How to use static if?

BRUTAL

I'm working
Reaction score
118
When I try to put 'static' in front of certain if conditions, I get a syntax error saying nothing more then "syntax error."
I have no idea why it doesn't work, I've looked at peoples examples so I think I'm not doing anything wrong.
Here is an example code where I get an error.
JASS:
scope test initializer qwe
globals
boolean B=true
endglobals
private function a takes nothing returns nothing
    static if B then
        call BJDebugMsg("true")
    endif
endfunction
private function qwe takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterPlayerChatEvent(t,Player(0),"go",true)
    call TriggerAddAction(t,function a)
endfunction
endscope
 

Romek

Super Moderator
Reaction score
963
> [ljass]boolean B=true[/ljass]
Should be: [ljass]constant boolean B=true[/ljass]

Static if's only work for constant globals, as they're evaluated when the script is compiled. A non-constant variable could change it's value over the course of the game, so a regular if statement would need to be used.
 

BRUTAL

I'm working
Reaction score
118
I just tried putting the constant keyword, I actually should have remember to do so anyways.
Though I still get the error.. and I'm starting to think its something wrong with newgen? But I just downloaded the newest version from the page. T_T
 
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