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,672
  • 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:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • 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 Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top