#Exitting a loop

1 messages · Page 1 of 1 (latest)

cedar arch
#

Basically, I'm looping through a list of train stops to see which train the player is riding.
If their button press matches ANY of the stops, it will run a function to teleport the player to the next stop after the one they're currently at. Here's the code:

            send loop-value to player
            if event-block's location is {train::%loop-value%::button}:
                send "Next stop is %{train::%loop-value%::nextstop}%" to player
                train_tp("%{train::%loop-value%::nextstop}%", event-player, loop-value)

However, I realised that once the list finds the correct stop, it keeps looping the other stops in the list anyway, which is annoying because I reckon this'd cause a glitch in the future.
I tried adding "return" to the end of the loop but it doesn't work, because I have to be returning a function (or something of the like). How do I exit the loop?

#

To be fair, it probably won't cause issues here, but I'd like to know because I also need this info for other things that actually will need to exit loops in the future

north lily