Implementing player movement in a Finite State Machine

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
nfey
Citizen
Posts: 63
Joined: Tue Feb 18, 2014 9:50 am
Location: Romania

Re: Implementing player movement in a Finite State Machine

Post 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.
vincolus
Prole
Posts: 2
Joined: Wed Oct 27, 2021 3:54 pm

Re: Implementing player movement in a Finite State Machine

Post 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...
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Implementing player movement in a Finite State Machine

Post 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".
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
vincolus
Prole
Posts: 2
Joined: Wed Oct 27, 2021 3:54 pm

Re: Implementing player movement in a Finite State Machine

Post 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:
Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests