diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 2dbf41aaa..384f5d939 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -123,9 +123,11 @@ local function def_action_or_move(what, tab) if (what=="action") then -- Special default values or checking of actor members. -- KEEPINSYNC with ACTOR_CHECK in lunacon.lua for consistency. - local numframes, viewtype, incval = tab[2], tab[3], tab[4] + local numframes = tab[2] or tab.numframes + local viewtype = tab[3] or tab.viewtype + local incval = tab[4] or tab.incval - if (numframes==nil and tab.numframes==nil) then + if (numframes==nil) then am.numframes = 1 else check_number(numframes, 4) @@ -134,7 +136,7 @@ local function def_action_or_move(what, tab) end end - if (viewtype==nil and tab.viewtype==nil) then + if (viewtype==nil) then am.viewtype = 1 else check_number(viewtype, 4) @@ -143,7 +145,7 @@ local function def_action_or_move(what, tab) end end - if (incval==nil and tab.incval==nil) then + if (incval==nil) then am.incval = 1 end end diff --git a/polymer/eduke32/source/lunatic/defs_common.lua b/polymer/eduke32/source/lunatic/defs_common.lua index 1603d085d..362c1ba7c 100644 --- a/polymer/eduke32/source/lunatic/defs_common.lua +++ b/polymer/eduke32/source/lunatic/defs_common.lua @@ -801,17 +801,14 @@ end -- Construct const struct from table function conststruct(tab) - local strtab = { "const struct { int32_t " } - local vals = {} + local strtab = { "struct {" } for member, val in pairs(tab) do - strtab[#strtab+1] = member.."," - vals[#vals+1] = val + strtab[#strtab+1] = "static const int "..member.."="..val..";" end - strtab[#strtab] = strtab[#strtab]:gsub(',',';') strtab[#strtab+1] = "}" - return ffi.new(table.concat(strtab), vals) + return ffi.new(table.concat(strtab)) end -- Static, non-instance members. Used to hold constants, for example diff --git a/polymer/eduke32/source/lunatic/test.lua b/polymer/eduke32/source/lunatic/test.lua index 23800d923..e16a5c3d6 100644 --- a/polymer/eduke32/source/lunatic/test.lua +++ b/polymer/eduke32/source/lunatic/test.lua @@ -163,7 +163,7 @@ checkfail('print(sprite._nextspritesect[4].whatfield)', "attempt to index a numb -- our 'require' has only safe stuff --checkfail("require('os')") --- we must declare globals with 'gamevar' +-- gamevars are created using a special different mechanism checkfail("new_global = 345", "attempt to write into the global environment") -- can't redefine constants in 'gv'