• 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.

[vJASS] Please advise a simple script for TriggerRegisterEnterRegion & TimerDialog

Status
Not open for further replies.
Level 6
Joined
Jun 19, 2010
Messages
143
Hi,
I use this for Add region and checking unit enters a region. But not sure about it and how's about adding many rects, like RegionAddRect(r,r1), then (r,r2), (r,r3), Or even reuse set new r1 and add to region r instead of creating few more local rects.
JASS:
 function X2 takes nothing returns nothing
        local trigger t=CreateTrigger()
        local region r=CreateRegion()
        local rect r1=Rect(-3350,-1180,-3300,-250)
        call RegionAddRect(r,r1)
        call TriggerRegisterEnterRegion(t,r,null)
        call TriggerAddCondition(t,Condition(function X2Con))        
        call RemoveRegion(r)
        set r=null
        set r1=null
        set t=null
    endfunction
I also use this for TimerDialog. I can't get my map work so I still dout about its working. Please advise me on them and advise of some simple scripts for these issues. The script below is cited from a scope in my map
JASS:
globals
        private constant string TIMERSTRING="|c00ffff80Challenge Time"
        private timer         T             = CreateTimer()
        private timerdialog   T_WINDOW      
        private real          INTERVAL      = 50.
        private trigger tr
        endglobals
JASS:
set T_WINDOW=CreateTimerDialog(T)
            call TimerDialogSetTitle(T_WINDOW,TIMERSTRING)
            call TimerDialogDisplay(T_WINDOW,true)
            call TimerStart(T,INTERVAL,false,null)
And this one is to checking the Timer T if it expires as TimerExpire in GUI, I assumed it would work. tr is the trigger creates the TimerDialog.
call TriggerRegisterTimerExpireEvent(tr,T)

Thank you
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The function X2 is not going to work, because you delete the region, so the event will never fire.
However if you don't need the rect anymore later, after adding it to the region you can destroy it.
Rects are added in a region "by value", not "by reference", if you change/destroy them later, it won't affect the event.
However you can add/remove rect/cells to the region, it will affect the event.

For timer dialogs, try it in GUI and convert to jass, to guess what's wrong/missing.
Also, i suppose that timer dialogs can't be displayed (or maybe even created) on map init like leader/multi/boards.
 
Last edited:
Level 6
Joined
Jun 19, 2010
Messages
143
Thank you for your replies
So, call RemoveRegion(r) should be moved to action function?
What are the actions of tr?
I am still in a puzzle because I don't get the whole system (scripts+libs) work, or maybe I just copy 1 script like this one below to a blank map to test. The X5 function is triggered when unit enters a region, so timerdialog is created in its condition function. The EndX5 is supposed to destroy timerdialog T_WINDOW and cease everything when the INTERVAL of timer T expires. Please have a look on the script below and advise me.

JASS:
scope x5
    globals
        private constant string TIMERSTRING="|c00ffff80Challenge Time"
        private timer         T             = CreateTimer()
        private timerdialog   T_WINDOW      
        private real          INTERVAL      = 50.
        private constant integer FIRELORD='Nalc'
        private group grp=CreateGroup()
        private trigger t
        private trigger tr
        private trigger bf
     endglobals
    function X5Con takes nothing returns boolean
        local real x=-5600
        local real y=2455
        local real z  
        local effect fx
        if GetUnitTypeId(GetEnteringUnit())==PEONID and IsTriggerEnabled(GetTriggeringTrigger())
            call EnableTrigger(tr)
            set T_WINDOW=CreateTimerDialog(T)
            call TimerDialogSetTitle(T_WINDOW,TIMERSTRING)
            call TimerDialogDisplay(T_WINDOW,true)
            call TimerStart(T,INTERVAL,false,null)
            call DisableTrigger(GetTriggeringTrigger())
        endif
        return false
    endfunction
function X5 takes nothing returns nothing
        local region r=CreateRegion()
        local rect r1=Rect(-5620,2380,-4880,2500)
        set t=CreateTrigger()
        call RegionAddRect(r,r1)
        call TriggerRegisterEnterRegion(t,r,null)
        call TriggerAddCondition(t,Condition(function X5Con))    
        call RemoveRegion(r)
        set r=null
        set r1=null
    endfunction
    function EndX5Con takes nothing returns boolean
        local unit FoG=null 
        if IsTriggerEnabled(tr)==true then
            call DestroyTimerDialog(T_WINDOW)
            call DisableTrigger(bf)
            set bf=null
            call GroupEnumUnitsInRect(grp,bj_mapInitialPlayableArea,null)
            loop
                set FoG=FirstOfGroup(grp)
                exitwhen FoG==null
                if GetUnitTypeId(FoG)==FIRELORD then
                    call KillUnit(FoG)
                endif
                    call GroupRemoveUnit(grp,FoG)
            endloop      
            call ModifyGateBJ(bj_GATEOPERATION_OPEN,gg_dest_ATg1_0015)
            call DisableTrigger(t) 
            call DisableTrigger(GetTriggeringTrigger()) 
        endif
    return false
    endfunction
    function EndX5 takes nothing returns nothing
        local trigger tr= CreateTrigger()        
        call TriggerRegisterTimerExpireEvent(tr,T)
        call TriggerAddCondition(tr,Condition(function EndX5Con))
        set t=null
        set tr=null        
    endfunction
endscope
 
Last edited:
Status
Not open for further replies.
Top