Global Struct Arrays are Illegal?

Hatebreeder

So many apples
Reaction score
381
Sooo, I have started to programm again, and I've run into Problems...

JASS:
    globals
        private UnitData array UserData
    endglobals


So, it gives me "Undefined type UserData. But, shouldn't it be of the typ "UnitData" ? Kinda confused here :x

JASS:
    private struct UnitData
        unit Target
        real Timeout
    
        static method Timer takes nothing returns boolean
            local UnitData this = TT_GetData()
        
            set .Timeout = .Timeout - TT_PERIOD
        
            if .Timeout <= 0 then
                call RemoveStun(.Target)
                    call .destroy()
                        return true
            endif
                return false
        endmethod
    
        static method create takes unit U, real T returns UnitData
            local UnitData this = UnitData.allocate()
        
            set .Target = U
            set .Timeout = T
        
            call AddStun(.Target)
        
            set UserData[GetUnitIndex(.Target)] = this
        
            call TT_Start(function UnitData.Timer,this)
        
                return this
        endmethod
        
    endstruct


And this is what I use it for later on. It's a timed Stun function, that adds up the stun duration instead of replacing the stun duration with a longer one.
 

Bribe

vJass errors are legion
Reaction score
67
Yeah, are they in the same scope? Because you made the struct private, so it's only accessible from within the scope/library.
 
Reaction score
91
Put your global block below your struct or use keyword:

[ljass]private keyword UnitData[/ljass]

[ljass]globals[/ljass]
[ljass] private UnitData array UserData[/ljass]
[ljass]endglobals[/ljass]
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top