hedgewars/uScript.pas
changeset 12754 1df909b46c05
parent 12688 047c5b7ec422
child 12852 1aba77b2e4ac
--- a/hedgewars/uScript.pas	Tue Oct 24 04:06:03 2017 +0200
+++ b/hedgewars/uScript.pas	Tue Oct 24 04:48:20 2017 +0200
@@ -2887,6 +2887,13 @@
     lua_pop(luaState, 1);
 end;
 
+function ScriptGetAnsiString(name : shortstring) : ansistring;
+begin
+    lua_getglobal(luaState, Str2PChar(name));
+    ScriptGetAnsiString:= lua_tostringa(luaState, -1);
+    lua_pop(luaState, 1);
+end;
+
 procedure ScriptOnPreviewInit;
 begin
 // not required if there is no script to run
@@ -2982,7 +2989,7 @@
     ParseCommand('map ' + ScriptGetString('Map'), true, true);
 if ScriptGetString('Theme') <> '' then
     ParseCommand('theme ' + ScriptGetString('Theme'), true, true);
-LuaGoals:= ScriptGetString('Goals');
+LuaGoals:= ScriptGetAnsiString('Goals');
 
 // Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around.
 k:= 0;