• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[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