diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 0aa573b9f..06bca54e1 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -1188,6 +1188,10 @@ function _cansee(aci, ps) local spr = sprite[aci] local s = sprite[ps.i] + -- This is kind of redundant, but points the error messages to the CON code. + check_sector_idx(spr.sectnum) + check_sector_idx(s.sectnum) + if (ps.holoduke_on >= 0) then -- If holoduke is on, let them target holoduke first. local hs = sprite[ps.holoduke_on] diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index c674a3c02..8f92917eb 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -913,6 +913,11 @@ ffi.metatype("actor_t", actor_mt) --- PER-PLAYER WEAPON SETTINGS local weapondata_mt = { + __index = function(wd, member) + -- Handle protected members that are renamed (e.g. shoots/_shoots). + return ffi.cast(weapondata_ptr_ct, wd)[member] + end, + __newindex = function(wd, member, val) if (string.match(member, "sound")) then if (val < 0) then diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index d64dffe06..bc2d8b87b 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -2567,11 +2567,15 @@ local function after_if_cmd_Cmt(subj, pos, ...) local capts = {...} assert(capts[1] ~= nil) assert(#capts <= 3) - for i=1,#capts do - assert(type(capts[i]=="string")) + + for i=#capts,1, -1 do + assert(type(capts[i])=="string" or type(capts[i])=="table") end - -- TODO: make if* commands have line numbers. + -- IF_LINE_NUMBERING + local firstistab = (type(capts[1])=="table") + attachlinenum(firstistab and capts[1] or capts, pos) + return true, unpack(capts) end @@ -2750,6 +2754,7 @@ function on.if_else_end(ifconds, ifstmt, elsestmt, ...) -- and it's always idempotent (executing it multiple times has the same -- effect as executing it once), so generate code for it only once, too. local deferred = { nil, nil } + local linenum = "" local ifcondstr = {} for i=1,#ifconds do @@ -2759,6 +2764,13 @@ function on.if_else_end(ifconds, ifstmt, elsestmt, ...) ifcondstr[i] = hasmore and cond[1] or cond assert(type(ifcondstr[i])=="string") + -- IF_LINE_NUMBERING + local tlinum = assert(ifcondstr[i]:match("^.*(%-%-[0-9]+)$")) + ifcondstr[i] = assert(ifcondstr[i]:match("^(.*)%-%-[0-9]+$")) + if (linenum == "") then + linenum = tlinum + end + if (hasmore) then for i=1,2 do if (deferred[i]==nil) then @@ -2772,7 +2784,7 @@ function on.if_else_end(ifconds, ifstmt, elsestmt, ...) local conds = "(" .. table.concat(ifcondstr, ")and(") .. ")" local code = { - format("if %s then", conds), + format("if %s then%s", conds, linenum), assert(ifstmt), }