218 lua_pushnil(L); |
218 lua_pushnil(L); |
219 end; |
219 end; |
220 lc_gethogname:= 1 |
220 lc_gethogname:= 1 |
221 end; |
221 end; |
222 |
222 |
|
223 function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
|
224 var gear : PGear; |
|
225 begin |
|
226 if lua_gettop(L) <> 1 then |
|
227 begin |
|
228 LuaError('Lua: Wrong number of parameters passed to GetTimer!'); |
|
229 lua_pushnil(L); // return value on stack (nil) |
|
230 end |
|
231 else |
|
232 begin |
|
233 gear:= GearByUID(lua_tointeger(L, 1)); |
|
234 if gear <> nil then |
|
235 lua_pushnumber(L, gear^.Timer) |
|
236 else |
|
237 lua_pushnil(L); |
|
238 end; |
|
239 lc_gettimer:= 1 |
|
240 end; |
|
241 |
|
242 function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
|
243 var gear : PGear; |
|
244 begin |
|
245 if lua_gettop(L) <> 1 then |
|
246 begin |
|
247 LuaError('Lua: Wrong number of parameters passed to GetHealth!'); |
|
248 lua_pushnil(L); // return value on stack (nil) |
|
249 end |
|
250 else |
|
251 begin |
|
252 gear:= GearByUID(lua_tointeger(L, 1)); |
|
253 if gear <> nil then |
|
254 lua_pushnumber(L, gear^.Health) |
|
255 else |
|
256 lua_pushnil(L); |
|
257 end; |
|
258 lc_gethealth:= 1 |
|
259 end; |
|
260 |
223 function lc_getx(L : Plua_State) : LongInt; Cdecl; |
261 function lc_getx(L : Plua_State) : LongInt; Cdecl; |
224 var gear : PGear; |
262 var gear : PGear; |
225 begin |
263 begin |
226 if lua_gettop(L) <> 1 then |
264 if lua_gettop(L) <> 1 then |
227 begin |
265 begin |
326 begin |
364 begin |
327 gear:= GearByUID(lua_tointeger(L, 1)); |
365 gear:= GearByUID(lua_tointeger(L, 1)); |
328 if gear <> nil then gear^.Health:= lua_tointeger(L, 2) |
366 if gear <> nil then gear^.Health:= lua_tointeger(L, 2) |
329 end; |
367 end; |
330 lc_sethealth:= 0 |
368 lc_sethealth:= 0 |
|
369 end; |
|
370 |
|
371 function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
|
372 var gear : PGear; |
|
373 begin |
|
374 if lua_gettop(L) <> 2 then |
|
375 begin |
|
376 LuaError('Lua: Wrong number of parameters passed to SetTimer!'); |
|
377 end |
|
378 else |
|
379 begin |
|
380 gear:= GearByUID(lua_tointeger(L, 1)); |
|
381 if gear <> nil then gear^.Timer:= lua_tointeger(L, 2) |
|
382 end; |
|
383 lc_settimer:= 0 |
331 end; |
384 end; |
332 |
385 |
333 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
386 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
334 var gear : PGear; |
387 var gear : PGear; |
335 begin |
388 begin |
818 lua_register(luaState, 'FollowGear', @lc_followgear); |
871 lua_register(luaState, 'FollowGear', @lc_followgear); |
819 lua_register(luaState, 'GetFollowGear', @lc_getfollowgear); |
872 lua_register(luaState, 'GetFollowGear', @lc_getfollowgear); |
820 lua_register(luaState, 'SetState', @lc_setstate); |
873 lua_register(luaState, 'SetState', @lc_setstate); |
821 lua_register(luaState, 'GetState', @lc_getstate); |
874 lua_register(luaState, 'GetState', @lc_getstate); |
822 lua_register(luaState, 'SetTag', @lc_settag); |
875 lua_register(luaState, 'SetTag', @lc_settag); |
|
876 lua_register(luaState, 'SetTimer', @lc_settimer); |
|
877 lua_register(luaState, 'GetTimer', @lc_gettimer); |
|
878 lua_register(luaState, 'GetHealth', @lc_gethealth); |
823 |
879 |
824 |
880 |
825 ScriptClearStack; // just to be sure stack is empty |
881 ScriptClearStack; // just to be sure stack is empty |
826 ScriptLoaded:= false; |
882 ScriptLoaded:= false; |
827 end; |
883 end; |