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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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