Advanced Variable Help

Mr_Bean355

Member
Reaction score
10
Hello guys,

I am currently designing a map with only GUI (and a few lines of custom script to remove leaks). I also have an AI for my map which I'm busy working on. As part of their item-buying, I have to store the completed recipes they have (as a variable), remove them, buy new items, then create the stored items again.

I have four variable arrays (there are four players) and each array has a size of 6 (6 inventory slots). Currently I have to have four triggers for the AI buying items (1 for each player). It looks something like this:

Trigger 1 (Player 1):
Events
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Create AI_1_Item[(Integer A)] and give it to (entering unit)

Trigger 2 (Player 2):
Events
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Create AI_2_Item[(Integer A)] and give it to (entering unit)

Trigger 3 (Player 3):
Events
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Create AI_3_Item[(Integer A)] and give it to (entering unit)

Trigger 4 (Player 4):
Events
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Create AI_4_Item[(Integer A)] and give it to (entering unit)

The other part of the trigger isn't important. Is there a way to put all these triggers into one (without using "IF")? Just say if I need to explain more...

Thanks,

Mr_Bean
 

Happy

Well-Known Member
Reaction score
71
use integer A and integer B....

so you would make the players integer A 1-4 and then inside it integer B 1-6 for the slots...
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Trigger:
  • Trigger
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Create Item[(Integer B)] and give it to (Entering unit)


He means that. In other words, it's actually looping 24 times. Checking 6 inventory slots for 4 players.
 

Mr_Bean355

Member
Reaction score
10
Trigger:
  • Trigger
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Create Item[(Integer B)] and give it to (Entering unit)


He means that. In other words, it's actually looping 24 times. Checking 6 inventory slots for 4 players.

Thanks! Is the variable "Item" an item-type variable or just item variable?
 

NeuroToxin

New Member
Reaction score
46
On Map Init
Set Item[0] = AI_ItemOne
Set Item[1] = AI_ItemTwo
Etc. Etc. Etc.

And if they're all getting the same item, all you need to do, is copy and paste the AI_ItemOne six times while changing the number.
 

Mr_Bean355

Member
Reaction score
10
On Map Init
Set Item[0] = AI_ItemOne
Set Item[1] = AI_ItemTwo
Etc. Etc. Etc.

And if they're all getting the same item, all you need to do, is copy and paste the AI_ItemOne six times while changing the number.

Okay thanks man. I will see how it works. Thanks for your help guys!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top