From 67db095bd3898403ced2493af67f8870c843377d Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 30 Jun 2013 20:38:41 +0000 Subject: [PATCH] Lunatic: require'CON.ACTION' etc. gets composites from CON; add actor.MOVFLAGS. git-svn-id: https://svn.eduke32.com/eduke32@3917 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/defs.ilua | 37 +++++++++++++++++----- polymer/eduke32/source/lunatic/lunacon.lua | 2 +- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index b2f8afbb7..4178cf01f 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -827,8 +827,22 @@ do actor_static_members.STAT = defs_c.conststruct(our_STAT) - -- TODO: actor_static_members.movflags? They can be obtained with - -- require('CON.DEFS') now... + actor_static_members.MOVFLAGS = defs_c.conststruct + { + -- NOTE: no underscores, like in DEFS.CON. + faceplayer = 1, + geth = 2, + getv = 4, + randomangle = 8, + faceplayerslow = 16, + spin = 32, + faceplayersmart = 64, + fleeenemy = 128, + jumptoplayer = 257, + seekplayer = 512, + furthestdir = 1024, + dodgebullet = 4096, + } end -- Delete sprite with index . @@ -1448,14 +1462,14 @@ do end -- Protect base modules. -local function basemodule_newindex() +local function basemod_newidx() error("modifying base module table forbidden", 2) end for modname, themodule in pairs(allowed_modules) do local mt = { __index = themodule, - __newindex = basemodule_newindex, + __newindex = basemod_newidx, } allowed_modules[modname] = setmtonce({}, mt) @@ -2265,12 +2279,19 @@ if (concode) then -- Emulate our 'require' for the CON module when running it, for -- our_module() which is called from the generated Lua code. table.insert(modname_stack, CON_MODULE_NAME) - local conlabels = confunc() + local conlabels, conaction, conmove, conai = confunc() table.remove(modname_stack) - -- Set up CON.DEFS module, providing access to labels defined in CON from Lua. - local mt = { __index = conlabels, __newindex = basemodule_newindex } - allowed_modules["CON.DEFS"] = setmtonce({}, mt) + local function protect_con_table(tab) + return setmtonce({}, { __index=tab, __newindex=basemod_newidx }) + end + + -- Set up CON.* modules, providing access to diffenrent kinds of labels + -- defined in CON from Lua. See CONCODE_RETURN in lunacon.lua. + allowed_modules["CON.DEFS"] = protect_con_table(conlabels) + allowed_modules["CON.ACTION"] = protect_con_table(conaction) + allowed_modules["CON.MOVE"] = protect_con_table(conmove) + allowed_modules["CON.AI"] = protect_con_table(conai) -- Propagate potentially remapped defines to the control module. con._setuplabels(conlabels) diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 3c305a94c..e5359ec0f 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -3348,7 +3348,7 @@ local function get_code_string(codetab, lineinfop) codetab[#codetab+1] = format("[%q]=%d,", label, val) end end - codetab[#codetab+1] = "}" + codetab[#codetab+1] = "},_C,_M,_I" -- CONCODE_RETURN local flatcode = flatten_codetab(codetab) local lineinfo = lineinfop and get_lineinfo(flatcode)