use _ENV to get rid of level_events and spawns
This commit is contained in:
parent
fbd9f97429
commit
fd391ff3bc
@ -887,7 +887,9 @@ function level_frame()
|
|||||||
else
|
else
|
||||||
while cbs do
|
while cbs do
|
||||||
assert(cbs[1] == distance)
|
assert(cbs[1] == distance)
|
||||||
level_events[cbs[2]](unpack(cbs, 3))
|
local f = _ENV[cbs[2]]
|
||||||
|
assert(type(f) == "function", cbs[2].." at "..distance..." is not a function")
|
||||||
|
f(unpack(cbs, 3))
|
||||||
cbs=cbs.next
|
cbs=cbs.next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1004,17 +1006,9 @@ function spawn_blocking_boss_chasey()
|
|||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
|
|
||||||
spawns = {
|
|
||||||
chasey = chasey,
|
|
||||||
frownie = frownie,
|
|
||||||
blocky = blocky,
|
|
||||||
spewy = spewy,
|
|
||||||
spewy_xl=spewy_xl,
|
|
||||||
-- TODO: populate this
|
|
||||||
}
|
|
||||||
function std_spawn(tnm, n, blocking, goodie,altspr)
|
function std_spawn(tnm, n, blocking, goodie,altspr)
|
||||||
local typ = spawns[tnm]
|
local typ = _ENV[tnm]
|
||||||
assert(typ, tostr(tnm).." not a spawnable")
|
assert(typ and typ.new, tostr(tnm).." not a class")
|
||||||
for i=1,(n or 1) do
|
for i=1,(n or 1) do
|
||||||
spawn_rnd(typ, blocking, goodie,altspr)
|
spawn_rnd(typ, blocking, goodie,altspr)
|
||||||
end
|
end
|
||||||
@ -1047,14 +1041,9 @@ function spawn_goodie(goodie_name, x, y, sz)
|
|||||||
goodies[goodie_name].new{}:spawn_at(x+sh,y+sh)
|
goodies[goodie_name].new{}:spawn_at(x+sh,y+sh)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: populate level_events
|
|
||||||
|
|
||||||
-- to implement: multi(times, interval, f, ...)
|
|
||||||
-- once on this frame, then times-1 times after that spaced interval
|
|
||||||
-- frames apart, f(...). schedule this like the one-off written in
|
|
||||||
-- example_level.
|
|
||||||
function multi(times, interval, fnm, ...)
|
function multi(times, interval, fnm, ...)
|
||||||
local f,irm = level_events[fnm],interval
|
local f,irm = _ENV[fnm],interval
|
||||||
|
assert(type(f) == "function", fnm.." not a function")
|
||||||
fnm(...)
|
fnm(...)
|
||||||
events:push_back{move=function()
|
events:push_back{move=function()
|
||||||
irm-=1
|
irm-=1
|
||||||
|
Loading…
Reference in New Issue
Block a user