# HG changeset patch # User Wuzzy # Date 1534891211 -7200 # Node ID 076b7d23fab8db384ca4ab54ea91721fd2f9416f # Parent 6c0cf6b9eff82c25a38a779eebe89e7d351f2870 Backed out changeset 6c0cf6b9eff8. Scripters should be prepared for nil and pretending the gear exists would cause more pain diff -r 6c0cf6b9eff8 -r 076b7d23fab8 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Tue Aug 21 15:26:29 2018 -0400 +++ b/hedgewars/uScript.pas Wed Aug 22 00:40:11 2018 +0200 @@ -862,10 +862,10 @@ end; end else - lua_pushnumber(L,0); + lua_pushnil(L); end else - lua_pushnumber(L,0); // return value on stack (nil) + lua_pushnil(L); // 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 (Trunc(lua_tonumber(L, 1)) > 0) and CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then + if not(cOnlyStats) 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_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); + 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); end end else begin - 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); + 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); end; lc_getvisualgearvalues:= 10 end; @@ -938,7 +938,7 @@ var vg : PVisualGear; begin lc_setvisualgearvalues:= 0; - if cOnlyStats or (Trunc(lua_tonumber(L, 1)) = 0) then exit; + if cOnlyStats 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