How do I declare array globals :(

Artificial

Without Intelligence
Reaction score
326
First of all, it's integer array, not array integer. Second of all, you can't initialize arrays with values like that. Third of all, even if you could size arrays down (which you can't), sizing it to 1 would be the exact same as using a non-arrayed variable... 4th, arrays can't be constant, as then you can't change their value and they are of no use (since you can't initialize them with a value, as said earlier).
 

Kenny

Back for now.
Reaction score
202
So basically what artifical is saying is it should look something like this:

JASS:
globals
    private integer array SPELL_ID
endglobals


then to use the array, you would set the values in either the initialiser or action function or something, so like this:

JASS:
private function Init takes nothing returns nothing // Your basic InitTrig for a spell
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function Conditions))
    call TriggerAddAction(t,function Actions)
    // then you would do something like this:
    set SPELL_ID[0] = 'A100'
    set SPELL_ID[1] = 'A101'
    // and so on...
endfunction


or you could do it in another function as said before.
 

Vassilev

New Member
Reaction score
39
i guess i should've pasted my full code..

JASS:
scope FieldOfChaos initializer Init

globals
private constant array integer SPELL_ID1[1]  = 'A100'
endglobals

function Init takes nothing returns nothing
local trigger t = CreateTrigger()
endfunction // just leave this for now, havent added events


endscope


Thanks kenny, you were helpful.

Are you SURE its integer array and not the other way round? cuz when i did that i got syntax error....

I thought you could set the variables as you declared them???

like,

local unit u = GetTriggerUnit()
local integer i = 5

??

EDIT: Ok.. its definitely integer array :p
so how about "I thought you could set the variables as you declared them???" ?
 
Reaction score
456
> so how about "I thought you could set the variables as you declared them???" ?
You can't do that for arrays in JASS. Some other languages allow it.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top