Lua API: Fix Goals text being cut off at ca. 255 characters
authorWuzzy <Wuzzy2@mail.ru>
Tue, 24 Oct 2017 04:48:20 +0200
changeset 12754 1df909b46c05
parent 12753 aa96dec39da8
child 12755 6cec6b881a1c
Lua API: Fix Goals text being cut off at ca. 255 characters
ChangeLog.txt
hedgewars/uScript.pas
hedgewars/uVariables.pas
--- a/ChangeLog.txt	Tue Oct 24 04:06:03 2017 +0200
+++ b/ChangeLog.txt	Tue Oct 24 04:48:20 2017 +0200
@@ -381,6 +381,7 @@
  * Fixed call: HideHog(gear) -- Fix crash when gear is invalid. Returns true on success or false otherwise
  * Fixed call: SwitchHog(gear) -- Fix new hog being unable to open ammo menu
  * Removed call: SetAmmoStore -- Old undocumented function of questional use, has never been used
+ * Fixed variable: Goals -- Fix Goals text being cut off at ca. 255 characters
  * Fix huge numbers having sign errors on 64-bit architectures
 
 ====================== 0.9.22 ======================
--- 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;
--- a/hedgewars/uVariables.pas	Tue Oct 24 04:06:03 2017 +0200
+++ b/hedgewars/uVariables.pas	Tue Oct 24 04:48:20 2017 +0200
@@ -244,7 +244,7 @@
 
     hiTicks: Word;
 
-    LuaGoals        : shortstring;
+    LuaGoals        : ansistring;
 
     LuaTemplateNumber : LongWord;