mirror of
https://github.com/kikito/middleclass.git
synced 2024-11-08 09:34:22 +00:00
mindstate: fixed error when gotoState(nil)
This commit is contained in:
parent
4ffe20574f
commit
46820474a8
@ -42,11 +42,14 @@ end
|
||||
function StatefulObject:gotoState(stateName)
|
||||
assert(self.states~=nil, "Attribute 'states' not detected. check that you called instance:gotoState and not instance.gotoState, and that you invoked super(self) in the constructor.")
|
||||
|
||||
local nextState = self.states[stateName]
|
||||
assert(type(stateName)=='string' and nextState~=nil, "State '" .. stateName .. "' not found")
|
||||
local nextState
|
||||
if(stateName~=nil) then
|
||||
nextState = self.states[stateName]
|
||||
assert(nextState~=nil, "State '" .. stateName .. "' not found")
|
||||
end
|
||||
|
||||
local prevState = self.currentState
|
||||
if(prevState~=nil and type(prevState.exitState) == "function") then
|
||||
if(prevState~=nil and type(prevState.exitState) == "function") then
|
||||
prevState.exitState(self)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user