MoscowModder's Recent Forum Activity

  • Ah, nice! Thanks rhg1968!

  • DiegoM - Hmm. It's not as elegant as I might like, but I suppose that could work.

    Perhaps some day I'll learn the addon SDK and develop my own plugin for this.

  • Yeah, that sounds pretty similar to what I have.

    Using the layout name in the function call sadly won't help me because I also have a Pause menu that appears in most layouts. Some layouts have both the pause menu and another menu.

    I might swap out my own equivalent to your OnKeyPressed functions from callbacks to functions for consistency. I felt that might take a small performance hit, but it could be worth it.

  • Unfortunately, signals don't take parameters, which I rely on in many places.

  • Right. I am not doing this for repeatable bits of code. That's what I use the native Functions feature for.

    I'm only using the old Function plugin because it just so happens to provide exactly the functionality I need for callbacks.

    If we had custom events on objects, I could replace a lot of this. But I can't.

    I'm not asking how functions work. I am asking if there is anything else out there that could do exactly (or approximately) what I am doing now.

  • Okay, how about this case then: control inputs.

    My game supports both keyboard and gamepad inputs. All of these inputs are customizable with an in-game menu.

    I have 2 kinds of checks, similar to the built-in Keyboard & Gamepad plugins:

    * inputDown(control): Checks if the given input is being held down. Implemented with a native function. Checked with an expression.

    * inputPressed(control): Event called when this button is pressed. Implemented with the Functions plugin.

    For example, here's the code in my Controls event sheet that fires these events:

    And here's the code in my Menus event sheet that listens to keyboard input while a menu cursor is active:

    And here's the code in my Player event sheet that also listens to some of the same events:

    So basically, when I press a keyboard/gamepad button, the controls module sends out a callback that a playable character or a menu cursor or something else might possibly listen for. I can't make a single function out of all the possible things that might happen when you press a button.

  • My problem is that C3 functions can only have one definition in one event sheet, where as the Function plugin lets you define a response to the same function call multiple times.

    I need callbacks that can have multiple different effects depending on what event sheets are loaded. For example, my "on menu item selected" callback that's fired from my global Menus event sheet, which has a different callback listener on each event sheet that has menu items defined in it.

  • When I opened Construct 3 after the last update, it warned me that the old "Function" plugin (a carryover from C2) is deprecated and may be removed. In my project, I use that alongside the new-style C3 functions. My reason is that where the C3 functions have a single definition, the old Function plugin lets you define a function in multiple places. This, to me, makes it a perfect event/callback system. A piece of code can fire off an event without knowing if there will be a piece of code in the current event sheet that listens for it.

    For example, I have a callback-style function called "checkpointDone". Note that I changed the name of the "Function" plugin to "Callbacks" to reduce ambiguity.

    In this code, I have a standard function that will save the game at a checkpoint.

    Then, in this code for a specific level, the game is supposed to wait for the checkpoint to finish saving before it does something.

    I have many, many other uses of this plugin, including the callback when my universal menu cursor selects something. In this specific case, this would easily be handled by custom object events (similar to custom actions), if only C3 had those.

    Is there another method I could do to accomplish the same purpose?

  • Update: Ashley responded to my bug report and explained that in JS, you can check the `isEndingLayout` property of the event object in your listener to tell the difference.

  • Yeah, considering they changed that behavior in event sheets, that seems like an oversight.

    Anyway, I guess as a workaround I can just use an event sheet trigger to call my JS function for now.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I managed to replicate this behavior in a minimal example project. It's pretty consistent.

    I attached listeners to "MyObject"'s destroy event in event sheet and script. Destroying it directly triggers both. Changing layouts (in event sheet or script) triggers only the script listener.

    https://www.dropbox.com/scl/fi/uhbib9wozk9jct0qv9hnc/DestroyListenerTest.c3p?rlkey=7vu1msqyakrfq41qqhnyykjny&st=71wppsf2&dl=0

    I'm going to submit this as a bug and see what response I get.

  • No, the layout change is triggered from an event sheet.

MoscowModder's avatar

MoscowModder

Member since 24 May, 2013

None one is following MoscowModder yet!

Connect with MoscowModder

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

16/44
How to earn trophies