hedgewars/uScript.pas
changeset 6415 af2047bb4f70
parent 6380 1ff5ad1d771b
parent 6328 d14adf1c7721
child 6430 93eefff23bcd
--- a/hedgewars/uScript.pas	Wed Nov 23 20:12:16 2011 +0300
+++ b/hedgewars/uScript.pas	Thu Nov 24 16:18:45 2011 +0100
@@ -45,6 +45,9 @@
 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
 function ScriptExists(fname : shortstring) : boolean;
 
+
+function ParseCommandOverride(key, value : shortstring) : shortstring;
+
 procedure initModule;
 procedure freeModule;
 
@@ -1724,6 +1727,25 @@
 GetGlobals;
 end;
 
+function ParseCommandOverride(key, value : shortstring) : shortstring;
+begin
+ParseCommandOverride:= value;
+if not ScriptExists('ParseCommandOverride') then exit;
+lua_getglobal(luaState, Str2PChar('ParseCommandOverride'));
+lua_pushstring(luaState, Str2PChar(key));
+lua_pushstring(luaState, Str2PChar(value));
+if lua_pcall(luaState, 2, 1, 0) <> 0 then
+    begin
+    LuaError('Lua: Error while calling ParseCommandOverride: ' + lua_tostring(luaState, -1));
+    lua_pop(luaState, 1)
+    end
+else
+    begin
+    ParseCommandOverride:= lua_tostring(luaState, -1);
+    lua_pop(luaState, 1)
+    end;
+end;
+
 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
 begin
 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0)
@@ -2077,6 +2099,11 @@
 ScriptExists:= false
 end;
 
+function ParseCommandOverride(key, value : shortstring) : shortstring;
+begin
+ParseCommandOverride:= value
+end;
+
 procedure initModule;
 begin
 end;