diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 3219a0b78..cbf558330 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -1852,6 +1852,8 @@ end -- is kinda breaking the classic "no array nesting" rules -- (if there ever were any) but making our life harder else. local arraypat = sp0 * "[" * sp0 * tok.rvar * sp0 * "]" +-- For {get,set}userdef: +local arraypat_maybe_empty = sp0 * "[" * sp0 * (tok.rvar * sp0)^-1 * "]" -- Table of various patterns that are (parts of) more complex inner commands. local patt = {} @@ -2263,7 +2265,8 @@ local handle = soundonce = "_con._soundonce(_aci,%1)", } -local userdef_common_pat = (arraypat + sp1)/{} * lpeg.Cc(0) * lpeg.Ct(patt.singlemember) * sp1 +local userdef_common_pat = (arraypat_maybe_empty + sp1)/{} + * lpeg.Cc(0) * lpeg.Ct(patt.singlemember) * sp1 -- NOTE about prefixes: most is handled by all_alt_pattern(), however commands -- that have no arguments and that are prefixes of other commands MUST be diff --git a/polymer/eduke32/source/lunatic/test/getuserdef.con b/polymer/eduke32/source/lunatic/test/getuserdef.con index a9869d201..d81d56233 100644 --- a/polymer/eduke32/source/lunatic/test/getuserdef.con +++ b/polymer/eduke32/source/lunatic/test/getuserdef.con @@ -1,16 +1,26 @@ -// XXX: should be allowed to override existing modes? (Probably yes.) -// XXX: but currently, this ensues badness? (g_numGametypes becomes inconsistent?) -definegametype 0 46051 Cooperative +definegametype 0 46051 Cooperative, not Dukematch + +// NOTE: we need to define the rest anew too (or at least #4), because +// 'definegametype' does "g_numGametypes = idx+1", as opposed to +// "g_numGametypes = max(g_numGametypes, idx+1)". +definegametype 1 46051 Cooperative +definegametype 2 16410 Dukematch (no spawn) +definegametype 3 216088 Team Dukematch +definegametype 4 213018 Team Dukematch (no spawn) gamevar temp 0 0 // Original version by Fox, from // http://forums.duke4.net/topic/775-eduke32-20-and-polymer/page__view__findpost__p__183890 onevent EVENT_DISPLAYREST -// getuserdef[THISACTOR].statusbarscale temp - // NOTE: index (THISACTOR) is never used. - // NOTE: incorrect if screenpeek != myconnectindex, e.g. by pressing [K]: + // Notes: + // - index (THISACTOR) is never used. + // - incorrect if screenpeek != myconnectindex, e.g. by pressing [K]: + // - all three are equivalent: + getuserdef[THISACTOR].statusbarscale temp getuserdef .statusbarscale temp + getuserdef[].statusbarscale temp + redefinequote 0 %ld qsprintf 0 0 temp gametext STARTALPHANUM 10 10 0 0 0 0 0 0 xdim ydim