Help - Search - Members - Calendar
Full Version: for loop iteration
RPG RPG Revolution Forums > Scripting > Script Development and Support
DUFUTA
I have three variables:
X, Y, and Z

They're all three constants.

The first two are also game_variables.

I want to make a couple for loops to iterate from the value of X by increments of Z, and base the stopping point on the number of party members one has. The outcome must be this,

X becomes a variable in game.
all the variables found in the iteration also must become an in game variable.

That done, I want to do the same thing with Y.

Let's say X = 1, Y = 2 and Z = 2 and there were 4 party members.

In that situation, the X-based variables found in the iteration process should be: 1, 3, 5 and 7
In the Y situation, they would be 2, 4, 6 and 8.

Night5h4d3
you cant modify constants, thus them being called constants, but supposing X,Y and Z were variables, then I believe you'd do something like this:

CODE
for i in 0...$game_actors.size
  X_OUTPUT[i] = (Z * i) + X
  Y_OUTPUT[i] = (Z * i) + Y
end


X_OUTPUT[i] and Y_OUTPUT[i] are arrays so you can store each iteration, you could change it to a regular variable if you didn't need the values for all the iterations.
DUFUTA
Thank you, Night! This helped a bunch. When its tested, I may require more assistance.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.