This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
authornemo
Tue, 26 Jun 2012 23:02:25 -0400
changeset 7307 f830a65d6a6d
parent 7305 b242e91a92a9
child 7308 40aa797c4ef0
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Tue Jun 26 20:05:24 2012 -0400
+++ b/hedgewars/uScript.pas	Tue Jun 26 23:02:25 2012 -0400
@@ -184,10 +184,19 @@
 end;
 
 function lc_parsecommand(L : Plua_State) : LongInt; Cdecl;
+var t: PChar;
+    i,c: LongWord;
+    s: shortstring;
 begin
     if lua_gettop(L) = 1 then
         begin
-        ParseCommand(lua_tostring(L ,1), true);
+        t:= lua_tolstring(L,1,@c);
+
+        for i:= 1 to c do s[i]:= t[i-1];
+        s[0]:= char(c);
+
+        ParseCommand(s, true);
+
         end
     else
         LuaError('Lua: Wrong number of parameters passed to ParseCommand!');