Event Trigger (Construct 3 Plugins)

You're viewing a single comment in a conversation. View all the comments
  • 13 Comments

  • Order by
  • What's different from function?

    • Actually typing the response to your question made me think through a scenario that made me realize that there is a bug in the code. If you only send one event, but there are multiple handlers waiting to respond, only one will trigger. I am working on that and will issue a new version soon.

    • That's a great question.

      1) It decouples your code so you fire off an event and aren't concerned who or if anyone handles it.

      2) Based on the event sent, you could have different logic executed on different event sheets. So lets say you have a player being hit by bullets. The player event sheet sends an event player hit, It's responsibility is all things about the player. The title screen may act on that message by changing the color of player. On the game screen it may decrease the health of the player.

      3) You also could have multiple items respond differently based on the event. Lets say you emit an event for player health low. You could have a health bar that listens for that event and changes color, the player could listen for that event and start flashing, etc.

      So it's a different way of organizing and thinking about your code in a more event system driven way where one event could have a multitude of results.

      Hope this helps

      • Doesn't this work with only the Function object?

        Call the Function "Screen Touch" (from your blog post), and in this function call other functions or other code

        • You can organize your logic many ways. Can you do this with all functions and have it work, of course. Can you create a function that calls other functions, of course. This is more a way of organizing code so that you fire an event and don't worry about who or if anyone handles it. It is the responsibility of other events sheets to decide to handle it or not. Instead of having nested functions set up, where one function ultimately has knowledge of all things that need to be called. It's just another way to organize and reason about your code. So in my game the benefit is that I'm encapsulating all behavior in a components' event sheet and there is no logic anywhere that has to specifically call it or any other component. If I want to add it so that another component listens for that event, I just make it listen for it, no other changes required.

          So like I said in the blog, will this work for everyone, probably not. It just depends on how you like to organize and maintain your code.

          • Yes but my point is: you can already do that with Functions.

            The way i see it - this is just another way to organize events, but the way you describe it, it should work with Functions too.

            1. = Function Plugin = F

            2. = Event Trigger Plugin = ET

            Starting the Event - When the Event happens:

            1. F Call "Screen Touch"

            2. ET Send Event "Screen Touch"

            On any other Event Sheet:

            1. F On "Screen Touch" is called (= triggered) - does stuff

            2. ET On Sent "Screen Touch" is triggered (= is called) - does stuff

            Want to add another thing that happens when the "Screen Touch" Event happens?

            1. Add another F On "Screen Touch" in any Event Sheet

            2. Add another ET On Sent "Screen Touch" in any Event Sheet

            • (

              This is a Test Text for Website Issues.

              "

            • "Call Function" and "On Function" are just different words for "Send Event" and "On Sent".

              Both Plugins:

              "Call"/"Send" an Event with multiple Parameters.

              Can have multiple "On Function"/"On Sent" Conditions in different/same Event Sheets.

              (I may be overlooking something, but i just cannot see the difference other than the words)

              • Looking at the documentation for the Function plugin, it describes it and shows examples of using like a function in a traditional programming language like what I am used to. Usually you have one "On" block that gets executed (shared code). It appears though that you are correct you can use multiple "On" blocks and have them all fire on one "call". I wasn't aware that could be done.

      • Ok, I kind of understand now:

        1.It's for keeping code split and orgnazied. I do have player code in enemy event sheet.

        2.It's a broadcast and there is no broadcast for function plugin.

        One thinking : Compare to function, this event have only 1 parameter, it has more work to do if I want to picking object with messages.

        • Good suggestion. I just finished making it capable of having many items that can be passed in a message. Getting ready to post my update in the next few minutes. For now it just a basic implementation, but I may add to it in the future.