Integer

Status
Not open for further replies.
Level 3
Joined
Apr 20, 2009
Messages
26
Hello,

I have a big problem with the integer action.
I do not understand how the integer action works like "Integer A" and what those "1 to 10" numbers are.
If there is a tutorial or if someone kindly could explain this too me I would be very greatful. :)
 
Level 8
Joined
Aug 21, 2009
Messages
333
It's a simple FOR loop.
Basically, you have a variable "Integer A" and whatever actions you put in the loop are going to be performed 10 times. Each time with "Integer A" being a different value.
So it's the equivalent of this:

set "Integer A" to 1
do the actions in the loop
set "Integer A" to 2
do the actions in the loop
set "Integer A" to 3
do the actions in the loop
...
set "Integer A" to 10
do the actions in the loop
 
Level 31
Joined
Apr 17, 2009
Messages
3,572
Well, the Integer A Loop, is a like the name says, a loop,
which means is does the actions in it, many times.

The Integer can for example be used to do some variable setting for every player.
Maybe an integer variable which saves how many gold the player has.

I don't know if you already know arrays.
Well, you can make every variable with an array.
(just tick the box Array when you create a new variable.
So now we create an integer variable named IntCurrentGold.
Because we don't want to make a single variable for every player, we can make the variable with an array.
Means IntCurrentGold[1] is for player 1
IntCurrentGold[2]is for player 2.
And so on.
Note that there exists also Array 0 means IntCurrentGold[0], but we don't need that.

Now we want to set this variable to the current amount of gold the player has.
It would be very time taking and unefficient to set it for every single player, one by one.

Here comes the Integer A Loop in handy.
This loop makes the same action for every number, means every array.

This is the trigger:

  • Setting Gold
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Aktionen
          • Set IntCurrentGold[(Integer A)] = ((Player((Integer A))) Current Amount of Gold)
You can see the thing, the loop does like some kind of rounds.
In the first round it takes the first number defined in the "from 1 - 12"
so it starts by 1.

So it takes 1 and this is now Integer A.
In the actions inside the loop we now just define the array of the integer to Integer A.

So loop has in the first round for Integer A the number 1.
So it sets in the actions IntCurrentGold[1] (the integer variable which saves the current gold of player 1) to the current gold of player 1.

Now the first round of the loop is finished.
The next round starts, but now with the next number -> 2.

So this round it sets for Integer A the number 2
So it sets in the actions IntCurrentGold[2] (the integer variable which saves the current gold of player 2) to the current gold of player 2.

The second round is finished.
The same happens to all other numbers, untill it reaches the maximum you defined in the from 1 to 12.
So the last round takes 12.

Now we have made a trigger which sets for all players a variable, but we don't need 12 lines, so it saves much time and efficiency.


I hope you understood me.
If not, ask more.

chilla_killa
 
Level 3
Joined
Apr 20, 2009
Messages
26
Well, the Integer A Loop, is a like the name says, a loop,
which means is does the actions in it, many times.

The Integer can for example be used to do some variable setting for every player.
Maybe an integer variable which saves how many gold the player has.

I don't know if you already know arrays.
Well, you can make every variable with an array.
(just tick the box Array when you create a new variable.
So now we create an integer variable named IntCurrentGold.
Because we don't want to make a single variable for every player, we can make the variable with an array.
Means IntCurrentGold[1] is for player 1
IntCurrentGold[2]is for player 2.
And so on.
Note that there exists also Array 0 means IntCurrentGold[0], but we don't need that.

Now we want to set this variable to the current amount of gold the player has.
It would be very time taking and unefficient to set it for every single player, one by one.

Here comes the Integer A Loop in handy.
This loop makes the same action for every number, means every array.

This is the trigger:

  • Setting Gold
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Aktionen
          • Set IntCurrentGold[(Integer A)] = ((Player((Integer A))) Current Amount of Gold)
You can see the thing, the loop does like some kind of rounds.
In the first round it takes the first number defined in the "from 1 - 12"
so it starts by 1.

So it takes 1 and this is now Integer A.
In the actions inside the loop we now just define the array of the integer to Integer A.

So loop has in the first round for Integer A the number 1.
So it sets in the actions IntCurrentGold[1] (the integer variable which saves the current gold of player 1) to the current gold of player 1.

Now the first round of the loop is finished.
The next round starts, but now with the next number -> 2.

So this round it sets for Integer A the number 2
So it sets in the actions IntCurrentGold[2] (the integer variable which saves the current gold of player 2) to the current gold of player 2.

The second round is finished.
The same happens to all other numbers, untill it reaches the maximum you defined in the from 1 to 12.
So the last round takes 12.

Now we have made a trigger which sets for all players a variable, but we don't need 12 lines, so it saves much time and efficiency.


I hope you understood me.
If not, ask more.

chilla_killa

Yeah I think I kinda got it. But what if you don't want it to go from 1-12; for example if I want it to take a random number between 1-100 instead of just making it so predictable that it takes the lowest number and then keeps going until it ends.

And another question as well. I understand that if you want to an ability with chance on hit or something like that you have to use integers right? But how advanced is that then?

Thank you for you reply btw!
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
If you want to make it start (or end) at a random number, just modify the starting (or ending) number to the function:

(Random integer between A and B)

Where A is the minimum possible number and B is the maximum possible number.

Similarly, if you want to have a chance to do something just do:

If
((Random integer between 1 and 100) Less Than or Equal To <YourPercentChance>)
Then
...
 
Level 3
Joined
Apr 20, 2009
Messages
26
If you want to make it start (or end) at a random number, just modify the starting (or ending) number to the function:

(Random integer between A and B)

Where A is the minimum possible number and B is the maximum possible number.

Similarly, if you want to have a chance to do something just do:

If
((Random integer between 1 and 100) Less Than or Equal To <YourPercentChance>)
Then
...

Ahh I see, thank you very much! This provided me with ideas!
 
Status
Not open for further replies.
Top