Get triggering region

Wratox1

Member
Reaction score
22
i need to get the region which was entered;
Trigger:
  • Unit - A unit enters my region <gen>


i know there is get triggering region, but i dont know if it works with this event...

basically i want to set a region variable to the entered region and then do some stuff..

also, i dont know how to write it in custom script, because i use gui..
 

Ashlebede

New Member
Reaction score
43
http://www.thehelper.net/forums/showthread.php?t=156603, you already asked how to do that.

Accname's way works fine 95% of the time. In the other cases, you'd have to use my method, which does require Jass. However, there is no way to do this without even partially using custom script.

[ljass]GetTriggeringRegion()[/ljass] does work for that event, but cannot be compared to "<gen>" regions (declared using the region palette). To check if triggering region is equal to your region, you'd have to do :

Code:
Custom Script : [ljass]if GetTriggeringRegion()==udg_myHandleTypeVariable then[/ljass]
[COLOR="Green"][I]-------- Whatever goes here --------[/I][/COLOR]
Custom Script : [ljass]endif[/ljass]

[ljass]udg_myHandleTypeVariable[/ljass] would be declared using CTRL+B with the name "myHandleTypeVariable" and its type would be [ljass]handle[/ljass]. If you have an array, then it should be [ljass]udg_myHandleTypeVariable[udg_myIntegerVariable][/ljass].

However, that means you have to register the events in the other 100% Jass trigger, and that's the harder part...

Or just use multiple triggers...

P.S.: Chrome actually is great.
 

Wratox1

Member
Reaction score
22
http://www.thehelper.net/forums/showthread.php?t=156603, you already asked how to do that.

Accname's way works fine 95% of the time. In the other cases, you'd have to use my method, which does require Jass. However, there is no way to do this without even partially using custom script.

[ljass]GetTriggeringRegion()[/ljass] does work for that event, but cannot be compared to "<gen>" regions (declared using the region palette). To check if triggering region is equal to your region, you'd have to do :

Code:
Custom Script : [ljass]if GetTriggeringRegion()==udg_myHandleTypeVariable then[/ljass]
[COLOR="Green"][I]-------- Whatever goes here --------[/I][/COLOR]
Custom Script : [ljass]endif[/ljass]

[ljass]udg_myHandleTypeVariable[/ljass] would be declared using CTRL+B with the name "myHandleTypeVariable" and its type would be [ljass]handle[/ljass]. If you have an array, then it should be [ljass]udg_myHandleTypeVariable[udg_myIntegerVariable][/ljass].

However, that means you have to register the events in the other 100% Jass trigger, and that's the harder part...

Or just use multiple triggers...

P.S.: Chrome actually is great.

i completely forgot about that thread:banghead:, but i am going to things a little different, so i need to know which region was entered, and then set a point variable to the center of the region, and then do some stuff..

will this work?:
Trigger:
  • Custom script: set udg_tmp_region = GetTriggeringRegion()

because this is what i want to do..

P.S.: Yup, i really love Chrome:p
 

Ashlebede

New Member
Reaction score
43
will this work?:
Trigger:
  • Custom script: set udg_tmp_region = GetTriggeringRegion()

because this is what i want to do..

It works, although it is unnecessary. The variable needs to be of type "handle" (== no region-related actions can be used with it without using a special system). If you wish to execute actions on the triggering region, then you'll have to use Jass ; GUI can't manipulate regions at all, only rects.

You could associate a rect (aka <gen> regions) to every region registered through my method by using a hashtable (or [ljass]rect[/ljass] array)... since there is no way to find, say, the center of a [ljass]region[/ljass], although you can find the center of a [ljass]rect[/ljass].

Conclusion: GUI shouldn't have named it "region", since they ain't regions, and that makes it most confusing...

The registering trigger would then become :

JASS:
function InitTrig_MyTrigger takes nothing returns nothing
//function names are important in Jass. Replace MyTrigger with the trigger name (function automatically called @ map init)
    local region r=CreateRegion()

    call PolledWait(.1)//make sure the other trigger&#039;s init was run

    call RegionAddRect(r,gg_rct_My_Regions_Name) //add the rect to the region (doesn&#039;t work with handle-type vars
    call TriggerRegisterEnterRegion(gg_trg_OtherTrigger,r,null) //add an event
    set udg_Regions[0]=r //this handle can only be used for comparison with the region, not as a parameter for functions.
    set udg_Rects[0]=gg_rct_My_Regions_Name

    set r=CreateRegion()
    call RegionAddRect(r,gg_rct_My_Other_Regions_Name)
    call TriggerRegisterEnterRegion(gg_trg_OtherTrigger,r,null)
    set udg_Regions[1]=r
    set udg_Rects[1]=gg_rct_My_Other_Regions_Name

    set r=CreateRegion()
    call RegionAddRect(r,gg_rct_Another_Regions_Name)
    call TriggerRegisterEnterRegion(gg_trg_OtherTrigger,r,null)
    set udg_Regions[2]=r
    set udg_Rects[2]=gg_rct_Another_Regions_Name

    //and so on...

    set r = null //leak clearing
endfunction


And the "main" trigger would become something like this :

Trigger:
  • //Hand-written
    • Events
    • -------- Events added in other trigger --------
    • Conditions
    • Actions
      • For each Integer A from 0 to 2, do (Actions)
        • Loop - Actions
          • Custom Script : if GetTriggeringRegion()==udg_Regions[bj_forLoopAIndex] then
          • Set int = Integer A
          • Custom Script : endif
      • Set loc = Center of Rects[int]


Or something along those lines...

P.S.: I am currently giving you some 100% untested stuff. This will most likely give you syntax errors, forgetful as I am... not to mention I never actually used that method. However, the method itself most likely works.
 

Wratox1

Member
Reaction score
22
so there is no way to do it with only a few custom scripts and gui?
since i dont know Jass i would rather have it in gui..

Trigger:
  • It works, although it is unnecessary.

what do you mean with unnecessary?
 

Ashlebede

New Member
Reaction score
43
If you meant using that variable for actions (such as Center of Region, which is the center of a [ljass]rect[/ljass]), setting a variable to [ljass]GetTriggeringRegion()[/ljass] is unnecessary, since the variable can only have [ljass]handle[/ljass] as a type, since there is no region type in GUI.

If you meant making the condition using GUI, then I fear that is impossible. I am pretty sure GUI can't compare two handles, although you should check first. If it can, then it might be a good idea, since you seem to be a lot more comfortable with GUI.

since i dont know Jass i would rather have it in gui..

The actions, the core of the trigger, will still be in GUI, though. Although it is true that, for someone who doesn't know Jass, the "add events in another trigger" part can be confusing.
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
Why not do it in GUI?

Code:
Initialize Reigon
    Events
        Map initialization
    Conditions
    Actions
        Set region[1] = 1 <gen>
        Set region[2] = 2 <gen>
        Set regioncounter = 2
        For each (Integer A) from 1 to regioncounter, do (Actions)
            Loop - Actions
                Trigger - Add to EnteredRegion <gen> the event (Unit - A unit enters region[(Integer A)])

Code:
EnteredRegion
    Events
    Conditions
        (Unit-type of (Triggering unit)) Equal to Knight
    Actions
        Wait 0.01 seconds
        Set regionEntered = 0
        For each (Integer A) from 1 to regioncounter, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (region[(Integer A)] contains (Triggering unit)) Equal to True
                    Then - Actions
                        Set regionEntered = (Integer A)
                    Else - Actions
        Set p = (Center of region[regionEntered])
        Unit - Create 1 Blood Mage for (Owner of (Triggering unit)) at p facing Default building facing degrees
        Custom script:   call RemoveLocation(udg_p)

>>P.S.: Chrome actually is great.
Flock's better.
 

Ashlebede

New Member
Reaction score
43
Why not do it in GUI?

Because you can't compare a [ljass]rect[/ljass] with a [ljass]region[/ljass], and [ljass]GetTriggeringRegion()[/ljass] returns a [ljass]region[/ljass], whereas <gen> region's are in fact [ljass]rect[/ljass]s. And if you just wanted to create a unit in the middle of the region, you'd have to find the [ljass]rect[/ljass] associated to it, since there is no [ljass]GetRegionCenterLoc()[/ljass] function.

Accname already proposed your solution in the other thread. However, it cannot work all the time (what if there is a region inside another one, for instance? Or if they simply overlap?) and sometimes has to be more accurate. After all, that is the point of this thread. Your solution does work most of the time, though.
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
>>it cannot work all the time
It can work all the time, in any cases, even with dynamically created regions (regions created at run-time), in GUI, yes.

>>what if there is a region inside another one
Would not be a problem, but thread-starter does not imply he needs that.

>>sometimes has to be more accurate
More accurate than what? Finding which region he entered? Can it get more accurate than that?
 

Ashlebede

New Member
Reaction score
43
A region inside another region, a region overlapping another one. Think about it two minutes. It would only pick the last one from the array... that would mean either random results or rather complex "priority" array arrangement.

Also using a wait would mean having a certain delay between the moment when the region is entered and the moment when the effect is triggered. The wait should range somewhere between .1 & .3 seconds.

thread-starter does not imply he needs that.

Fine, then. But didn't he say he wanted to get the triggering region? He didn't say he wanted to know if the triggering unit was in a certain region after a certain time.

On-topic: There is most likely a reason why he didn't take Accname's solution in the other thread. Whatever the reason, it either means he didn't try it or his solution doesn't work...

More accurate than what?

More accurate than checking if the unit is inside the region instead of litterally checking which region was entered. Again, overlapping regions. A simple mistake in the array's organization could make it disfunction.

P.S.: Wratox1 said in his other thread that region overlapping is not a problem.
 

Wratox1

Member
Reaction score
22
since im too lazy and stubborn to not learn Jass, im going to create 1 trigger fo each region..

but thanks fo the help anyway!

P.S.: Wratox1 said in his other thread that region overlapping is not a problem.

this is still true;)
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
>>It would only pick the last one from the array
I never said the trigger I gave worked with overlapping regions, I said if regions were overlapping, there would not be a problem whatsoever in creating a 100% workable trigger, in GUI. You just carefully add the regions to the array, and with a loop more and a check here and there..., it is covered.

>>But didn't he say he wanted to get the triggering region?
He does have the triggering region:
region[regionEntered] == The region that a unit entered.

>>P.S.: Wratox1 said in his other thread that region overlapping is not a problem.
Yes, I know, hence the trigger I gave works, but then again... "in his other thread", two threads means two different questions/problems, if you use threads properly..., totally, awesome.

>>Again, overlapping regions.
Again, it is not a problem in GUI.

>>since im too lazy and stubborn to not learn Jass
Doubt you'll need JASS.

>>im going to create 1 trigger fo each region..
Show us the trigger you are creating for one region, and maybe someone here would be kind enough creating a trigger that works for all of your regions, in GUI, imagine that?...
 

vypur85

Hibernate
Reaction score
803
Have to disagree with you ManyTimes. GUI version of region detection isn't that good. Not sure how the Jass one works, though, so I can't compare both.

When it comes to sliding effect (or the like) detection via GUI isn't that much sensitive. It can miss, besides there's a wait there. If the unit move fast enough in and out of region, detection might not be there as well. Then again, the GUI trigger posted is probably the best you can get so far, in terms of GUI per se.
 

Ashlebede

New Member
Reaction score
43
If you're going to make a single trigger for every region, I suggest this computer-hungry method:

Trigger:
  • //Hand-written : Region Actions
    • Events
    • Conditions
    • Actions
      • Set loc=Center of (RegionVar)
      • Unit - Create [...] at loc
      • Custom Script : call RemoveLocation(udg_loc)


Trigger:
  • //Hand-written : Region Events 01
    • Events
      • Unit - A unit enters My Region &lt;gen&gt;
    • Conditions
    • Actions
      • Set RegionVar = My Region &lt;gen&gt;
      • Trigger - Run Region Actions &lt;gen&gt; Ignoring conditions


Trigger:
  • //Hand-written : Region Events 02
    • Events
      • Unit - A unit enters Other Region &lt;gen&gt;
    • Conditions
    • Actions
      • Set RegionVar = Other Region &lt;gen&gt;
      • Trigger - Run Region Actions &lt;gen&gt; Ignoring conditions


That way you only have to write the actions once.

Not sure how the Jass one works, though

Indeed, it is rather complex for a simple triggering element detection. The problem is that "[ljass]region!=rect[/ljass]" and you have to associate a rect to every region manually, since you can't find the center of a [ljass]region[/ljass] ; only the center of a [ljass]rect[/ljass]. So, basically :

[ljass]rect[/ljass] = actions & manipulation, area delimitation.
[ljass]region[/ljass] = event detection, finding triggering element.

To get the "best of both worlds", you have to associate a rect with its corresponding region.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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