# HG changeset patch # User nemo # Date 1534879589 14400 # Node ID 6c0cf6b9eff82c25a38a779eebe89e7d351f2870 # Parent f60b3998ba564a474f6326e253be02ee2f93cafb use 0s instead of nils to try to protect script assumptions diff -r f60b3998ba56 -r 6c0cf6b9eff8 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Tue Aug 21 15:11:28 2018 -0400 +++ b/hedgewars/uScript.pas Tue Aug 21 15:26:29 2018 -0400 @@ -862,10 +862,10 @@ end; end else - lua_pushnil(L); + lua_pushnumber(L,0); end else - lua_pushnil(L); // return value on stack (nil) + lua_pushnumber(L,0); // return value on stack (nil) lc_addvisualgear:= 1; // 1 return value end; @@ -904,7 +904,7 @@ function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; var vg: PVisualGear; begin - if not(cOnlyStats) and CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then + if not(cOnlyStats) and (Trunc(lua_tonumber(L, 1)) > 0) and CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then begin vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1))); if vg <> nil then @@ -922,14 +922,14 @@ end else begin - lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); - lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); + lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); + lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); end end else begin - lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); - lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); + lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); + lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); lua_pushnumber(L, 0); end; lc_getvisualgearvalues:= 10 end; @@ -938,7 +938,7 @@ var vg : PVisualGear; begin lc_setvisualgearvalues:= 0; - if cOnlyStats then exit; + if cOnlyStats or (Trunc(lua_tonumber(L, 1)) = 0) then exit; // Param count can be 1-11 at present // if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then // begin