• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] ( TriggerRegisterTrackableHitEvent )

Status
Not open for further replies.
Level 10
Joined
Dec 15, 2012
Messages
650
Hello,
I made this trigger with JNGP 2.0.X
JASS:
globals
    trackable array T
    trigger Init
    trigger Event
endglobals

function InitFunc takes nothing returns nothing
    local timer = Timer
    local integer i = 1
    local integer x = 1
    local integer y = 1
    loop
        exitwhen i > 250
        if x > 25 then
            set x = 1
            set y = y + 1
        endif
        set x = x + 1
        set T[i] = CreateTrackable("units\\human\\peasant\\peasant.mdx", x, y, 90)
        set i = i + 1
    endloop
    call CameraSetupApplyForPlayer( true, gg_cam_Main_Camera, Player(0), 0.01 )
    call SetTimeOfDay( 8.00 )
endfunction

function InitTrig_Init takes nothing returns nothing
    set Init = CreateTrigger()
    call TriggerRegisterTimerEventSingle( Init, 0.00 )
    call TriggerAddAction( Init, function InitFunc )
endfunction

// Trigger Separation

function Action_Hit takes nothing returns nothing
    call DisplayTextToPlayer(Player(0), 0, 0, "Button Clicked !")
endfunction

function Event_Hit takes nothing returns nothing
    local integer i = 1
    set Event = CreateTrigger()
    loop
        exitwhen i > 250
        call TriggerRegisterTrackableHitEvent(Event, T[i])
        set i = i + 1
    endloop
    call TriggerAddAction(Event, function Action_Hit)
endfunction
So my problem is that am I using the correct event or not ? Why is there nothing happen when I hit(my meaning is "left-click" with mouse) any of the trackables. The event itself wass a problem already or I misunderstood the use of the event ?? Please tell me more about "Trackable". Thank you.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
function Event_Hit must be run AFTER function InitFunc is done working.Because T is always empty when Event_Hit function runs.
 
Level 10
Joined
Dec 15, 2012
Messages
650
I will try that and c wat happen, thanks for helping :)

EDIT :
Great, my problem was solved.
A big thanks to you :thumbs_up:
 

Attachments

  • Button System Screenshot.jpg
    Button System Screenshot.jpg
    201.2 KB · Views: 91
Last edited:
Status
Not open for further replies.
Top