mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Merge pull request #36 from jessevanherk/master
add assertions to catch incorrect colon-calls to gamestate
This commit is contained in:
commit
526ca620c9
@ -36,6 +36,7 @@ function GS.new(t) return t or {} end -- constructor - deprecated!
|
|||||||
|
|
||||||
function GS.switch(to, ...)
|
function GS.switch(to, ...)
|
||||||
assert(to, "Missing argument: Gamestate to switch to")
|
assert(to, "Missing argument: Gamestate to switch to")
|
||||||
|
assert(to ~= GS, "Can't call switch with colon operator")
|
||||||
local pre = stack[#stack]
|
local pre = stack[#stack]
|
||||||
;(pre.leave or __NULL__)(pre)
|
;(pre.leave or __NULL__)(pre)
|
||||||
;(to.init or __NULL__)(to)
|
;(to.init or __NULL__)(to)
|
||||||
@ -46,6 +47,7 @@ end
|
|||||||
|
|
||||||
function GS.push(to, ...)
|
function GS.push(to, ...)
|
||||||
assert(to, "Missing argument: Gamestate to switch to")
|
assert(to, "Missing argument: Gamestate to switch to")
|
||||||
|
assert(to ~= GS, "Can't call push with colon operator")
|
||||||
local pre = stack[#stack]
|
local pre = stack[#stack]
|
||||||
;(to.init or __NULL__)(to)
|
;(to.init or __NULL__)(to)
|
||||||
to.init = nil
|
to.init = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user