hedgewars/uScript.pas
branchwebgl
changeset 8026 4a4f21070479
parent 8012 2a61631a4505
child 8096 453917e94e55
equal deleted inserted replaced
8023:7de85783b823 8026:4a4f21070479
   137         begin
   137         begin
   138         LuaError('Lua: Wrong number of parameters passed to bnot!');
   138         LuaError('Lua: Wrong number of parameters passed to bnot!');
   139         lua_pushnil(L);
   139         lua_pushnil(L);
   140         end
   140         end
   141     else
   141     else
   142         lua_pushinteger(L, not lua_tointeger(L, 1));
   142         lua_pushinteger(L, (not lua_tointeger(L, 1)));
   143     lc_bnot := 1;
   143     lc_bnot := 1;
   144 end;
   144 end;
   145 
   145 
   146 function lc_div(L: PLua_State): LongInt; Cdecl;
   146 function lc_div(L: PLua_State): LongInt; Cdecl;
   147 begin
   147 begin
  1246     lc_settag:= 0
  1246     lc_settag:= 0
  1247 end;
  1247 end;
  1248 
  1248 
  1249 function lc_endgame(L : Plua_State) : LongInt; Cdecl;
  1249 function lc_endgame(L : Plua_State) : LongInt; Cdecl;
  1250 begin
  1250 begin
       
  1251    {$IFNDEF PAS2C}
  1251     L:= L; // avoid compiler hint
  1252     L:= L; // avoid compiler hint
       
  1253    {$ENDIF}
  1252     GameState:= gsExit;
  1254     GameState:= gsExit;
  1253     lc_endgame:= 0
  1255     lc_endgame:= 0
  1254 end;
  1256 end;
  1255 
  1257 
  1256 function lc_findplace(L : Plua_State) : LongInt; Cdecl;
  1258 function lc_findplace(L : Plua_State) : LongInt; Cdecl;
  2016 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  2018 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  2017 end;
  2019 end;
  2018 
  2020 
  2019 procedure ScriptCall(fname : shortstring);
  2021 procedure ScriptCall(fname : shortstring);
  2020 begin
  2022 begin
  2021 if not ScriptLoaded or (not ScriptExists(fname)) then
  2023 if (not ScriptLoaded) or (not ScriptExists(fname)) then
  2022     exit;
  2024     exit;
  2023 SetGlobals;
  2025 SetGlobals;
  2024 lua_getglobal(luaState, Str2PChar(fname));
  2026 lua_getglobal(luaState, Str2PChar(fname));
  2025 if lua_pcall(luaState, 0, 0, 0) <> 0 then
  2027 if lua_pcall(luaState, 0, 0, 0) <> 0 then
  2026     begin
  2028     begin
  2067 ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
  2069 ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
  2068 end;
  2070 end;
  2069 
  2071 
  2070 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
  2072 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
  2071 begin
  2073 begin
  2072 if not ScriptLoaded or (not ScriptExists(fname)) then
  2074 if (not ScriptLoaded) or (not ScriptExists(fname)) then
  2073     exit;
  2075     exit;
  2074 SetGlobals;
  2076 SetGlobals;
  2075 lua_getglobal(luaState, Str2PChar(fname));
  2077 lua_getglobal(luaState, Str2PChar(fname));
  2076 lua_pushinteger(luaState, par1);
  2078 lua_pushinteger(luaState, par1);
  2077 lua_pushinteger(luaState, par2);
  2079 lua_pushinteger(luaState, par2);