• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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