Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Come and join our gamer community by
registering for free here
Other Gaming Forum
PC games
WarCraft III Modding
Tutorial: Arrays
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Laosh&#039;Ra" data-source="post: 110436" data-attributes="member: 5870"><p><u>For those who want to understand arrays:</u></p><p><strong>how do i create arrays?</strong></p><p>while making a new variable just activate the "array" box and set the number of possible entries.</p><p>to call the different entries you have specify the number of the entry: tinef[1] for the first entry, tinef[2] for the second entry (tinef is the name of the variable).</p><p></p><p><strong>WTF are arrays anyway???</strong></p><p>a common variable has only 1 value. by using arrays its possible to store many values in a single variable. this is useful to create certain dynamic things instead of using copy-paste all the time.</p><p></p><p><strong>HUH?</strong></p><p>heres an example:</p><p>10 spawnpoints are created (regions in this case).</p><p>a variable named "spawnpoints" is created as array with the size 10.</p><p>at the beginning of the map the spawnregions are stored in the array:</p><p></p><p><em>Set spawnpoint[1] = frist_spawn_region <gen></em></p><p><em>Set spawnpoint[2] = second_spawn_region <gen></em></p><p>etc.</p><p></p><p><strong>whatever... now whats the clue with arrays?</strong></p><p>besides the overview, arrays have a nice feature: you can replace the index-number with another variable!</p><p>instead of using this</p><p><em>Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[1]) facing Default building facing (270.0) degrees</em></p><p>u can make it like that</p><p><em>Set randomnumber = (Random integer number between 1 and 10)</em></p><p><em>Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[randomnumber]) facing Default building facing (270.0) degrees</em></p><p>=> 1 unit is spawned in a random spawnpoint</p><p></p><p>of course u could solve this with mass IFs but this wouldnt work anymore if u make a map with 100 possible spawnpoints.</p><p></p><p><strong>any other examples?</strong></p><p>in case u want to spawn 1 unit in each spawnregion u could make a loop reffering to all arrayentries.</p><p><em>For each (Integer A) from 1 to 10, do (Actions)</em></p><p><em>Loop - Actions</em></p><p><em>Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[(Integer A)]) facing Default building facing (270.0) degrees</em></p><p>=> the action unit-create is executed 10 times. the value of integer A changes each time so another spawnpoint is used in each step. YES u could just copy-paste triggers instead. but that wont work if u have 100,000 spawnregions (theres a maximum triggerlength <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />)</p><p></p><p>hf</p></blockquote><p></p>
[QUOTE="Laosh'Ra, post: 110436, member: 5870"] [u]For those who want to understand arrays:[/u] [b]how do i create arrays?[/b] while making a new variable just activate the "array" box and set the number of possible entries. to call the different entries you have specify the number of the entry: tinef[1] for the first entry, tinef[2] for the second entry (tinef is the name of the variable). [b]WTF are arrays anyway???[/b] a common variable has only 1 value. by using arrays its possible to store many values in a single variable. this is useful to create certain dynamic things instead of using copy-paste all the time. [b]HUH?[/b] heres an example: 10 spawnpoints are created (regions in this case). a variable named "spawnpoints" is created as array with the size 10. at the beginning of the map the spawnregions are stored in the array: [i]Set spawnpoint[1] = frist_spawn_region <gen> Set spawnpoint[2] = second_spawn_region <gen>[/i] etc. [b]whatever... now whats the clue with arrays?[/b] besides the overview, arrays have a nice feature: you can replace the index-number with another variable! instead of using this [i]Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[1]) facing Default building facing (270.0) degrees[/i] u can make it like that [i]Set randomnumber = (Random integer number between 1 and 10) Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[randomnumber]) facing Default building facing (270.0) degrees[/i] => 1 unit is spawned in a random spawnpoint of course u could solve this with mass IFs but this wouldnt work anymore if u make a map with 100 possible spawnpoints. [b]any other examples?[/b] in case u want to spawn 1 unit in each spawnregion u could make a loop reffering to all arrayentries. [i]For each (Integer A) from 1 to 10, do (Actions) Loop - Actions Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[(Integer A)]) facing Default building facing (270.0) degrees[/i] => the action unit-create is executed 10 times. the value of integer A changes each time so another spawnpoint is used in each step. YES u could just copy-paste triggers instead. but that wont work if u have 100,000 spawnregions (theres a maximum triggerlength :P) hf [/QUOTE]
Verification
Post reply
Other Gaming Forum
PC games
WarCraft III Modding
Tutorial: Arrays
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top