You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using this wonderful component, thank you for sharing.
I have a problem. Let's say, I have a state A. push A named A1 (self.name is set to A1 when enteredState), push A named A2, do pop I should get back to state A named A1, but actually It's still A2.
Could you please give me some help?
localclass=require'middleclass'localStateful=require'stateful'localEnemy=class('Enemy')
Enemy:include(Stateful)
functionEnemy:speak()
endlocalA=Enemy:addState('A')
-- overriden functionfunctionA:enteredState(name)
self.name=nameprint( 'enteredState ' ..name )
endfunctionA:speak()
print( 'I am ' ..self.name )
endlocalpeter=Enemy:new()
peter:pushState('A', 'A1') -- enteredState A1peter:speak() -- I am A1peter:pushState('A', 'A2') -- enteredState A2peter:speak() -- I am A2peter:popState()
peter:speak() -- I am A2, expect 'I am A1'
The text was updated successfully, but these errors were encountered:
Hi, I am using this wonderful component, thank you for sharing.
I have a problem. Let's say, I have a state A. push A named A1 (self.name is set to A1 when enteredState), push A named A2, do pop I should get back to state A named A1, but actually It's still A2.
Could you please give me some help?
The text was updated successfully, but these errors were encountered: