• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Condition not functioning correctly

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
library Waypoint initializer Init

    globals
        private unit array ward
        private integer array current 
        private hashtable waypointHash = InitHashtable()
        private integer array currentMenu
        private dialog array main
        private button array bttn
        private integer array cont1
        private integer array cont2
        private integer array cont3
        private integer array cont4
    endglobals
    
    private function onWardInteract_Cond takes nothing returns boolean
        call print("12345")
        return GetUnitTypeId(GetOrderTargetUnit()) == 'H00P' or GetUnitTypeId(GetTriggerUnit()) == 'H00P'
    endfunction
    
    private function onWardInteract takes nothing returns nothing
        local unit ward = GetOrderTargetUnit()
        local unit trig = GetTriggerUnit()
        local integer play = GetPlayerId(GetOwningPlayer(trig)) 
        call print(I2S(play))
        . . .
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i
        call print("wtf")
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
        call TriggerAddAction(t, function onWardInteract)
        call TriggerAddCondition(t, Condition(function onWardInteract_Cond))
        set t = CreateTrigger()
        . . . 
    endfunction
    
endlibrary

When im ordering my unit towards the unit ('H00P'), it prints 12345 but it doesnt print play.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
It would be better to combine the condition and action functions. Try this:

JASS:
library Waypoint initializer onInit
    
    private function Conditions takes nothing returns boolean
        call print("12345")
        
        if (GetUnitTypeId(GetOrderTargetUnit()) == 'H00P' or GetUnitTypeId(GetTriggerUnit()) == 'H00P') then
            call print("play")
        endif
        
        return false
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
        call TriggerAddCondition(t, Condition(function Conditions))
        
        set t = null
    endfunction
    
endlibrary
Does it work?
If not, are you sure the unit has the ID H00P? :p
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
It would be better to combine the condition and action functions. Try this:

JASS:
library Waypoint initializer onInit
    
    private function Conditions takes nothing returns boolean
        call print("12345")
        
        if (GetUnitTypeId(GetOrderTargetUnit()) == 'H00P' or GetUnitTypeId(GetTriggerUnit()) == 'H00P') then
            call print("play")
        endif
        
        return false
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
        call TriggerAddCondition(t, Condition(function Conditions))
        
        set t = null
    endfunction
    
endlibrary
Does it work?
If not, are you sure the unit has the ID H00P? :p

herp de derp it was h00P not H00P
 
Status
Not open for further replies.
Top