Cant Create new triggers

darkbeer

Beer is Good!
Reaction score
84
Hey,
somehow when i create new triggers, they are not working at all in my map, i added some debug messages and found out, that they arent initalized at all. -.- im using NewGen

Anyone knows whats the reason and how to prevent it??
 

darkbeer

Beer is Good!
Reaction score
84
any new trigger i create isnt working, but there are no error messages

examples: trigger 1
JASS:
library ItemSystem
    scope Items

globals
    integer ItemNumberTotal = 3
    integer array ItemID
    integer array ItemAbilityID
    integer array AbilityIndexStart
    integer array AbilityIndexAtt  //Graphic first hand
    integer array AbilityIndexAttSec  //Graphic if its in the sec hand
    string array ItemIcon
    
    // Player - Items Variables
    item array FirstWeapon
    item array SecondWeapon
    integer array FirstWeaponIndex
    integer array SecondWeaponIndex
    integer array EquipStatus
endglobals

public function SetItemVariables takes nothing returns nothing
    //Item Types
    set ItemID[0] = 'I000' //Test Staff
    set ItemID[1] = 'I001' //Test Shield
    set ItemID[2] = 'I002' //Test Sword
    set ItemID[3] = 'I003' //Test Stump
    
    set AbilityIndexStart[0] = 0
    set ItemAbilityID[0] = 'A006' //NOT YET
    set ItemAbilityID[1] = 'A006' //NOT YET
    set ItemAbilityID[2] = 'A006' //NOT YET
    set AbilityIndexStart[1] = 3
endfunction
endlibrary

private function RemoveAbilities takes unit u, integer i, integer id returns nothing
    local integer index = 0
    local integer t = 0
    
    if i == 0 then //disequipp first weapon
        set index = FirstWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    elseif i == 1 then // disequipp second weapon
        set index = SecondWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    elseif i == 2 then // diseqipp all
        set index = SecondWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop

        set index = FirstWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    endif
endfunction
    
private function AddAbilities takes unit u, integer index, integer att returns nothing
    local integer i = AbilityIndexStart[index]
    
    loop
        exitwhen i == AbilityIndexStart[index + 1]
        call UnitAddAbility(u, ItemAbilityID<i>)
        set i = i + 1
    endloop
    
    if att == 1 then
        call UnitAddAbility(u, AbilityIndexAtt[index])
    else
        call UnitAddAbility(u, AbilityIndexAttSec[index])      
    endif
endfunction

private function Equip takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer id = GetPlayerId(GetOwningPlayer(u))
    local item i = GetManipulatedItem()
    local integer t = 0
    local integer Index = 0
    
            call BJDebugMsg(&quot;item&quot;)
    //Get Weapon Index
    loop
        if Index &gt; 100 then
            call BJDebugMsg(&quot;Item Variable not set&quot;)
        endif
        exitwhen GetItemTypeId(i) == ItemID[Index] or Index &gt; 100
        set Index = Index + 1
    endloop
    
    if EquipStatus[id] == 0 then // no weapons yet
        if GetItemType(i) != ITEM_TYPE_PERMANENT then // Item is not shield
            set FirstWeapon[id] = i
            set FirstWeaponIndex[id] = Index
            call AddAbilities(u, Index, 0)
            call BJDebugMsg(I2S(Index))
            if GetItemType(i) != ITEM_TYPE_ARTIFACT then 
                set EquipStatus[id] = 1 // Means one one-hand Weapon
            else
                set EquipStatus[id] = 3 // Means a 2 Hand Weapon
            endif
        else
            set SecondWeapon[id] = i
            set SecondWeaponIndex[id] = Index
            call AddAbilities(u, Index, 1)
            set EquipStatus[id] = 2 // Means only one Shield
        endif
    elseif GetItemType(i) != ITEM_TYPE_ARTIFACT then // Item is 2 Hand Weapon
        if EquipStatus[id] == 0 then
            set FirstWeapon[id] = i
            set FirstWeaponIndex[id] = Index
            call AddAbilities(u, Index, 0)
            call RemoveAbilities(u, 2, id)
            set EquipStatus[id] = 3 // Means one 2hand weapon
        endif
    endif
    
 
    set u = null
    set i = null
        
endfunction

//===========================================================================
public function InitTrig_Equip_Sec takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call BJDebugMsg(&quot;trigger item create&quot;)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM)
    call TriggerAddAction( t, function Equip)
    set t = null
endfunction
endscope

</i>


trigger 2:
JASS:
scope XY
private function Go takes nothing returns nothing
    local string s = SubString(GetEventPlayerChatString(), 4, 10)
    local unit dummy = CreateUnit(Player(0), &#039;hfoo&#039;, 0, 0 ,0)
    
    call BJDebugMsg(&quot;a&quot;)
    call SetUnitTimeScalePercent(dummy, 10)
    call SetUnitAnimation(dummy, s)    
    
    set dummy = null
endfunction

//===========================================================================
public function InitTrig_Animation_Test takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call BJDebugMsg(&quot;ani-&quot;)
    call TriggerRegisterPlayerChatEvent( t, Player(0), &quot;ani-&quot;, false )
    call TriggerAddAction( t, function Go )
    set t = null
endfunction
endscope


The debug messages from the trigger initalizion function arent shown at start -.-
 
Reaction score
456
JASS:
public function InitTrig_Equip_Sec takes nothing returns nothing

Change the Equip_Sec to your triggers name (if it isn't), and remove that public from it.

JASS:
public function InitTrig_Equip_Sec takes nothing returns nothing

Same for this. As now the function's name would be InitTrig_Equip_Sec_<scope/library name>.
 

darkbeer

Beer is Good!
Reaction score
84
Sry, but i dont really get it, the 2nd trigger works now, but the 1st still makes problems :(

JASS:
library ItemSystem
    scope Items

globals
    integer ItemNumberTotal = 3
    integer array ItemID
    integer array ItemAbilityID
    integer array AbilityIndexStart
    integer array AbilityIndexAtt  //Graphic first hand
    integer array AbilityIndexAttSec  //Graphic if its in the sec hand
    string array ItemIcon
    
    // Player - Items Variables
    item array FirstWeapon
    item array SecondWeapon
    integer array FirstWeaponIndex
    integer array SecondWeaponIndex
    integer array EquipStatus
endglobals

public function SetItemVariables takes nothing returns nothing
    //Item Types
    set ItemID[0] = &#039;I000&#039; //Test Staff
    set ItemID[1] = &#039;I001&#039; //Test Shield
    set ItemID[2] = &#039;I002&#039; //Test Sword
    set ItemID[3] = &#039;I003&#039; //Test Stump
    
    set AbilityIndexStart[0] = 0
    set ItemAbilityID[0] = &#039;A006&#039; //NOT YET
    set ItemAbilityID[1] = &#039;A006&#039; //NOT YET
    set ItemAbilityID[2] = &#039;A006&#039; //NOT YET
    set AbilityIndexStart[1] = 3
endfunction
endlibrary

private function RemoveAbilities takes unit u, integer i, integer id returns nothing
    local integer index = 0
    local integer t = 0
    
    if i == 0 then //disequipp first weapon
        set index = FirstWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    elseif i == 1 then // disequipp second weapon
        set index = SecondWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    elseif i == 2 then // diseqipp all
        set index = SecondWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop

        set index = FirstWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    endif
endfunction
    
private function AddAbilities takes unit u, integer index, integer att returns nothing
    local integer i = AbilityIndexStart[index]
    
    loop
        exitwhen i == AbilityIndexStart[index + 1]
        call UnitAddAbility(u, ItemAbilityID<i>)
        set i = i + 1
    endloop
    
    if att == 1 then
        call UnitAddAbility(u, AbilityIndexAtt[index])
    else
        call UnitAddAbility(u, AbilityIndexAttSec[index])      
    endif
endfunction

private function Equip takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer id = GetPlayerId(GetOwningPlayer(u))
    local item i = GetManipulatedItem()
    local integer t = 0
    local integer Index = 0
    
            call BJDebugMsg(&quot;item&quot;)
    //Get Weapon Index
    loop
        if Index &gt; 100 then
            call BJDebugMsg(&quot;Item Variable not set&quot;)
        endif
        exitwhen GetItemTypeId(i) == ItemID[Index] or Index &gt; 100
        set Index = Index + 1
    endloop
    
    if EquipStatus[id] == 0 then // no weapons yet
        if GetItemType(i) != ITEM_TYPE_PERMANENT then // Item is not shield
            set FirstWeapon[id] = i
            set FirstWeaponIndex[id] = Index
            call AddAbilities(u, Index, 0)
            call BJDebugMsg(I2S(Index))
            if GetItemType(i) != ITEM_TYPE_ARTIFACT then 
                set EquipStatus[id] = 1 // Means one one-hand Weapon
            else
                set EquipStatus[id] = 3 // Means a 2 Hand Weapon
            endif
        else
            set SecondWeapon[id] = i
            set SecondWeaponIndex[id] = Index
            call AddAbilities(u, Index, 1)
            set EquipStatus[id] = 2 // Means only one Shield
        endif
    elseif GetItemType(i) != ITEM_TYPE_ARTIFACT then // Item is 2 Hand Weapon
        if EquipStatus[id] == 0 then
            set FirstWeapon[id] = i
            set FirstWeaponIndex[id] = Index
            call AddAbilities(u, Index, 0)
            call RemoveAbilities(u, 2, id)
            set EquipStatus[id] = 3 // Means one 2hand weapon
        endif
    endif
    
 
    set u = null
    set i = null
        
endfunction

//===========================================================================
function Equip_Sec takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call BJDebugMsg(&quot;trigger item create&quot;)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM)
    call TriggerAddAction( t, function Equip)
    set t = null
endfunction
endscope

</i>


tried to change the things as you said, mby im doing something wrong, could you please make an example of the Equip_Sec (original Init_Trig)function?
 
Reaction score
456
JASS:
public function InitTrig_Equip_Sec takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call BJDebugMsg(&quot;trigger item create&quot;)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM)
    call TriggerAddAction( t, function Equip)
    set t = null
endfunction

To:
JASS:
function InitTrig_Equip_Sec takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call BJDebugMsg(&quot;trigger item create&quot;)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM)
    call TriggerAddAction( t, function Equip)
    set t = null
endfunction


If Equip Sec is the trigger's name?
 

darkbeer

Beer is Good!
Reaction score
84
i dont get it -.-, still doesnt work, but now the 2nd trigger doesnt work anymore either -.-

changed the code as you suggested but theres still no message shown -.-

i completely removed the scopes but theres no message, im going to go crazy...

JASS:
library ItemSystem
globals
    integer ItemNumberTotal = 3
    integer array ItemID
    integer array ItemAbilityID
    integer array AbilityIndexStart
    integer array AbilityIndexAtt  //Graphic first hand
    integer array AbilityIndexAttSec  //Graphic if its in the sec hand
    string array ItemIcon
    
    // Player - Items Variables
    item array FirstWeapon
    item array SecondWeapon
    integer array FirstWeaponIndex
    integer array SecondWeaponIndex
    integer array EquipStatus
endglobals

function SetItemVariables takes nothing returns nothing
    //Item Types
    set ItemID[0] = &#039;I000&#039; //Test Staff
    set ItemID[1] = &#039;I001&#039; //Test Shield
    set ItemID[2] = &#039;I002&#039; //Test Sword
    set ItemID[3] = &#039;I003&#039; //Test Stump
    
    set AbilityIndexStart[0] = 0
    set ItemAbilityID[0] = &#039;A006&#039; //NOT YET
    set ItemAbilityID[1] = &#039;A006&#039; //NOT YET
    set ItemAbilityID[2] = &#039;A006&#039; //NOT YET
    set AbilityIndexStart[1] = 3
endfunction
endlibrary

function RemoveAbilities takes unit u, integer i, integer id returns nothing
    local integer index = 0
    local integer t = 0
    
    if i == 0 then //disequipp first weapon
        set index = FirstWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    elseif i == 1 then // disequipp second weapon
        set index = SecondWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    elseif i == 2 then // diseqipp all
        set index = SecondWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop

        set index = FirstWeaponIndex[id]
        set t = AbilityIndexStart[index]
        loop
            exitwhen t == AbilityIndexStart[index + 1]
            call UnitRemoveAbility(u, ItemAbilityID[t])
            set t = t + 1
        endloop
    endif
endfunction
    
function AddAbilities takes unit u, integer index, integer att returns nothing
    local integer i = AbilityIndexStart[index]
    
    loop
        exitwhen i == AbilityIndexStart[index + 1]
        call UnitAddAbility(u, ItemAbilityID<i>)
        set i = i + 1
    endloop
    
    if att == 1 then
        call UnitAddAbility(u, AbilityIndexAtt[index])
    else
        call UnitAddAbility(u, AbilityIndexAttSec[index])      
    endif
endfunction

function Equip takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer id = GetPlayerId(GetOwningPlayer(u))
    local item i = GetManipulatedItem()
    local integer t = 0
    local integer Index = 0
    
            call BJDebugMsg(&quot;item&quot;)
    //Get Weapon Index
    loop
        if Index &gt; 100 then
            call BJDebugMsg(&quot;Item Variable not set&quot;)
        endif
        exitwhen GetItemTypeId(i) == ItemID[Index] or Index &gt; 100
        set Index = Index + 1
    endloop
    
    if EquipStatus[id] == 0 then // no weapons yet
        if GetItemType(i) != ITEM_TYPE_PERMANENT then // Item is not shield
            set FirstWeapon[id] = i
            set FirstWeaponIndex[id] = Index
            call AddAbilities(u, Index, 0)
            call BJDebugMsg(I2S(Index))
            if GetItemType(i) != ITEM_TYPE_ARTIFACT then 
                set EquipStatus[id] = 1 // Means one one-hand Weapon
            else
                set EquipStatus[id] = 3 // Means a 2 Hand Weapon
            endif
        else
            set SecondWeapon[id] = i
            set SecondWeaponIndex[id] = Index
            call AddAbilities(u, Index, 1)
            set EquipStatus[id] = 2 // Means only one Shield
        endif
    elseif GetItemType(i) != ITEM_TYPE_ARTIFACT then // Item is 2 Hand Weapon
        if EquipStatus[id] == 0 then
            set FirstWeapon[id] = i
            set FirstWeaponIndex[id] = Index
            call AddAbilities(u, Index, 0)
            call RemoveAbilities(u, 2, id)
            set EquipStatus[id] = 3 // Means one 2hand weapon
        endif
    endif
    
 
    set u = null
    set i = null
        
endfunction

//===========================================================================
function Init_Trig_Equip_Sec takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call BJDebugMsg(&quot;trigger item create&quot;)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM)
    call TriggerAddAction( t, function Equip)
    set t = null
endfunction

</i>


JASS:
function Go takes nothing returns nothing
    local string s = SubString(GetEventPlayerChatString(), 4, 10)
    local unit dummy = CreateUnit(Player(0), &#039;hfoo&#039;, 0, 0 ,0)
    
    call BJDebugMsg(&quot;a&quot;)
    call SetUnitTimeScalePercent(dummy, 10)
    call SetUnitAnimation(dummy, s)    
    
    set dummy = null
endfunction

//===========================================================================
function Init_Trig_Animation_Test takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call BJDebugMsg(&quot;ani-&quot;)
    call TriggerRegisterPlayerChatEvent( t, Player(0), &quot;ani-&quot;, false )
    call TriggerAddAction( t, function Go )
    set t = null
endfunction


the animation test trigger worked 1 time before, but now it somehow doesnt anymore ...

Note: Equip Sec and Animation Test are trigger names

EDIT: added the map

OMG: Im too stupid, wrote InitTrig wrong, sry to bother you and thanks for your help -.-:banghead:
 
Reaction score
456
For god's sake ;D!

I didn't see the difference now as I've used to libraries initializers xD!
 

darkbeer

Beer is Good!
Reaction score
84
damn -.-
changed it and still got problems, i created a whole new trigger but the message isnt shown ...

the animation trigger works, the equip trigger not, i changed both to be InitTrig..

dont get it, the message of the new created trigger isnt shown as well:

JASS:
function Trig_ghgg_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_ghgg takes nothing returns nothing
    set gg_trg_ghgg = CreateTrigger(  )
    call BJDebugMsg(&quot;new trigger created&quot;)
    call TriggerAddAction( gg_trg_ghgg, function Trig_ghgg_Actions )
endfunction


Note:ghgg is trigger name

EDIT: found the error, had an infinite loop within one of the initalizion functions of another trigger -.-, sorry for bothering you all
 
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