As the title states, I'm trying to run a loop on the player. I'm testing this simple script to see if it's possible but nothing is being written at the coordinates. Looking through the documentation is unhelpful — any ideas?
on loop do
label "LOOP" at 0,0
end
I figured this out, label only works on the draw event, but question still is do loops work on the player and what's the best way to declare and use them
loop
is an event that only works in event.game
and is called in every frame similar to draw
. Personally, I don't useloop
too much because I don't want to have too many functions on every frame plus draw
lets me use exclusive functions like draw
, label
, hide
and window
but It's pretty useful for running things in the background at all times like playtime.
As @MintFerret notes, loop is called on the game script. I find it useful to move code out of the game script as much as I can though, so I often do something like this:
// in game
on loop do
tell event.player to
call "game_loop"
end
end
// in player
on game_loop do
... whatever ...
end
And the same approach for calling the loop event on the current room (event.room) - if the room or player script doesn't have a game_loop handler, it doesn't matter.
1 Like