Library gives Critical Error

Lightstalker

New Member
Reaction score
55
For some reason, this library gives me a critical error when loading the map:

JASS:
library LibraryGlobals initializer Init

globals
    //DECLARE ARRAY VARIABLES
    unit array HEROSHOP
    unit array HEROSELECT
    unit array HERO
    unit array STATSUNIT
    unit array SKILLSTRAINER
    
    integer array STATSPOINTS
    integer array SKILLPOINTS
    integer array SPAWNRND
    
    string array PLAYERCOLORSTRING
    
    weathereffect array WEATHEREFFECT
    
    //SET NON-ARRAY VARIABLES
    integer HEROCONFIRM = 'A04C'
    integer STATSUP = 'A00N'
    integer STATSDIS = 'A00W'
    integer ARMORY = 'n004'
    integer MARKETPLACE = 'n006'
    integer ARMSCOUNT = 14
    integer TRINKETCOUNT = 12
    integer RNDINT = 0
    
    group TEMPGROUP = null
    
    force INCOMEFORCE = null
    force CPUFORCE = null
    
    rect MAPENTIRE = GetWorldBounds()
    rect MAPPLAYABLE = bj_mapInitialPlayableArea
endglobals

private function Actions takes nothing returns nothing
    //SET SPAWN_RND
    set SPAWNRND[0] = 'h000' //FOOTMAN
    set SPAWNRND[1] = 'n000' //ARCHER
    set SPAWNRND[2] = 'n003' //WIZARD
    set SPAWNRND[3] = 'o000' //CATAPULT
    set SPAWNRND[4] = 'h003' //KNIGHT
    set SPAWNRND[5] = 'h009' //RIFLEMAN
    set SPAWNRND[6] = 'h00A' //WAR MAGE
    set SPAWNRND[7] = 'h008' //MORTAR TEAM
    
    //SET HERO_SHOP
    set HEROSHOP[0] = gg_unit_n01H_0005
    set HEROSHOP[1] = gg_unit_n01I_0004
    set HEROSHOP[2] = gg_unit_n01J_0008
    set HEROSHOP[3] = gg_unit_n01G_0007
    set HEROSHOP[4] = gg_unit_n01E_0006
    set HEROSHOP[5] = gg_unit_n01F_0009
    set HEROSHOP[6] = gg_unit_n005_0001
    set HEROSHOP[7] = gg_unit_n00U_0002
    set HEROSHOP[8] = gg_unit_n00O_0010
    
    // SET WEATHER_EFFECT
    set WEATHEREFFECT[0] = AddWeatherEffect(MAPENTIRE, 'RLhr')
    set WEATHEREFFECT[1] = AddWeatherEffect(MAPENTIRE, 'RLlr')
    set WEATHEREFFECT[2] = AddWeatherEffect(MAPENTIRE, 'FDwh')
    set WEATHEREFFECT[3] = AddWeatherEffect(MAPENTIRE, 'SNhs')
    set WEATHEREFFECT[4] = AddWeatherEffect(MAPENTIRE, 'Snls')
    
    //SET CPU_FORCE
    call ForceAddPlayer(CPUFORCE, Player(5))
    call ForceAddPlayer(CPUFORCE, Player(11))
    
    //SET PLAYER_COLORSTRING
    set PLAYERCOLORSTRING[0] = "|cffff0000"
    set PLAYERCOLORSTRING[1] = "|cff0000ff"
    set PLAYERCOLORSTRING[2] = "|cff18e7bd"
    set PLAYERCOLORSTRING[3] = "|cff520084"
    set PLAYERCOLORSTRING[4] = "|cffffff00"
    set PLAYERCOLORSTRING[5] = "|cfffe8a0e"
    set PLAYERCOLORSTRING[6] = "|cff18be00"
    set PLAYERCOLORSTRING[7] = "|cffe759ad"
    set PLAYERCOLORSTRING[8] = "|cff949694"
    set PLAYERCOLORSTRING[9] = "|cff7bbef7"
    set PLAYERCOLORSTRING[10] = "|cff0F6145"
    set PLAYERCOLORSTRING[11] = "|cff4D2903"
    
    //TO FIX SOON!
    // Setting Ability Variables...
    // Setting Last Kill Variables...
    set udg_LastKill_Bonus[1] = 'A03U'
    set udg_LastKill_Bonus[2] = 'A03V'
    set udg_LastKill_Bonus[3] = 'A03Y'
    set udg_LastKill_Bonus[4] = 'A03W'
    set udg_LastKill_Bonus[5] = 'A03Z'
    set udg_LastKill_Bonus[6] = 'A01B'
    set udg_LastKill_Bonus[7] = 'A01U'
    set udg_LastKill_Bonus[8] = 'A01Y'
    set udg_LastKill_Bonus[9] = 'A03X'
    set udg_LastKill_Bonus[10] = 'A040'
    
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction
endlibrary
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Don't know how to explain, really. Libraries do not require events. Thats why you can call the function they contain in any trigger.

What I think cause it, is the
JASS:

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction


Remove that, keep the rest. In fact, since you do not call the function anywhere, I'd suggest you to use a normal trigger and set "run at map initialization" - Also having a private function is useless since libraries are for custom functions. If you want to call it, do not put private or public.

Only constants need CAPS LETTERS. Remove these caps, it sounds agessive! :p
 

saw792

Is known to say things. That is all.
Reaction score
280
Ignore what Blitz said.
JASS:


Set those two in your actions function, some natives should not be called when setting a global on declaration. Also, bj_mapInitialPlayableArea isn't set until after the initialization functions have run, so this will return null/cause problems from uninitialized variables.
JASS:
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

This has no event, and running it on map initialization does not execute local triggers. Just remove all that and rename the Actions function to Init so it will run on initialization.
 

Zaraf

New Member
Reaction score
22
Here, this should work:

JASS:
library LibraryGlobals initializer Init

        globals
            //DECLARE ARRAY VARIABLES
            unit    array HEROSHOP
            unit    array HEROSELECT
            unit    array HERO
            unit    array STATSUNIT
            unit    array SKILLSTRAINER
            
            integer array STATSPOINTS
            integer array SKILLPOINTS
            integer array SPAWNRND
            integer array LAST_KILL_BONUS
            
            string  array PLAYERCOLORSTRING
            
            weathereffect array WEATHEREFFECT
            
            //SET NON-ARRAY VARIABLES
            integer HEROCONFIRM  = 'A04C'
            integer STATSUP      = 'A00N'
            integer STATSDIS     = 'A00W'
            integer ARMORY       = 'n004'
            integer MARKETPLACE  = 'n006'
            integer ARMSCOUNT    = 14
            integer TRINKETCOUNT = 12
            integer RNDINT       = 0
            
            group TEMPGROUP      = null
            
            force INCOMEFORCE    = null
            force CPUFORCE       = null
            
            rect MAPENTIRE       = null
            rect MAPPLAYABLE     = null
        endglobals

    private function Init takes nothing returns nothing
        
        set MAPENTIRE   = GetWorldBounds()
        set MAPPLAYABLE = bj_mapInitialPlayableArea
        //SET SPAWN_RND
        set SPAWNRND[0] = 'h000' //FOOTMAN
        set SPAWNRND[1] = 'n000' //ARCHER
        set SPAWNRND[2] = 'n003' //WIZARD
        set SPAWNRND[3] = 'o000' //CATAPULT
        set SPAWNRND[4] = 'h003' //KNIGHT
        set SPAWNRND[5] = 'h009' //RIFLEMAN
        set SPAWNRND[6] = 'h00A' //WAR MAGE
        set SPAWNRND[7] = 'h008' //MORTAR TEAM
        
        //SET HERO_SHOP
        set HEROSHOP[0] = gg_unit_n01H_0005
        set HEROSHOP[1] = gg_unit_n01I_0004
        set HEROSHOP[2] = gg_unit_n01J_0008
        set HEROSHOP[3] = gg_unit_n01G_0007
        set HEROSHOP[4] = gg_unit_n01E_0006
        set HEROSHOP[5] = gg_unit_n01F_0009
        set HEROSHOP[6] = gg_unit_n005_0001
        set HEROSHOP[7] = gg_unit_n00U_0002
        set HEROSHOP[8] = gg_unit_n00O_0010
        
        // SET WEATHER_EFFECT
        set WEATHEREFFECT[0] = AddWeatherEffect(MAPENTIRE, 'RLhr')
        set WEATHEREFFECT[1] = AddWeatherEffect(MAPENTIRE, 'RLlr')
        set WEATHEREFFECT[2] = AddWeatherEffect(MAPENTIRE, 'FDwh')
        set WEATHEREFFECT[3] = AddWeatherEffect(MAPENTIRE, 'SNhs')
        set WEATHEREFFECT[4] = AddWeatherEffect(MAPENTIRE, 'Snls')
        
        //SET CPU_FORCE
        call ForceAddPlayer(CPUFORCE, Player(5))
        call ForceAddPlayer(CPUFORCE, Player(11))
        
        //SET PLAYER_COLORSTRING
        set PLAYERCOLORSTRING[0]  = "|cffff0000"
        set PLAYERCOLORSTRING[1]  = "|cff0000ff"
        set PLAYERCOLORSTRING[2]  = "|cff18e7bd"
        set PLAYERCOLORSTRING[3]  = "|cff520084"
        set PLAYERCOLORSTRING[4]  = "|cffffff00"
        set PLAYERCOLORSTRING[5]  = "|cfffe8a0e"
        set PLAYERCOLORSTRING[6]  = "|cff18be00"
        set PLAYERCOLORSTRING[7]  = "|cffe759ad"
        set PLAYERCOLORSTRING[8]  = "|cff949694"
        set PLAYERCOLORSTRING[9]  = "|cff7bbef7"
        set PLAYERCOLORSTRING[10] = "|cff0F6145"
        set PLAYERCOLORSTRING[11] = "|cff4D2903"
        
        //TO FIX SOON!
        // Setting Ability Variables...
        // Setting Last Kill Variables...
        set LAST_KILL_BONUS[1]  = 'A03U'
        set LAST_KILL_BONUS[2]  = 'A03V'
        set LAST_KILL_BONUS[3]  = 'A03Y'
        set LAST_KILL_BONUS[4]  = 'A03W'
        set LAST_KILL_BONUS[5]  = 'A03Z'
        set LAST_KILL_BONUS[6]  = 'A01B'
        set LAST_KILL_BONUS[7]  = 'A01U'
        set LAST_KILL_BONUS[8]  = 'A01Y'
        set LAST_KILL_BONUS[9]  = 'A03X'
        set LAST_KILL_BONUS[10] = 'A040'
        
    endfunction

endlibrary


Instead of having an action function, just have all of the variable setting done in the Init function. Also, instead of using a GUI variable for your Last Kill Bonus, you should make an integer array in your global block and use it. Of course, if you're still using the udg_Last_Kill_Bonus GUI variable in GUI triggers still, then use it, but you should aim to phase out the usage and eventually stick to only vJass globals.
 
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