stateful.lua
Re: stateful.lua
Ok sure, this is my bad design. Anyway thanks very much for explanation! stateful is very usefull, but i should have taken it from the very beginning.
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: stateful.lua
Coincidentally, I've been messing with stateful today too. Can I just ask, is there an easy way to access a function from below the current state in the stack?
For example, I have a pause state that is intended to overlay the state below it with a dark rectangle. How can I call the state below's draw function from Pause:draw()? Isn't this sort of the point of having state stacks?
(I'm löving this library, by the way. I've been meaning to start using middleclass for gamestates, and then I found out you had this. )
For example, I have a pause state that is intended to overlay the state below it with a dark rectangle. How can I call the state below's draw function from Pause:draw()? Isn't this sort of the point of having state stacks?
(I'm löving this library, by the way. I've been meaning to start using middleclass for gamestates, and then I found out you had this. )
I LÖVE, therefore I am.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: stateful.lua
First of all, don't go overblow with stacked states: most of the time one state is enough.Puzzlem00n wrote:Coincidentally, I've been messing with stateful today too. Can I just ask, is there an easy way to access a function from below the current state in the stack?
The states are supposed to override the methods "below" them. If you need to "still use the method below" then you should not be overriding the method on the top state.
The solution to your issue is splitting the method in question into two smaller ones - you override one, and leave the other untouched - Is the same discussion I had with Science regarding Game:draw vs Game:baseDraw.
When I write def I mean function.
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: stateful.lua
Hm. Okay. I may have slightly misunderstood the point of stacking. =)
Sorry if you literally just answered my question when talking to Science- I did skim through it, but evidently I couldn't see how it applied.
Thank you!
Sorry if you literally just answered my question when talking to Science- I did skim through it, but evidently I couldn't see how it applied.
Thank you!
I LÖVE, therefore I am.
Re: stateful.lua
- Could you make the library compatible with lurker?
- Could you please add optional state change "restrictions"? Sometimes it is good to make sure the flow goes in a certain way, e.g. going from MainMenu to GameOver state should throw an error or warning. I think it may be possible to implement this by adding a "to" or "from" field and querying these before starting/finishing the state change.
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: stateful.lua
Yeah, I ran into the "compatibility with lurker" problem too. I don't think it's something that'd be easy to do, or fair to ask of Kikito. Commenting out line 85 in stateful makes it sorta work, with some bugs on state stacks. In the end, lurker is only meant for the development of the game, not the end product, so the bugs are excusable.
I LÖVE, therefore I am.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: stateful.lua
Can you give me more information? What did you try, what did you expected to happen, and what did happen instead?enygmata wrote:
- Could you make the library compatible with lurker?
No, sorry, I don't think that's frequent enough to be on the library.enygmata wrote:
- Could you please add optional state change "restrictions"?
When I write def I mean function.
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: stateful.lua
I can give you what I've found. Apparently, when lurker reloads values defined in states, stateful wants to put the reloaded state as a new state on top of the old one. This gives the error you assert in line 85, about putting an already existing state in the stack. Commenting out the line makes it work, obviously, but the two states still exist, which causes problems when you want to pop a state and it still exists underneath.
I LÖVE, therefore I am.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: stateful.lua
Sorry, but I don't understand what "values defined in states" means, and I have never used lurker before. Does any of you guys have a sample *.love file showing the issue?Puzzlem00n wrote:I can give you what I've found. Apparently, when lurker reloads values defined in states, stateful wants to put the reloaded state as a new state on top of the old one.
When I write def I mean function.
Re: stateful.lua
I attached one simple love file for testing purposes. To make the problem happen, open the menu.lua file and save it again. Lurker will reload the file and an assertion error will be thrown:kikito wrote:Does any of you guys have a sample *.love file showing the issue?
State Menu already exists on class Game
- Attachments
-
- stateful-lurker.love
- (10.11 KiB) Downloaded 166 times
Who is online
Users browsing this forum: Ahrefs [Bot] and 6 guests