hedgewars/uScript.pas
changeset 13340 85644a45e988
parent 13272 5984e8c6cbeb
child 13348 5f6208031658
child 13393 ae5d6448c5be
equal deleted inserted replaced
13339:450e37b2b4d4 13340:85644a45e988
  1922     if CheckAndFetchParamCount(L, 0, 1, call, params, n) then
  1922     if CheckAndFetchParamCount(L, 0, 1, call, params, n) then
  1923         if n >= 1 then
  1923         if n >= 1 then
  1924             LuaNoEndTurnTaunts:= lua_toboolean(L, 1);
  1924             LuaNoEndTurnTaunts:= lua_toboolean(L, 1);
  1925     LuaEndTurnRequested:= true;
  1925     LuaEndTurnRequested:= true;
  1926     lc_endturn:= 0
  1926     lc_endturn:= 0
       
  1927 end;
       
  1928 
       
  1929 function lc_retreat(L : Plua_State) : LongInt; Cdecl;
       
  1930 var n, time: LongInt;
       
  1931     respectFactor: Boolean;
       
  1932 const
       
  1933     call = 'Retreat';
       
  1934     params = 'time [, respectGetAwayTimeFactor]';
       
  1935 begin
       
  1936     if CheckAndFetchParamCount(L, 1, 2, call, params, n) then
       
  1937         begin
       
  1938         IsGetAwayTime:= true;
       
  1939         AttackBar:= 0;
       
  1940         time:= Trunc(lua_tonumber(L, 1));
       
  1941         if n = 2 then
       
  1942             respectFactor:= lua_toboolean(L, 2)
       
  1943         else
       
  1944             respectFactor:= True;
       
  1945         if respectFactor then
       
  1946             TurnTimeLeft:= (time * cGetAwayTime) div 100
       
  1947         else
       
  1948             TurnTimeLeft:= time;
       
  1949         if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then
       
  1950             begin
       
  1951             CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstAttacked;
       
  1952             CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and (not gstAttacking);
       
  1953             end;
       
  1954         end;
       
  1955     lc_retreat:= 0
  1927 end;
  1956 end;
  1928 
  1957 
  1929 function lc_skipturn(L : Plua_State): LongInt; Cdecl;
  1958 function lc_skipturn(L : Plua_State): LongInt; Cdecl;
  1930 begin
  1959 begin
  1931     L:= L; // avoid compiler hint
  1960     L:= L; // avoid compiler hint
  3828 lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole);
  3857 lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole);
  3829 lua_register(luaState, _P'WriteLnToChat', @lc_writelntochat);
  3858 lua_register(luaState, _P'WriteLnToChat', @lc_writelntochat);
  3830 lua_register(luaState, _P'GetGearType', @lc_getgeartype);
  3859 lua_register(luaState, _P'GetGearType', @lc_getgeartype);
  3831 lua_register(luaState, _P'EndGame', @lc_endgame);
  3860 lua_register(luaState, _P'EndGame', @lc_endgame);
  3832 lua_register(luaState, _P'EndTurn', @lc_endturn);
  3861 lua_register(luaState, _P'EndTurn', @lc_endturn);
       
  3862 lua_register(luaState, _P'Retreat', @lc_retreat);
  3833 lua_register(luaState, _P'SkipTurn', @lc_skipturn);
  3863 lua_register(luaState, _P'SkipTurn', @lc_skipturn);
  3834 lua_register(luaState, _P'GetTeamStats', @lc_getteamstats);
  3864 lua_register(luaState, _P'GetTeamStats', @lc_getteamstats);
  3835 lua_register(luaState, _P'SendStat', @lc_sendstat);
  3865 lua_register(luaState, _P'SendStat', @lc_sendstat);
  3836 lua_register(luaState, _P'SendGameResultOff', @lc_sendgameresultoff);
  3866 lua_register(luaState, _P'SendGameResultOff', @lc_sendgameresultoff);
  3837 lua_register(luaState, _P'SendRankingStatsOff', @lc_sendrankingstatsoff);
  3867 lua_register(luaState, _P'SendRankingStatsOff', @lc_sendrankingstatsoff);