hedgewars/uScript.pas
changeset 6453 11c578d30bd3
parent 6430 93eefff23bcd
child 6468 da1e7fe7cff7
equal deleted inserted replaced
6452:7c6f9b6672dc 6453:11c578d30bd3
    51 procedure initModule;
    51 procedure initModule;
    52 procedure freeModule;
    52 procedure freeModule;
    53 
    53 
    54 implementation
    54 implementation
    55 {$IFNDEF LUA_DISABLED}
    55 {$IFNDEF LUA_DISABLED}
    56 uses LuaPas in 'LuaPas.pas',
    56 uses LuaPas,
    57     uConsole,
    57     uConsole,
    58     uConsts,
    58     uConsts,
    59     uVisualGears,
    59     uVisualGears,
    60     uGears,
    60     uGears,
    61     uFloat,
    61     uFloat,
  1713 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  1713 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
  1714 end;
  1714 end;
  1715 
  1715 
  1716 procedure ScriptCall(fname : shortstring);
  1716 procedure ScriptCall(fname : shortstring);
  1717 begin
  1717 begin
  1718 if not ScriptLoaded or not ScriptExists(fname) then
  1718 if not ScriptLoaded or (not ScriptExists(fname)) then
  1719     exit;
  1719     exit;
  1720 SetGlobals;
  1720 SetGlobals;
  1721 lua_getglobal(luaState, Str2PChar(fname));
  1721 lua_getglobal(luaState, Str2PChar(fname));
  1722 if lua_pcall(luaState, 0, 0, 0) <> 0 then
  1722 if lua_pcall(luaState, 0, 0, 0) <> 0 then
  1723     begin
  1723     begin
  1761 ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
  1761 ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
  1762 end;
  1762 end;
  1763 
  1763 
  1764 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
  1764 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
  1765 begin
  1765 begin
  1766 if not ScriptLoaded or not ScriptExists(fname) then
  1766 if not ScriptLoaded or (not ScriptExists(fname)) then
  1767     exit;
  1767     exit;
  1768 SetGlobals;
  1768 SetGlobals;
  1769 lua_getglobal(luaState, Str2PChar(fname));
  1769 lua_getglobal(luaState, Str2PChar(fname));
  1770 lua_pushinteger(luaState, par1);
  1770 lua_pushinteger(luaState, par1);
  1771 lua_pushinteger(luaState, par2);
  1771 lua_pushinteger(luaState, par2);