hedgewars/uScript.pas
changeset 10015 4feced261c68
parent 10009 88929358d2e1
parent 9952 32f5982604f4
child 10040 4ac87acbaed9
equal deleted inserted replaced
10014:56d2f2d5aad8 10015:4feced261c68
    83     uLandGraphics,
    83     uLandGraphics,
    84     SysUtils,
    84     SysUtils,
    85     uIO,
    85     uIO,
    86     uVisualGearsList,
    86     uVisualGearsList,
    87     uGearsHandlersMess,
    87     uGearsHandlersMess,
    88     uPhysFSLayer,
    88     uPhysFSLayer
    89     typinfo
    89 {$IFDEF PAS2C}
       
    90     , hwpacksmounter
       
    91 {$ELSE}
       
    92     , typinfo
       
    93 {$ENDIF}
    90     ;
    94     ;
    91 
    95 
    92 var luaState : Plua_State;
    96 var luaState : Plua_State;
    93     ScriptAmmoLoadout : shortstring;
    97     ScriptAmmoLoadout : shortstring;
    94     ScriptAmmoProbability : shortstring;
    98     ScriptAmmoProbability : shortstring;
   153         begin
   157         begin
   154         LuaParameterCountError('bnot', 'value', lua_gettop(L));
   158         LuaParameterCountError('bnot', 'value', lua_gettop(L));
   155         lua_pushnil(L);
   159         lua_pushnil(L);
   156         end
   160         end
   157     else
   161     else
   158         lua_pushinteger(L, not lua_tointeger(L, 1));
   162         lua_pushinteger(L, (not lua_tointeger(L, 1)));
   159     lc_bnot := 1;
   163     lc_bnot := 1;
   160 end;
   164 end;
   161 
   165 
   162 function lc_div(L: PLua_State): LongInt; Cdecl;
   166 function lc_div(L: PLua_State): LongInt; Cdecl;
   163 begin
   167 begin
   249 
   253 
   250 function lc_disablegameflags(L : Plua_State) : LongInt; Cdecl;
   254 function lc_disablegameflags(L : Plua_State) : LongInt; Cdecl;
   251 var i : integer;
   255 var i : integer;
   252 begin
   256 begin
   253     for i:= 1 to lua_gettop(L) do
   257     for i:= 1 to lua_gettop(L) do
   254         GameFlags := GameFlags and not(LongWord(lua_tointeger(L, i)));
   258         GameFlags := (GameFlags and (not (LongWord(lua_tointeger(L, i)))));
   255     ScriptSetInteger('GameFlags', GameFlags);
   259     ScriptSetInteger('GameFlags', GameFlags);
   256     lc_disablegameflags:= 0;
   260     lc_disablegameflags:= 0;
   257 end;
   261 end;
   258 
   262 
   259 function lc_cleargameflags(L : Plua_State) : LongInt; Cdecl;
   263 function lc_cleargameflags(L : Plua_State) : LongInt; Cdecl;
  1170                 begin
  1174                 begin
  1171                 RenderHealth(gear^.Hedgehog^);
  1175                 RenderHealth(gear^.Hedgehog^);
  1172                 RecountTeamHealth(gear^.Hedgehog^.Team)
  1176                 RecountTeamHealth(gear^.Hedgehog^.Team)
  1173                 end;
  1177                 end;
  1174             // Why did this do a "setalltoactive" ?
  1178             // Why did this do a "setalltoactive" ?
  1175             //SetAllToActive;  
  1179             //SetAllToActive;
  1176             Gear^.Active:= true;
  1180             Gear^.Active:= true;
  1177             AllInactive:= false
  1181             AllInactive:= false
  1178             end
  1182             end
  1179         end;
  1183         end;
  1180     lc_sethealth:= 0
  1184     lc_sethealth:= 0
  2239 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  2243 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  2240 end;
  2244 end;
  2241 
  2245 
  2242 procedure ScriptCall(fname : shortstring);
  2246 procedure ScriptCall(fname : shortstring);
  2243 begin
  2247 begin
  2244 if not ScriptLoaded or (not ScriptExists(fname)) then
  2248 if (not ScriptLoaded) or (not ScriptExists(fname)) then
  2245     exit;
  2249     exit;
  2246 SetGlobals;
  2250 SetGlobals;
  2247 lua_getglobal(luaState, Str2PChar(fname));
  2251 lua_getglobal(luaState, Str2PChar(fname));
  2248 if lua_pcall(luaState, 0, 0, 0) <> 0 then
  2252 if lua_pcall(luaState, 0, 0, 0) <> 0 then
  2249     begin
  2253     begin
  2290 ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
  2294 ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
  2291 end;
  2295 end;
  2292 
  2296 
  2293 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
  2297 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
  2294 begin
  2298 begin
  2295 if not ScriptLoaded or (not ScriptExists(fname)) then
  2299 if (not ScriptLoaded) or (not ScriptExists(fname)) then
  2296     exit;
  2300     exit;
  2297 SetGlobals;
  2301 SetGlobals;
  2298 lua_getglobal(luaState, Str2PChar(fname));
  2302 lua_getglobal(luaState, Str2PChar(fname));
  2299 lua_pushinteger(luaState, par1);
  2303 lua_pushinteger(luaState, par1);
  2300 lua_pushinteger(luaState, par2);
  2304 lua_pushinteger(luaState, par2);