Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> for loop iteration
DUFUTA
post Jul 19 2011, 10:46 AM
Post #1


Level 5
Group Icon

Group: Member
Posts: 60
Type: Musician
RM Skill: Intermediate




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.

Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 19 2011, 11:23 AM
Post #2


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




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.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
DUFUTA
post Jul 20 2011, 06:45 AM
Post #3


Level 5
Group Icon

Group: Member
Posts: 60
Type: Musician
RM Skill: Intermediate




Thank you, Night! This helped a bunch. When its tested, I may require more assistance.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 02:48 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker