LunaCON: accept empty square brackets for {g,s}etuserdef optional index part.

git-svn-id: https://svn.eduke32.com/eduke32@4287 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-02-01 16:19:55 +00:00
parent 842cce37b7
commit 7c26c180cd
2 changed files with 20 additions and 7 deletions

View file

@ -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

View file

@ -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