• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Set value to variable array - speed question

Status
Not open for further replies.
Level 17
Joined
Nov 13, 2006
Messages
1,814
  • Custom script: call PopulateArray()

JASS:
function PopulateArray takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i >= 250
        set udg_pista[i] = i
        set i = i + 1
    endloop
endfunction

i know to how to do it just was curios if need to bother about speed if i do that kind of fuinction, because i remeber something like storing to variable is fast thing thing but i dont remember this to sure and want use more times that function (what look like ur Populate array but without global variable because then easier to implent)
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
While it is fast, it isn't something I recommend having in a fast periodic timer. Any reason you can't store the data statically? Anyways, if you can't pre-calculate it once, then there is really no better way.

i try avoid the global gui variables and no global jass variable in normal WE and i want use normal we :)

its is for save load thinggy where i must check if i find then itemid in local integer array or unittypeid type in local integer array
 
Level 10
Joined
Jun 6, 2007
Messages
392
You can set the options so that the required globals will be copied automatically with triggers. So globals don't make implementing it more difficult.

In world editor: file>preferences>automatically create unknown variables while pasting trigger data
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
If the array elements are constant then it should be assigned to a global array and generated once before use (either at map initialization or just as it is needed first time).

If the array elements are dynamic then I guess there is no avoiding it 250 array elements alone should not cause a frame drop if done occasionally however if very often then it is possible.
 
Status
Not open for further replies.
Top