Main Menu
  • Welcome to The RPG Maker Resource Kit.

Loops and conditional branches

Started by Caesis, May 31, 2008, 09:21:47 PM

0 Members and 1 Guest are viewing this topic.

Caesis

Okay ... I'm thinking out a common event. The first part would look like this.

Loop
  Timer (x numbers and y seconds)
       conditional branch
          If timer past x miniutes and y seconds then
           stop timer
Break loop

-----------------------------------
I make another loop below it.

loop
  Conditional branch
      If timer less than x
         This thing happens
         else
              conditional branch
                   if timer is less than x
                    This thing happens
                      else
                          conditional branch
                             if timer is less than x
                                 This thing happens.
                               else

Etc etc etc

                                               Conditional branch
                                                 if timer is less than x 
                                                     this thing happens
                                                         else
break loop
---------------------
Now, Eventually, the conditional branch runs out of time from the timer. Obviously. After it does, will it go back to the first conditional branch in the loop?

And will the timer from another loop auctually interact from a timer from another loop? If its in the same common event? And did I even use the timer right?

Thanks alot
- Caesis

Sabre_of_Pain

can't say i know. but if the "This thing happens" part is the same for each of them why not just have one that loops itself?
"screaming out the mating call. i've become the lord of love"

caramelldansen forever!

Caesis

That plan didn't work great ...

Okay, anyone know this now:

Theres a timer in a loop.

Theres another loop or conditional branch.
Can the timer affect the events in the conditional branch and loop?

Thanks
- Caesis

Kularian

I don't see why it wouldn't.  The timer is a global thing.  It should affect any events that would refer to it, no matter where they are located.

Because we'll say you have loop A and loop B, which is what you're asking about.  Loop A will call the timer, which makes it start, and shows the time on the screen, counting down.  If you're setting it up like you have in that loop down there, however, you may want to do something more like...

Timer (x numbers and y seconds)   
   Loop
       conditional branch
          If timer past x miniutes and y seconds then
           stop timer
   Break loop

Because otherwise each instance of the loop will reset your timer to whatever you placed it at.  Anyway, continuing on. 

...hm.  I think your eventing could be changed a bit, otherwise this is going to be caught in the loop until the end of the timer is reached, and none of your other events will happen.  Something more like this would be more effective, I think...

(Step 1)
Plot event starts the Timer.

(Step 2)
Set a Common Event with a parallel process that has your

       conditional branch
          If timer past x miniutes and y seconds then
           stop timer

Which will do exactly what you wanted up there, only it won't be trapped in limbo forever.  However, if you plan on using more than one timer in your game (as in, another event involving a timer in the future), this will need to be edited slightly, as /all/ timers will stop at that time.

(Step 3)

Setup another Common Event with parallel process.  Again, if you're planning to use multiple timers throughout your game, you're going to want to set up another condition, such as a switch.  Here is where you'll have your conditional branches, just how you had them before.  So something like...

loop
  Conditional branch
      If timer less than 5
         This thing happens
         else
              conditional branch
                   if timer is less than 10
                    This thing happens
                      else
                          conditional branch
                             if timer is less than 20
                                 This thing happens.
                               else

And so on building upwards, otherwise it'll just run the first condition once and that'll be all. 

Whew, that was a little longer than I thought, ^_^;  I hope that's clear, but if not, either reply again, shoot me a PM or hit me up on one of my messengers. 

Kularian