Stencyl 3.4.0 is now out. Get it now!

Calling Custom Events in Actors from a behavior

Fool

  • Posts: 78
I'd love to be able to call custom vents in Actors from a behavior attached to the actor.
That way actors can hold actor-specific logic, and logic thats more general and behavior oriented, or controls
how actor logic works, can be isolated in behaviors.

Justin

  • *
  • Posts: 3814
You can. Use the trigger event block, and select the appropriate Actor Events behavior from the behaviors list. Or use trigger event for all behaviors attached to actor.

For Live Support: Join our discord channel and ping me @justin.

Fool

  • Posts: 78
I don't think I explained it well enough.
I can trigger events in other behaviors from any given behavior, but can I trigger events *directly* attached to the actor? And can I trigger these *from* an attached behavior?
Because when I tried, nothing happened.

Justin

  • *
  • Posts: 3814
Yes. As I said, look under "Actor Events" in the behaviors list. If you tried what you believe should work and nothing happened, post your code for troubleshooting.

For Live Support: Join our discord channel and ping me @justin.

Fool

  • Posts: 78
I just tore out the code and rewrote it to route around the problem. I tried 'trigger event text in all behaviors for actor'
but that didn't work. This wasn't supposed to be a bug post, but heres the details. I have a 'UIElement' behavior, that has a bunch of attributes, including 'isActive?' a boolean. isActive is set by other behaviors and actors for various reasons. UIElement has two boolean events, 'active' and 'notactive' based on the value of isActive. In each UIElement is supposed to trigger a custom event on its parent actor, an event name which is passed in via attribute filled out in the behavior configuration screen. This way I can separate interaction from logic.  So I have a UIElement that handles when something is clicked..and I can just add that as a behavior to dozens of actors if I want for example. And that in turn calls custom events in the actors themselves. I can do this for other standard interactions, double click, drag, etc.

Anyway I run this, and nothing happens when I click on the actor on screen.

Justin

  • *
  • Posts: 3814
Seems like there are a lot of parts that could cause this to fail (slight misconfigurations, typos, so on).

It sounds like you're using a different approach now, but if you want to get your original idea working, feel free to send me the game and I'll take a look.

For Live Support: Join our discord channel and ping me @justin.

Fool

  • Posts: 78
I appreciate the offer Justin. And you're right, there was a number of fail points. After talking with you I realized I probably wasn't going to need it, and was just duplicating engine functions. I suppose its true what people say, YAGNI.
Thanks again!