--- a/hedgewars/uScript.pas Sun Jun 15 23:48:06 2014 +0200
+++ b/hedgewars/uScript.pas Mon Jun 16 02:23:37 2014 +0200
@@ -48,6 +48,7 @@
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
function ScriptExists(fname : shortstring) : boolean;
+procedure LuaParseString(s: shortString);
//function ParseCommandOverride(key, value : shortstring) : shortstring; This did not work out well
@@ -107,6 +108,17 @@
var LuaDebugInfo: lua_Debug;
+procedure LuaParseString(s: shortString);
+begin
+ AddFileLog('[Lua] input string: ' + s);
+ AddChatString(#3 + '[Lua] > ' + s);
+ if luaL_dostring(luaState, Str2PChar(s)) <> 0 then
+ begin
+ AddFileLog('[Lua] input string parsing error!');
+ AddChatString(#5 + '[Lua] Error while parsing!');
+ end;
+end;
+
function LuaUpdateDebugInfo(): Boolean;
begin
FillChar(LuaDebugInfo, sizeof(LuaDebugInfo), 0);
@@ -2384,8 +2396,8 @@
if ret <> 0 then
begin
- LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
- LuaError('Lua: ' + lua_tostring(luaState, -1));
+ LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
+ LuaError(lua_tostring(luaState, -1));
end
else
begin
@@ -2431,7 +2443,7 @@
lua_getglobal(luaState, Str2PChar(fname));
if lua_pcall(luaState, 0, 0, 0) <> 0 then
begin
- LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
+ LuaError('Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
lua_pop(luaState, 1)
end;
GetGlobals;
@@ -2487,7 +2499,7 @@
ScriptCall:= 0;
if lua_pcall(luaState, 4, 1, 0) <> 0 then
begin
- LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
+ LuaError('Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
lua_pop(luaState, 1)
end
else