hedgewars/uScript.pas
changeset 13744 b3b55b03d499
parent 13731 247d1bcf3c5e
child 13746 e8f26bc793d9
equal deleted inserted replaced
13743:94bf5f976e3e 13744:b3b55b03d499
  3184     else
  3184     else
  3185         lua_pushboolean(L, false);
  3185         lua_pushboolean(L, false);
  3186     lc_explode:= 1;
  3186     lc_explode:= 1;
  3187 end;
  3187 end;
  3188 
  3188 
       
  3189 function lc_setturntimeleft(L : Plua_State) : LongInt; Cdecl;
       
  3190 begin
       
  3191     if CheckLuaParamCount(L, 1, 'SetTurnTimeLeft', 'TurnTimeLeft') then
       
  3192         TurnTimeLeft:= Trunc(lua_tonumber(L, 1));
       
  3193     lc_setturntimeleft:= 0;
       
  3194 end;
       
  3195 
       
  3196 function lc_setreadytimeleft(L : Plua_State) : LongInt; Cdecl;
       
  3197 begin
       
  3198     if CheckLuaParamCount(L, 1, 'SetReadyTimeLeft', 'ReadyTimeLeft') then
       
  3199         ReadyTimeLeft:= Trunc(lua_tonumber(L, 1));
       
  3200     lc_setreadytimeleft:= 0;
       
  3201 end;
       
  3202 
  3189 function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl;
  3203 function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl;
  3190 begin
  3204 begin
  3191     if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then
  3205     if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then
  3192         startGhostPoints(Trunc(lua_tonumber(L, 1)));
  3206         startGhostPoints(Trunc(lua_tonumber(L, 1)));
  3193     lc_startghostpoints:= 0
  3207     lc_startghostpoints:= 0
  3667     ScriptSetNil('CurrentHedgehog');
  3681     ScriptSetNil('CurrentHedgehog');
  3668 end;
  3682 end;
  3669 
  3683 
  3670 procedure GetGlobals;
  3684 procedure GetGlobals;
  3671 begin
  3685 begin
  3672 // TODO
  3686 // This function is deprecated.
  3673 // Use setters instead, because globals should be read-only!
  3687 // TODO: Remove this function.
  3674 // Otherwise globals might be changed by Lua, but then unexpectatly overwritten by engine when a ScriptCall is triggered by whatever Lua is doing!
  3688 // Setting TurnTimeLeft and ReadyTimeLeft is now done in the setter functions
  3675 // Sure, one could work around that in engine (e.g. by setting writable globals in SetGlobals only when their engine-side value has actually changed since SetGlobals was called the last time...), but things just get messier and messier then.
  3689 // SetTurnTimeLeft and SetReadTimeLeft.
  3676 // It is inconsistent anyway to have some globals be read-only and others not with no indication whatsoever.
  3690 // GetGloals should be removed in a future release.
  3677 // -- sheepluva
       
  3678 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  3691 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  3679 ReadyTimeLeft:= ScriptGetInteger('ReadyTimeLeft');
  3692 ReadyTimeLeft:= ScriptGetInteger('ReadyTimeLeft');
  3680 end;
  3693 end;
  3681 
  3694 
  3682 procedure ScriptCall(fname : shortstring);
  3695 procedure ScriptCall(fname : shortstring);
  4174 lua_register(luaState, _P'SetVampiric', @lc_setvampiric);
  4187 lua_register(luaState, _P'SetVampiric', @lc_setvampiric);
  4175 lua_register(luaState, _P'GetVampiric', @lc_getvampiric);
  4188 lua_register(luaState, _P'GetVampiric', @lc_getvampiric);
  4176 lua_register(luaState, _P'SetLaserSight', @lc_setlasersight);
  4189 lua_register(luaState, _P'SetLaserSight', @lc_setlasersight);
  4177 lua_register(luaState, _P'GetLaserSight', @lc_getlasersight);
  4190 lua_register(luaState, _P'GetLaserSight', @lc_getlasersight);
  4178 lua_register(luaState, _P'Explode', @lc_explode);
  4191 lua_register(luaState, _P'Explode', @lc_explode);
       
  4192 lua_register(luaState, _P'SetTurnTimeLeft', @lc_setturntimeleft);
       
  4193 lua_register(luaState, _P'SetReadyTimeLeft', @lc_setreadytimeleft);
  4179 // drawn map functions
  4194 // drawn map functions
  4180 lua_register(luaState, _P'AddPoint', @lc_addPoint);
  4195 lua_register(luaState, _P'AddPoint', @lc_addPoint);
  4181 lua_register(luaState, _P'FlushPoints', @lc_flushPoints);
  4196 lua_register(luaState, _P'FlushPoints', @lc_flushPoints);
  4182 
  4197 
  4183 lua_register(luaState, _P'SetGearAIHints', @lc_setgearaihints);
  4198 lua_register(luaState, _P'SetGearAIHints', @lc_setgearaihints);