Structs and Global Variables

SineCosine

I'm still looking for my Tangent
Reaction score
77
Do structs and global variables hate each other or something?

JASS:

scope Error initializer ErrorInit

  globals
    integer ComboNumber = 1
  endglobals

  private struct StructOne
  
    static method Start takes nothing returns nothing
      local StructOne SO = StructOne.allocate()

      //Do stuff..
      call SO.destroy()
    endmethod
    
    method onDestroy takes nothing returns nothing
      set ComboNumber = 2
    endmethod

  endstruct

  private struct StructTwo
  
    static method Start takes nothing returns nothing
      local StructTwo ST = StructTwo.allocate()

      //Do stuff..
      call ST.destroy()
    endmethod
    
    method onDestroy takes nothing returns nothing
      set ComboNumber = 3
    endmethod

  endstruct

  private struct StructThr
  
    static method Start takes nothing returns nothing
      local StructThr STh = StructThr.allocate()

      //Do stuff..
      call STh.destroy()
    endmethod
    
    method onDestroy takes nothing returns nothing
      set ComboNumber = 1
    endmethod

  endstruct

  private function Action takes nothing returns nothing
    
    call BJDebugMsg(I2S(ComboNumber))

    if ComboNumber == 1 then    
      call StructOne.Start()
    elseif ComboNumber == 2 then
      call StructTwo.Start()
    elseif ComboNumber == 3 then
      call StructThr.Start()
    endif

  endfunction

  private function Condition takes nothing returns boolean
    //Return whatever nonsense..
  endfunction

  private function ErrorInit takes nothing returns nothing
    //Something that registers Spell cast..
    call TriggerAddCondition(Stuff inside) //Something about Condition..
    call TriggerAddAction(Trigger, function Action)
  endfunction

endscope


The result of the above is..

1
2
3
1
2
0
0
0
0
0
0
0
0

And Zeros all the way, I don't know why.
 
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