What im expecting this trigger to do is get set a variable to a random number between 5 and 20 then Run the Actions that many times thus Creating a unit that many times and adding him to a unit group.
Im doing the trigger this way because i dont know how to add multiple units to a unit group with the add unit to unit group action or else id just tell it to create a random amount of units between 5 and 20 then add them all to a unit group.
So either a suggestion as to how to make this work or a suggestion on how to add multiple created units to a unit group would be awesome! Thx for any help in advance!
yeah i actually had the same variable in my code (that was just example code) but for some reason it wasnt working still. im gonna give the For Each Integer idea a try... wish me luck lol
EDIT: i fixed both the Example Code and my real code to the same variable
your 20, needs to the the var let me explain how a for loop works
ariable - Set UnitCreateAmount = (Random integer between 5 and 20)
General - For each integer UnitCreateAmount 1 from 1 to 20 with increment 1, do (Actions)
the var in a for loop is what holds the current number in the loop, so right now your making a random number, then as soon as you put that var in the loop there, your setting it back to 1, you need the End: to ve "unitcreateAmount" and have the first var in the loop be a new var
so Molsterr is it better to go with the For Each Integer in this case?
and my code needs to be UnitCreateAmount1 from 1 to UnitCreateAmount?
no, the first var just holds the loop # for example loopNumber from 1 to unitCreateAmount
on loop 1 loopNumber = 1
on loop 2 loopNumber = 2
...ect that was your problem with your for loop, it would always go 1 to 20, puting that var in the first "var place" just resets it to the current loop number.
Rollback Post to RevisionRollBack
Random Information
Tutorials - Map Development - Galaxy wiki
|Issues? PM me|
Thank you both for your help! Ive got the problem solved! Thanks to you guys and this website im learning more and more every day. without this i be stuck spinning in circles for a lot longer troubleshooting over and over.
What im expecting this trigger to do is get set a variable to a random number between 5 and 20 then Run the Actions that many times thus Creating a unit that many times and adding him to a unit group.
Im doing the trigger this way because i dont know how to add multiple units to a unit group with the add unit to unit group action or else id just tell it to create a random amount of units between 5 and 20 then add them all to a unit group.
So either a suggestion as to how to make this work or a suggestion on how to add multiple created units to a unit group would be awesome! Thx for any help in advance!
@hellzthunder: Go
There are 2 different variables UnitCreateAmount and InitialUnitCreateAmount, make sure the action is using the same variable
You could use For each Integer if this still isnt working, just get rid of the repeat
@Usernameisntworkingright: Go
yeah i actually had the same variable in my code (that was just example code) but for some reason it wasnt working still. im gonna give the For Each Integer idea a try... wish me luck lol
EDIT: i fixed both the Example Code and my real code to the same variable
@hellzthunder: Go
crud. still isnt working? any more suggestions this is frustrating haha.
essentially it only makes random (from my unit vars) 1 unit and adds that unit to the group rather than doing this over and over
@hellzthunder: Go
Make sure the trigger where you set the unit types for variable Unit comes before this trigger
Ive got all my Variables for units already preset in my Global Variables. For example i have 9 different types it picks from and theyre all defined
im just getting for example. 1 probe 1 hydra 1 zergling 1 marine etc
not multiple for some strange reason
By the way you are epic for helpin me out with this :-) your suggestions and comments are both great and helpful
This is what my stuff currently looks like
@hellzthunder: Go wait, For each integer will give you a different type of unit each time, use repeat
use this
@Usernameisntworkingright: Go
For Each Integer
im thinking that might work better
@hellzthunder: Go
oh crap i didnt even think of that. okay going back to repeat
your 20, needs to the the var let me explain how a for loop works
ariable - Set UnitCreateAmount = (Random integer between 5 and 20) General - For each integer UnitCreateAmount 1 from 1 to 20 with increment 1, do (Actions)
the var in a for loop is what holds the current number in the loop, so right now your making a random number, then as soon as you put that var in the loop there, your setting it back to 1, you need the End: to ve "unitcreateAmount" and have the first var in the loop be a new var
@Molsterr: Go
so Molsterr is it better to go with the For Each Integer in this case?
and my code needs to be For Each Integer UnitCreateAmount1 from 1 to UnitCreateAmount?
no, the first var just holds the loop # for example loopNumber from 1 to unitCreateAmount
on loop 1 loopNumber = 1 on loop 2 loopNumber = 2
...ect that was your problem with your for loop, it would always go 1 to 20, puting that var in the first "var place" just resets it to the current loop number.
@Molsterr: Go
Somethings still kinda screwball. If you god the time. id love a code sample :-) of how i can make this work <3
@hellzthunder: Go
EDIT: im curious to how you predefined specific arrays within the variable, i dont know how to do that
@Usernameisntworkingright: Go
dude you nailed it
here let me show yo uhaw i predefined specific arrays gimme a min
The Triggers actions is setting each Var[#] to a game link of a unit
@hellzthunder: Go
oh i knew how to do that i thought you meant in the variable without triggers
If you have multiple triggers with the same Event make sure they are in the proper order or they will not work correctly
@hellzthunder: Go
Thank you both for your help! Ive got the problem solved! Thanks to you guys and this website im learning more and more every day. without this i be stuck spinning in circles for a lot longer troubleshooting over and over.
@Usernameisntworkingright: Go i think theres a way but im not exactly sure how