(RMXP) LOOPING PROBLEM

Posts

Pages: 1
Is there a particular reason why every time I make a loop and it gets to the loop in-game, it freezes?
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Yeah, you have to end the loop! Otherwise, it's like the time when Sailor Saturn used Time Stop, and then realized she forgot to ever learn Time Start.
Well, I'm still confused, slightly: Whats the point of a loop if you have to end it? What good does it do to have one going?
KingArthur
( ̄▽ ̄)ノ De-facto operator of the unofficial RMN IRC channel.
1217
A loop is used to efficiently repeat a set of commands a certain number of times before proceeding.

An example is adding +2 gold to a player's inventory every second for 30 seconds before proceeding with whatever you want to do next. In psuedo-code, it would be something like:
loop
gold +=2 // Add gold.
timer +=1 // Increment our timer.
// If 30 seconds have passed, break out of the loop.
if (timer == 30)
break loop
end
wait (1 second) // Otherwise, wait 1 second before looping again.
end
Well, how does that work for making a fire during a conversation stay lit, but eventually go out at the conversation's end?
KingArthur
( ̄▽ ̄)ノ De-facto operator of the unofficial RMN IRC channel.
1217
loop
fire_animation
if (conversation_fin == true)
break loop
end
end
Obviously, it would be more complex than that but that's the basic concept of a loop: Repeating a set of commands until a certain condition is met.
KingArthur
( ̄▽ ̄)ノ De-facto operator of the unofficial RMN IRC channel.
1217
Let's change this to a real-world scenario then:

1. You are told to wash dishes until you wash 30 dishes in total.
2. You repeat the steps of washing a dish one by one until you reach a total of 30 dishes washed.
3. You finish washing dishes and wait for further instructions.

In psuedo-code, this would be:
loop
clean_dish += 1
if (clean_dish == 30)
break loop
end
end

Was that a bit easier to understand? ;-;
So I don't have to put a conversation in the middle of that loop, then? That's a relief.
A switch would work just as well, judging by his condition's description.

EDIT
And if you ask how to use a switch, I'll hit you.
Pages: 1