Trigger event (var+1)?

katana

  • Posts: 128
Basically, I've got a bunch of custom events called Click1, Click2 etc. That activate on click. Instead of having the game check if click ==1, click ==2 etc. and trigger an event accordingly, I'd like to just be able to trigger an event based on a string. If I try to say trigger event [var + 1] (Yes, the text adding, not the numbers adding), no event is actually triggered. What would I do to be able to trigger an event based on variable values?
One of the two expert stencylers to have done precisely nothing to earn their title... Oh damn, he did something and got promoted. I need to get to work. Until then, I'm unique?
<Katana>: Blob: back me up :c
<Stevetheipad>: what's the "move pen to" block?
<Blob>: irock you are wrong
<Blob>: it's 2 against 1 we live in a democracy

rob1221

  • *
  • Posts: 9421
If you look at the code preview you'll see that what you input into the trigger event block is code, not a string.  So when you try to input a string with the text block, it doesn't work.  You should probably use custom blocks instead.

Sunflower

  • Posts: 591
Generally, there are three types of trigger blocks:
trigger event [something] for behavior [somebehav] in actor/scene
trigger event [something] for all behaviors in actor/scene
trigger event [something]

The first one of course requires specific behavior, and probably has slightly better performance (since you trigger it for only one behavior, rather than trying to do that for every single behavior), though compared to other parts it's often negligible. However, sometimes you have same-named events in other behaviors, or you just want to know what behaviors it refers to even after looking at the logic after a few months, so that's where it would be more practical.

The second one can be generally used when someone is lazy, though I actually find it pretty useful and often use it for cases where it's not assumed what this trigger will apply to; for example, in some system from long time ago I made the system where adding new commands for dialogues would be flexible thanks to such triggers; if dialogue encountered e.g. "Wait()", event called "Wait" would be triggered for all behaviors, many of which would be containers for such commands.
But yes, generally it's pretty useful when you don't really want to remind yourself how that behavior was called, or when you need flexibility.

Both of the above can accept text arguments! Generally, there's probably some index of events somewhere in memory where they can be found by their names, and the two block above take such name as argument, whether it would be "MyEvent", ["Click" + [value]] or [MyEventAttribute].
The third block, however, accepts only input typed by hand! It provides a "quick" way to refer to that event, where it's not "some variable text name you search for", but rather a fixed function call. The difference between the earlier two and this one can be seen in code preview; the first two will have parameter as a text argument, the third one will have it typed as TEH FREAKIN LIVING CODE!!1!1

So yes, if you want to input text variable (which is the case with "Click" + [number], definitely!), rather than a fixed function call, you use one of the two blocks above!
Also, keep in mind that it'll only refer to events being precisely "Custom Events", not e.g. mouse-clicking events called "Click1", "Click2" and such in behavior editor. ;)
(not that I assume you would think so, but it's better to be safe here :P)

katana

  • Posts: 128
Oh, that explains it, thanks :)

I guess the lazy option has even more downsides than just slightly reduced speed.
One of the two expert stencylers to have done precisely nothing to earn their title... Oh damn, he did something and got promoted. I need to get to work. Until then, I'm unique?
<Katana>: Blob: back me up :c
<Stevetheipad>: what's the "move pen to" block?
<Blob>: irock you are wrong
<Blob>: it's 2 against 1 we live in a democracy