Noob Question

Dalemil

New Member
Reaction score
2
I started vJASS yesterday and I am having trouble creating a unit array.

This is the code:

JASS:
function Trig_Hero_Actions takes nothing returns nothing

local unit array Hero_Array    
    
set HERO_ARRAY[1] = 'E000'
set HERO_ARRAY[2] = 'E001'


endfunction
 

jig7c

Stop reading me...-statement
Reaction score
123
JASS:
function Trig_Hero_Actions takes nothing returns nothing
 local unit array Hero_Array    
 set Hero_Array[1] = 'E000'
 set Hero_Array[2] = 'E001'
endfunction


Jass is case-sensitive...
you declare Hero_Array, but you use HERO_ARRAY; those are two different things...
 

Komaqtion

You can change this now in User CP.
Reaction score
469
That major problem here isn't that he used capitalized letters where there should've been lower-case ones, but it's that [ljass]'E000' and 'E001'[/ljass] isn't "units", it's just their raw-codes... And they are integers ;)

So you also need to change the array from [ljass]unit[/ljass] to [ljass]integer[/ljass] ;)
 

Rushhour

New Member
Reaction score
46
last but not least: you declared a 'unit' type variable, but you try to store an integer in it (is called 'Unit_Type' in the GUI window, but still an integer). So either you would need to:
JASS:

function Trig_Hero_Actions takes nothing returns nothing

local integer array Hero_Array    
    
set HERO_ARRAY[1] = 'E000'
set HERO_ARRAY[2] = 'E001'


endfunction

//or:

function Trig_Hero_Actions takes nothing returns nothing

local unit array Hero_Array    
    
set HERO_ARRAY[1] = CreateUnit(Player(0),'E000',0.,0.,0.)
set HERO_ARRAY[2] = CreateUnit(Player(0),'E001',0.,0.,0.)
//this would create one unit of each type for Player1 in the middle of the map and store it in the array

endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top