hedgewars/uScript.pas
changeset 6415 af2047bb4f70
parent 6380 1ff5ad1d771b
parent 6328 d14adf1c7721
child 6430 93eefff23bcd
equal deleted inserted replaced
6414:8474b7fa84d6 6415:af2047bb4f70
    42 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
    42 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
    43 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt;
    43 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt;
    44 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
    44 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
    45 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
    45 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
    46 function ScriptExists(fname : shortstring) : boolean;
    46 function ScriptExists(fname : shortstring) : boolean;
       
    47 
       
    48 
       
    49 function ParseCommandOverride(key, value : shortstring) : shortstring;
    47 
    50 
    48 procedure initModule;
    51 procedure initModule;
    49 procedure freeModule;
    52 procedure freeModule;
    50 
    53 
    51 implementation
    54 implementation
  1720     begin
  1723     begin
  1721     LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
  1724     LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
  1722     lua_pop(luaState, 1)
  1725     lua_pop(luaState, 1)
  1723     end;
  1726     end;
  1724 GetGlobals;
  1727 GetGlobals;
       
  1728 end;
       
  1729 
       
  1730 function ParseCommandOverride(key, value : shortstring) : shortstring;
       
  1731 begin
       
  1732 ParseCommandOverride:= value;
       
  1733 if not ScriptExists('ParseCommandOverride') then exit;
       
  1734 lua_getglobal(luaState, Str2PChar('ParseCommandOverride'));
       
  1735 lua_pushstring(luaState, Str2PChar(key));
       
  1736 lua_pushstring(luaState, Str2PChar(value));
       
  1737 if lua_pcall(luaState, 2, 1, 0) <> 0 then
       
  1738     begin
       
  1739     LuaError('Lua: Error while calling ParseCommandOverride: ' + lua_tostring(luaState, -1));
       
  1740     lua_pop(luaState, 1)
       
  1741     end
       
  1742 else
       
  1743     begin
       
  1744     ParseCommandOverride:= lua_tostring(luaState, -1);
       
  1745     lua_pop(luaState, 1)
       
  1746     end;
  1725 end;
  1747 end;
  1726 
  1748 
  1727 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
  1749 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
  1728 begin
  1750 begin
  1729 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0)
  1751 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0)
  2075 function ScriptExists(fname : shortstring) : boolean;
  2097 function ScriptExists(fname : shortstring) : boolean;
  2076 begin
  2098 begin
  2077 ScriptExists:= false
  2099 ScriptExists:= false
  2078 end;
  2100 end;
  2079 
  2101 
       
  2102 function ParseCommandOverride(key, value : shortstring) : shortstring;
       
  2103 begin
       
  2104 ParseCommandOverride:= value
       
  2105 end;
       
  2106 
  2080 procedure initModule;
  2107 procedure initModule;
  2081 begin
  2108 begin
  2082 end;
  2109 end;
  2083 
  2110 
  2084 procedure freeModule;
  2111 procedure freeModule;