Page 2 of 2

Re: Implementing player movement in a Finite State Machine

Posted: Wed Mar 04, 2015 11:19 am
by nfey
Eroica wrote:If I understand you correctly, a system like those should fire an "ACTION" based on which key was pressed, and update the player's state in its methods.
Yup.
Eroica wrote: Which brings me to my other point: Is there any inconvenience in having "key-press logic" both in love.update() and love.keypressed()?
I don't think there's any big inconvenience, as long as you remember you've got key press logic in both places. The theoretical inconvenience is to have a hard time debugging key initiated functionality if there are two entry points to the logic. But it depends a lot on the whats, hows, how muchs and etc. In practice you might not hit any issues at all.
Eroica wrote:I hope I don't sound too confusing with this, perhaps I'm still lacking the "a-ha!" moment before I see all of this clearly.
It's perfectly fine, these are pretty advanced software engineering concepts and it takes a while to wrap one's head around them.

Re: Implementing player movement in a Finite State Machine

Posted: Wed Oct 27, 2021 4:11 pm
by vincolus
Jasoco wrote: Sun Mar 01, 2015 7:39 am This will help even more compactly

Code: Select all

if key == "f1" then
    DEBUG = not DEBUG
end
this made me suffer for many hours, trying to find a reason why lldebugger did not work.
The simple reason was overwriting the lua debug-library with this simple line.
Better call the variable something else...

Re: Implementing player movement in a Finite State Machine

Posted: Wed Oct 27, 2021 8:31 pm
by zorg
vincolus wrote: Wed Oct 27, 2021 4:11 pm
Jasoco wrote: Sun Mar 01, 2015 7:39 am This will help even more compactly

Code: Select all

if key == "f1" then
    DEBUG = not DEBUG
end
this made me suffer for many hours, trying to find a reason why lldebugger did not work.
The simple reason was overwriting the lua debug-library with this simple line.
Better call the variable something else...
Despite necroing the thread, one thing: casing matters; the above code block is probably fine since lua's debug library is called "debug" and not "DEBUG".

Re: Implementing player movement in a Finite State Machine

Posted: Sun Oct 31, 2021 7:39 am
by vincolus
zorg wrote: Wed Oct 27, 2021 8:31 pm
vincolus wrote: Wed Oct 27, 2021 4:11 pm
Jasoco wrote: Sun Mar 01, 2015 7:39 am This will help even more compactly

Code: Select all

if key == "f1" then
    DEBUG = not DEBUG
end
this made me suffer for many hours, trying to find a reason why lldebugger did not work.
The simple reason was overwriting the lua debug-library with this simple line.
Better call the variable something else...
Despite necroing the thread, one thing: casing matters; the above code block is probably fine since lua's debug library is called "debug" and not "DEBUG".
thanks for clarifying. poor me used lowercase :oops: