mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-14 08:30:58 +00:00
Lunatic translator: eventloadactor.
git-svn-id: https://svn.eduke32.com/eduke32@3515 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
6682313e87
commit
b0a8a381c8
2 changed files with 36 additions and 6 deletions
|
@ -127,8 +127,8 @@ local g_gamearray = {}
|
||||||
local g_have_file = {} -- [filename]=true
|
local g_have_file = {} -- [filename]=true
|
||||||
local g_curcode = nil -- a table of string pieces or other "gencode" tables
|
local g_curcode = nil -- a table of string pieces or other "gencode" tables
|
||||||
|
|
||||||
-- [{actor, event, actor}num]=gencode_table
|
-- will be a table, see reset_codegen()
|
||||||
local g_code = { actor={}, event={}, loadactor={} }
|
local g_code = nil
|
||||||
|
|
||||||
|
|
||||||
local function ACS(s) return "actor[_aci]"..s end
|
local function ACS(s) return "actor[_aci]"..s end
|
||||||
|
@ -263,7 +263,8 @@ local function reset_codegen()
|
||||||
|
|
||||||
g_have_file = {}
|
g_have_file = {}
|
||||||
g_curcode = new_initial_codetab()
|
g_curcode = new_initial_codetab()
|
||||||
g_code.actor, g_code.event, g_code.loadactor = {}, {}, {}
|
-- [{actor, event, actor}num]=gencode_table
|
||||||
|
g_code = { actor={}, event={}, loadactor={} }
|
||||||
|
|
||||||
g_recurslevel = -1
|
g_recurslevel = -1
|
||||||
g_numerrors = 0
|
g_numerrors = 0
|
||||||
|
@ -284,6 +285,8 @@ local function add_code_and_end(codetab, endstr)
|
||||||
addcode(endstr)
|
addcode(endstr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function warnprintf() end -- fwd-decl
|
||||||
|
|
||||||
local on = {}
|
local on = {}
|
||||||
|
|
||||||
function on.actor_end(usertype, tsamm, codetab)
|
function on.actor_end(usertype, tsamm, codetab)
|
||||||
|
@ -306,6 +309,10 @@ function on.actor_end(usertype, tsamm, codetab)
|
||||||
addcodef("gameactor(%d,%sfunction(_aci, _pli, _dist)", tilenum, str)
|
addcodef("gameactor(%d,%sfunction(_aci, _pli, _dist)", tilenum, str)
|
||||||
add_code_and_end(codetab, "end)")
|
add_code_and_end(codetab, "end)")
|
||||||
|
|
||||||
|
if (g_code.actor[tilenum] ~= nil) then
|
||||||
|
-- XXX: position will be that of last command in actor code
|
||||||
|
warnprintf("redefined actor %d", tilenum)
|
||||||
|
end
|
||||||
g_code.actor[tilenum] = codetab
|
g_code.actor[tilenum] = codetab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -343,6 +350,20 @@ function on.event_end(eventidx, codetab)
|
||||||
g_code.event[eventidx] = codetab
|
g_code.event[eventidx] = codetab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function on.eventloadactor_end(tilenum, codetab)
|
||||||
|
-- Translate eventloadactor into a chained EVENT_LOADACTOR block
|
||||||
|
addcode("gameevent('LOADACTOR', function (_aci, _pli, _dist)")
|
||||||
|
addcodef("if (%s==%d) then", SPS".picnum", tilenum)
|
||||||
|
addcode(codetab)
|
||||||
|
addcode("end")
|
||||||
|
addcode("end)")
|
||||||
|
|
||||||
|
if (g_code.loadactor[tilenum] ~= nil) then
|
||||||
|
warnprintf("redefined loadactor %d", tilenum)
|
||||||
|
end
|
||||||
|
g_code.loadactor[tilenum] = codetab
|
||||||
|
end
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
local function linecolstr(pos)
|
local function linecolstr(pos)
|
||||||
|
@ -376,7 +397,7 @@ local function pwarnprintf(pos, fmt, ...)
|
||||||
printf("%s %s: warning: "..fmt, g_filename, linecolstr(pos), ...)
|
printf("%s %s: warning: "..fmt, g_filename, linecolstr(pos), ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function warnprintf(fmt, ...)
|
function warnprintf(fmt, ...) -- local
|
||||||
if (g_lastkwpos) then
|
if (g_lastkwpos) then
|
||||||
pwarnprintf(g_lastkwpos, fmt, ...)
|
pwarnprintf(g_lastkwpos, fmt, ...)
|
||||||
else
|
else
|
||||||
|
@ -2351,8 +2372,8 @@ local Cblock = {
|
||||||
-- useractor <actortype> (...)
|
-- useractor <actortype> (...)
|
||||||
useractor = sp1 * tok.define * common.actor_end / on.actor_end,
|
useractor = sp1 * tok.define * common.actor_end / on.actor_end,
|
||||||
-- eventloadactor <name/tilenum>
|
-- eventloadactor <name/tilenum>
|
||||||
eventloadactor = lpeg.Cc(nil) * sp1 * lpeg.Ct(tok.define)
|
eventloadactor = sp1 * tok.define * sp1 * stmt_list_or_eps * "enda"
|
||||||
* sp1 * stmt_list_or_eps * "enda" / on.actor_end,
|
/ on.eventloadactor_end,
|
||||||
|
|
||||||
onevent = sp1 * tok.define * sp1 * stmt_list_or_eps * "endevent"
|
onevent = sp1 * tok.define * sp1 * stmt_list_or_eps * "endevent"
|
||||||
/ on.event_end,
|
/ on.event_end,
|
||||||
|
|
|
@ -14,6 +14,15 @@ onevent EVENT_INIT
|
||||||
echo 127
|
echo 127
|
||||||
endevent
|
endevent
|
||||||
|
|
||||||
|
eventloadactor 930 // "police line" ribbon
|
||||||
|
// make non-destroyable
|
||||||
|
setactor[THISACTOR].hitag 0
|
||||||
|
enda
|
||||||
|
|
||||||
|
eventloadactor 2491 // DUKECAR
|
||||||
|
killit
|
||||||
|
enda
|
||||||
|
|
||||||
// output:
|
// output:
|
||||||
// THIRD
|
// THIRD
|
||||||
// SECOND
|
// SECOND
|
||||||
|
|
Loading…
Reference in a new issue