diff --git a/updatedshmup.p8 b/updatedshmup.p8 index 2f7d2e6..ebabd4c 100644 --- a/updatedshmup.p8 +++ b/updatedshmup.p8 @@ -887,7 +887,9 @@ function level_frame() else while cbs do 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 end end @@ -1004,17 +1006,9 @@ function spawn_blocking_boss_chasey() return c 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) - local typ = spawns[tnm] - assert(typ, tostr(tnm).." not a spawnable") + local typ = _ENV[tnm] + assert(typ and typ.new, tostr(tnm).." not a class") for i=1,(n or 1) do spawn_rnd(typ, blocking, goodie,altspr) end @@ -1047,14 +1041,9 @@ function spawn_goodie(goodie_name, x, y, sz) goodies[goodie_name].new{}:spawn_at(x+sh,y+sh) 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, ...) - local f,irm = level_events[fnm],interval + local f,irm = _ENV[fnm],interval + assert(type(f) == "function", fnm.." not a function") fnm(...) events:push_back{move=function() irm-=1