Oh okay, I think I found the issue. The Libram is being created before the unit is being indexed, so it ends up assigning it to the ID of 0 on creation, but once the unit is indexed, it'll try looking up the Libram at ID 4 (the unit's index). All that you need to do is make Init2() called on the game's start, rather than map initialization. Like this:
scope Test initializer Init
globals
unit hero
Libram A
LibramPage array Pages
endglobals
private function esc takes nothing returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,12,"Use UP or DOWN key to switch the Spell Pack")
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,12,"Press ESC to refresh health, mana, cooldowns, and to display this text again.")
call SetWidgetLife(hero,GetUnitState(hero,UNIT_STATE_MAX_LIFE))
call SetUnitState(hero,UNIT_STATE_LIFE,GetUnitState(hero,UNIT_STATE_MAX_LIFE))
call UnitResetCooldown(hero)
endfunction
private function PreloadAbils takes nothing returns nothing
// This is just for preloading the abilities, it is not necessary
// However, I do recommend it in general
// Spell Tester
call AbilityPreload('A008')
call AbilityPreload('A001')
call AbilityPreload('A006')
//call AbilityPreload('')
// Life Witch
//call AbilityPreload('AHfs')
//call AbilityPreload('AHbn')
//call AbilityPreload('AHdr')
call AbilityPreload('A009')
// Shadow Assassin
call AbilityPreload('A00G')
call AbilityPreload('A00H')
call AbilityPreload('A00F')
call AbilityPreload('A00I')
endfunction
private function Init2 takes nothing returns nothing
set A = Libram.create(hero) // Make Libram for the hero
set Pages[0] = A.first
set Pages[1] = A.createPage() // Pages
set Pages[2] = A.createPage()
// Spell Tester
call A.addAbility(Pages[0],'A008') // Gather
call A.addAbility(Pages[0],'A001') // Body Replacement
call A.addAbility(Pages[0],'A006') // Impulse
//call A.addAbility(Pages[0],'') // Speller
// Life Witch
//call A.addAbility(Pages[1],'AHfs') // Lost
//call A.addAbility(Pages[1],'AHbn') // Extraction
//call A.addAbility(Pages[1],'AHdr') // Soul Burst
call A.addAbility(Pages[1],'A009') // Restart
// Shadow Assassin
call A.addAbility(Pages[2],'A00G') // Needle Of Death
call A.addAbility(Pages[2],'A00H') // Shadow Leap
call A.addPassive(Pages[2],'A00F','A00P') // Hide In Darkness
call A.addAbility(Pages[2],'A00I') // Sight Of Assassin
call A.refresh() // Refresh, just in case so that all of the abilities will work correctly
call DestroyTimer(GetExpiredTimer()) // clear leak
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
set hero = gg_unit_H000_0000
if GetLocalPlayer()==Player(0) then
call SetCameraTargetController(hero,0,0,false)
endif
call TriggerRegisterPlayerEvent(t,Player(0),EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction(t,function esc)
call TriggerExecute(t)
call TimerStart(CreateTimer(), 0, false, function Init2) // start a 0-sec timer
endfunction
endscope
If that doesn't work, let me know. Also, delete the AIDS trigger if you are using Bribe's indexer already. Otherwise, that might cause additional problems.