Tutorial Triggers - Adding a 'Add Event to Trigger' Action

Dave312

Censored for your safe viewing
Reaction score
269
Adding a 'Add Event to Trigger' Action
By Dave312
v1.0


The aim behind this tutorial is to teach you make use of the hidden native actions that are not available by default for use in GUI triggering. The example I will be demonstrating will be for making an Add Event to Trigger Action.

The first step is to decide which event this action will handle. I will be using the Unit Enters/Leaves Region Event, however these same steps can be applied and used for other events as well as any other native actions not available in the GUI.

Ok so open up your map, and then open up the console (Window -> Console). Type in browse to bring up the Archive Browser (you can type help into the console to bring up a list of available commands). You now need to navigate down to the natives.galaxy file which is located under the TriggerLibs folder.

attachment.php




Now you need to find the action you want to create. This file is split up into various sections which should help you find your action. Mine is of the type Unit so I'll will want to look under the unit section. It is not always easy to find what you want so you may want to try using the find function (crtl+f). I have found my action and it is shown below. Note that all Add Event to Trigger Actions start with TriggerAddEvent.
Code:
native void     TriggerAddEventUnitRegion (trigger t, unitref u, region r, bool state);
What you need to pay attention of here is the name of the action and the parameters specified.

Now open up the Triggers Window (don't close the Archive Browser as you will need to reference it later). Click on the New Action Definition icon on the toolbar (or Ctrl+Alt+R) to add your new action and name it whatever you want. I'm calling mine Add Event Unit Enters Region to Trigger. Now select the name of your trigger in the right-hand pane and uncheck the Based On Name property. You need to change the script identifier to the name of the action in the natives.galaxy file. For me, this becomes TriggerAddEventUnitRegion.

attachment.php




Now you need to modify the Options property and check Native as we are referencing a native action. Leave the rest unchecked. Now here is the tricky bit. For every parameter listed the natives.galaxy file, you need to add a corresponding parameter to your action. You can call the parameters whatever you want but you will need to change the script identifier to the name given in the natives.galaxy file. So for my first parameter, it says trigger t. The first word represents the type (Trigger), and the second word represents the script identifier (t). If your not sure of some of the types, just take a look at the Event you are trying to add and you should be able to work it out. Also note that for my last parameter, it is listed as bool (boolean) with a script identifier of state. If you look at the actual event, the boolean parameter represents the option Enters/Leaves. Because there are only 2 options to choose from (Enters or Leaves), the Region Enter/Leave State is marked as a boolean in the natives.galaxy file. If there were more options, it would be marked as an int (integer). For this reason, I have not chosen to use a type boolean parameter but the preset Region Enter/Leave State.

attachment.php




Finally, if say I wanted to not have to choose a specific unit for the unit parameter of my action, but rather use the preset Any Unit, I can allow this by selecting the parameter, then going to the bottom right-hand corner where it says Allowed Presets. I can then add my desired preset (right-click -> Add Preset...) here.

Now you can test your action to see if it works (the action can be found under the - General section of the action selection window). If it fails for any reason, you may want to check that you have correctly specified the script identifiers as these will prevent the action from working properly.

The now that brings us to the end of this tutorial. If you have any problems, please leave a post below and I'll do what I can to assist you.
 

Attachments

  • SC2Tutorial-AddingEventToTrigger-01.jpg
    SC2Tutorial-AddingEventToTrigger-01.jpg
    243.3 KB · Views: 2,690
  • SC2Tutorial-AddingEventToTrigger-02.jpg
    SC2Tutorial-AddingEventToTrigger-02.jpg
    126 KB · Views: 2,675
  • SC2Tutorial-AddingEventToTrigger-03.jpg
    SC2Tutorial-AddingEventToTrigger-03.jpg
    190.6 KB · Views: 2,590

Romek

Super Moderator
Reaction score
963
...And here I was, thinking that GUI is unrestricted (other than forcing you to click 100 times per minute).

The images are broken.
 

Dave312

Censored for your safe viewing
Reaction score
269
The images should work now.

The GUI isn't really that restricted, they just missed a couple things which can be added manually fairly easily.
 

Viper5030

New Member
Reaction score
0
Great tutorial, except you forgot to check "Use Reference" for the Unit parameter in your own example (since you're looking for an object of type <unitref> instead of <unit>);)
 
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