hedgewars/uScript.pas
changeset 3003 0afdba08a858
parent 2999 30c4d62cd0c3
child 3004 e9b3613cc3fb
equal deleted inserted replaced
3002:9bf51d5a8a80 3003:0afdba08a858
   349 procedure ScriptClearStack;
   349 procedure ScriptClearStack;
   350 begin
   350 begin
   351 lua_settop(luaState, 0)
   351 lua_settop(luaState, 0)
   352 end;
   352 end;
   353 
   353 
       
   354 procedure ScriptSetNil(name : shortstring);
       
   355 begin
       
   356 lua_pushnil(luaState);
       
   357 lua_setglobal(luaState, Str2PChar(name));
       
   358 end;
       
   359 
   354 procedure ScriptSetInteger(name : shortstring; value : LongInt);
   360 procedure ScriptSetInteger(name : shortstring; value : LongInt);
   355 begin
   361 begin
   356 lua_pushinteger(luaState, value);
   362 lua_pushinteger(luaState, value);
   357 lua_setglobal(luaState, Str2PChar(name));
   363 lua_setglobal(luaState, Str2PChar(name));
   358 end;
   364 end;
   441 end;
   447 end;
   442 
   448 
   443 procedure SetGlobals;
   449 procedure SetGlobals;
   444 begin
   450 begin
   445 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
   451 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
       
   452 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then
       
   453     ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID)
       
   454 else
       
   455     ScriptSetNil('CurrentHedgehog');
   446 end;
   456 end;
   447 
   457 
   448 procedure GetGlobals;
   458 procedure GetGlobals;
   449 begin
   459 begin
   450 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
   460 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');