• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[JASS] Static if in globals?

Status
Not open for further replies.
Level 11
Joined
Apr 6, 2008
Messages
760
Is it possible to get like a static if in globals?

eg.

JASS:
private
{
    static if(LIBRARY_Table)
    {
         HandleTable Table;
    }
}

This dont work but i want something like this, if the library exists i want it too add a global.

need this since im gonna make a system optional for a spell, and that system needs a globals in the spell :/
 
You could do something like this;

JASS:
scope someshit initializer onInit

    globals
        private hashtable Table
    endglobals
    
    private function onInit takes nothing returns nothing
        static if LIBRARY_Table then
            set Table = InitHashtable()
        endif
    endfunction
    
endscope

Maybe even add a boolean whether or not the table was initialized so you can check in other triggers.

Also, the optional keyword exists.
 
Level 11
Joined
Apr 6, 2008
Messages
760
yes but

JASS:
library Lib initializer init requiers optional Table

globals
    private HandleTable Table //this will give an error
englobals

private function init takes nothing returns nothing
    static if (LIBRARY_Table) then
        set Table = HandleTable.create()
    endif
endfunction

endlibrary

that wont work with out the table library

Edit:

wonder if it work with a keyword?

Edit2: but well i could be made with a hashtables aswell
 
Status
Not open for further replies.
Top