• 🏆 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!

[JASS] Not initiating...

Status
Not open for further replies.
Level 6
Joined
Jun 30, 2006
Messages
230
This is declared in my map header:
JASS:
globals
    integer array udg_ResearchId
    integer array udg_CreepId
    integer array udg_Interval
    real array udg_SpawnX
    real array udg_SpawnY 
    integer udg_CurrentInterval = 0
    force udg_Alliance
    force udg_Horde
    region array udg_Region 
endglobals
function Forces takes nothing returns nothing
    local integer c = 0
    set udg_Alliance = CreateForce()
    set udg_Horde = CreateForce()
    loop
        exitwhen c > 4
        if ( GetPlayerSlotState(Player(c)) == PLAYER_SLOT_STATE_PLAYING ) then
            call ForceAddPlayer( udg_Alliance, Player(c) )
        endif
        if ( GetPlayerSlotState(Player(c + 5)) == PLAYER_SLOT_STATE_PLAYING ) then
            call ForceAddPlayer( udg_Horde, Player(c + 5) )
        endif
        set c = c + 1
    endloop
endfunction

Then I call it with a trigger(with other things as well):
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: call Forces()
      • Custom script: call CreepSpawnPreload()
      • Custom script: call Regions()
But when I start the map, anything that uses udg_Alliance or udg_Horde does not work, and it gives me errors saying that they weren't initialized. I used to not use GUI to init, but I decided anything that can be GUI should be GUI. It's so others can easily read and alter the map with no JASS knowledge. It worked before I recreated it in GUI, but not anymore. I didn't keep the old trigger because this is something so basic, but I'm having problems.

What am I doing wrong?
Note: The Regions() never worked, so I can't tell if it is init, but I know that CreepSpawnPreload() is working.
 
Level 7
Joined
Nov 12, 2005
Messages
299
Are you using NewGen editor? If not then you can't just put globals anywhere - they must be on the top of war3map.j file, a part which you can't edit with the normal editor.
NewGen editor contains JassHelper, a preprocessor that locates and moves all globals blocks to the top. Without it your code will always result in errors.
 
Level 6
Joined
Jun 30, 2006
Messages
230
Of course I have the NewGen editor. Everything works out fine in the editor, it's when I run the game I get the errors.

It worked before I switched it to GUI, but I don't think I did anything else. It's supposed to be a simple function, so I didn't keep a backup.
 
Last edited:
Status
Not open for further replies.
Top