Array Help

YoyoZ

New Member
Reaction score
3
Hey, i have a map in which you can purchase new units. When new units are purchased, when the game starts, it will automatically swarm when the timer hits 0. I have created a timer window for the units which have already been purchased. However, i am trying to do this with arrays.

I can make it so each unit availiable has its own timer window however, i want it so that only purchased units will have a window.

This is what i got so far

For each (Integer A) from 1 to 4, do (Actions)
Loop - Actions
Countdown Timer - Create a timer window for User_Timers[(Integer A)] with title Names[(Integer A)]
Set User_Windows[(Integer A)] = (Last created timer window)
If (Purchased[(Integer A)] Not equal to 1) then do (Countdown Timer - Destroy User_Windows[(Integer A)]) else do (Do nothing)

I am using intergers to tell if the unit has been purchased. 0 = not purchased, 1 = purchased. The last trigger is so that when a unit is not purchased(0) the window for that unit is destoryed.

I don't know why but when i make purchased=1 at map initialization it works, but any other point, it doesn't. e.g.

Purchase Archers
Events
Unit - A unit Finishes research
Conditions
(Triggering player) Equal to Player 1 (Red)
(Researched tech-type) Equal to Purchase Archers
Actions
Set Purchased_Archer = 1

I know this trigger which changes 'Purchased_Archer = 1' works as another trigger is effected by this "Purchased_Archer = 1". A unit spawns or not spawns because of this, e.g.

User Sending Archers
Events
Time - User_Archer_Timer expires
Conditions
Purchased_Archer Equal to 1
Actions
Unit - Create 1 Archer for Player 1 (Red) at (Center of Region 000 <gen>) facing (Center of Region 001 <gen>)


Thanks in Advance
 

Exide

I am amazingly focused right now!
Reaction score
448
You should wrap code or wc3 -tags around your triggers.

In this trigger:
Code:
Purchase Archers
Events
Unit - A unit Finishes research
Conditions
[COLOR="Red"](Triggering player) Equal to Player 1 (Red)[/COLOR]
(Researched tech-type) Equal to Purchase Archers 
Actions
Set Purchased_Archer = 1

the red text is wrong.
You should change it to: '(Owner of (Triggering unit))'.

You should also use Boolean instead of Integer, for checking if it's bought or not.
Boolean True = Purchased
Boolean False = Not Purchased

Your last trigger leaks two points.
 

YoyoZ

New Member
Reaction score
3
but ther trigger works as when i have purchased archer, the archers do come out, so it can't b a problem with that can it? i have also tried adding it to other things e.g. Player types hi, Purchased_Archer = 1 and it still don't work.
I will try change it to the boolean tho. Also, what do you mean by 2 leaks? sorry not too fluent with the jargons:p

Thanks for the quick reply, Rep Added
 

Exide

I am amazingly focused right now!
Reaction score
448
Add a Text Message that is displayed when you upgrade the archers.
-That way you will see if the trigger runs or not.

Leaks = bad. They cause lag and whatnot. More info:
Tutorial
Useful Tool
 

YoyoZ

New Member
Reaction score
3
Yip, the changing of True to False works, the Trigger of destroying the window works, just when you put them together, it doesn't.....
 

YoyoZ

New Member
Reaction score
3
"Actually, i think i figured it out, its the naming of the windows that isn't working,

For each (Integer A) from 1 to 4, do (Actions)
Loop - Actions
Countdown Timer - Create a timer window for User_Timers[(Integer A)] with title Names[(Integer A)]
Set User_Windows[(Integer A)] = (Last created timer window)
If (Purchased[(Integer A)] Equal to False) then do (Countdown Timer - Destroy User_Windows[(Integer A)]) else do (Do nothing)

Do you think so?"

Not the solution, tried it and it don't work

There is something weird because i have already set:
User_Window[1] = User_Footman_Window
User_Window[2] = User_Archer_Window
User_Window[3] = User_Knight_Window

but when i use a single delete trigger

Countdown Timer - Destroy User_Window[1] it works but Countdown Timer - Destroy User_Footman_Window it doesn't. know why??
 

YoyoZ

New Member
Reaction score
3
Is it because 1 thing can not = more than 2? e.g. Footman_window= Window 1 = last created window?
 
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