• 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.

[JASS] Array for local variable

Status
Not open for further replies.
Level 4
Joined
Feb 12, 2007
Messages
99
Hi, i am a new in JASS and i started really for two days and now i have a strange matter with local variable, i used globals variable before for a big trigger bug now i want to reduce these trigger for reduce leaks and my matter is :

JASS:
function Trig_CitizensNumber2_Actions takes nothing returns nothing
    local unit array RandomHouse[8]
    local group array GroupHouse[8]

The probleme is the syntax, event if i writte the code like that he tell that it's wrong ! What's the matter ?
(i searched in other thread but i didn't find my answer...only for global...)
Help me please !
 
Level 10
Joined
Sep 6, 2007
Messages
440
JASS:
function Trig_CitizensNumber2_Actions takes nothing returns nothing
    local unit array RandomHouse
    local group array GroupHouse
    set RandomHouse[0] = RandomHouse[8]
endfunction
Well try this. It might be long but I'm sure someone would answer it. Because when I try to directly attach array, it says they can't be attached directly. I tried this then, see if it works.
 
Level 11
Joined
Feb 18, 2004
Messages
394
...

All arrays in JASS are 8191 indexes long. They are allocated in chunks like Vectors in many languages. (C++ STL for example.) The problem is the [8]. The only reason you would ever define a length on an array is to use vJASS' extended arrays, which only work on global arrays... (and it only matters if you want an array bigger than 8191...)

NoNZealot, set RandomHouse[0] = RandomHouse[8] sets the 0th element to the value of the 8th element... neither of which are set yet....
 
Status
Not open for further replies.
Top