[Construct 3][Feature Request] Function Advanced :: Call Function on Event Sheet

0 favourites
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Hello Construct Team. I have a feature request that won't require much time to add and if you wanted to, you could even add it immediately on the next release. With that said, this feature would still be very beneficial with developers who have complex projects.

    I have a sample Construct 2 plugin that might be a good basis on how it could be achieved and to show its practical use. Although I expect improvements from Construct team as it will be an official feature.

    The feature is the action "Call Function on Event Sheet". This eliminates the need to include an entire event sheet just to call a function from another event sheet. This would be very useful for complicated projects that require branch events. Games with Multiplayer, Open-World, Map Generator, Procedural Generation or any large projects that requires complex and modular game management and in-game design.

    Thank You.

    Ashley

    Reference : construct3.ideas.aha.io/ideas/C3-I-504

  • So in the event sheet A you call a function from event sheet B, without including B.

    What if that function relies on other events from the event sheet B? Say, calls other functions or triggers some delayed events defined in B?

    This can cause problems that will be very difficult to troubleshoot.

  • dop2000

    So in the event sheet A you call a function from event sheet B, without including B.

    What if that function relies on other events from the event sheet B? Say, calls other functions or triggers some delayed events defined in B?

    This can cause problems that will be very difficult to troubleshoot.

    Of course there won't be any problem since in the first place you are calling only a single function. And no one is forcing you to use a more advanced feature, but what is important is that it is at least available.

    Anyway, if Ashley wants to, he could work around that depending on how he prepared Construct 3.

    I do expect the Construct Team that they will improve the feature anyhow they can especially if it is going to get official.

    Hard to troubleshoot? Actually this is not a big deal to troubleshoot especially when we have situations similar to this case that still no one to an extent did complain about changing. Like Nested Groups, Wait(), Includes and etc...

    Nested Groups for example can have deactivated groups withing a parent group and this can cause problems in troubleshooting, but this makes sense to have as a feature since we need block scoping.

    Wait() in loops and functions and etc. can cause problems too and hard to troubleshoot but we just need to learn to use it properly.

    And Includes can actually be complicated as this function feature since they act as branch nodes and unexpected event sheets might get included and run without even the developer noticing, since includes can go spaghetti.

    So if another event sheet have initialization events there, it could run even when not supposed to. Then, that would be harder to troubleshoot.

    They all can go haywire on specific situations but we just need to learn to manage it. Construct is made easy but it shouldn't be limited to complex creativity just to avoid confusion in troubleshooting.

    If you support this kind of mentality, then Construct Games will continue to be seen by users as a game engine limited to typical game functions made mostly with built-in behaviors. Which Construct is not, it is way better than that and it has very good potential to do a lot of complex and advanced things.

    Besides, this is actually quite beneficial. It would prevent and avoid redundant techniques to very complex situations. Imagine this, if you include an event sheet instead of calling only a function from an event sheet.

    It would be way harder to troubleshoot when you face these problems:

    1) Duplicate Functions

    2) Include Spaghetti, includes that are spread across event sheets.

    3) Unorganized events

    Now here, you either pick to 'Duplicate a function' or 'Include Event Sheets' repeatedly until you lose track of their sources. For example :

    i.imgur.com/HiW2lqi.png

    Click the link to see the image.

    Imagine if Event Sheet (Green) has the functions. It is haywire!

    Either way, it is messy. The best solution, is the "Function Call : On Event Sheet".

    We have been using this feature on the background of Construct 2 for a while now and nobody has ever gotten any problems including me. But now, I am not sure if the SDK documentation references for the function plugin on Construct 3 is available, so i think asking Ashley to support it officially is better.

    Or, if he can't or won't, I would like to ask the Construct Team the 'Editor' and 'Runtime' documentation reference guide on how I could achieve making a customized function plugin for Construct 3.

    Thanks.

  • I still think you are wrong.

    You are basically asking to implement a hack.

    I can see how this feature can be useful in some projects, but I also see how many people (especially beginners) will abuse it and this will result in very poor code organization, and could potentially cause more harm than good.

  • dop2000

    I still think you are wrong.

    You are basically asking to implement a hack.

    I can see how this feature can be useful in some projects, but I also see how many people (especially beginners) will abuse it and this will result in very poor code organization, and could potentially cause more harm than good.

    It's not a hack. It's like saying the MM_Preloader or the MM_Unloader is a hack.

    Which it isn't. It is fully compatible with the SDK like the Function_Advanced.

    The Function_Advanced is fully compatible, just not available.

    It's a very simple plugin, yet a masterpiece. Try to read the code of the Function_Advanced, you'll see how impossible for it to be a hack.

    On this link :

    https://construct3.ideas.aha.io/ideas/C3-I-504

    The feature :

    The feature is the action "Call Function on Event Sheet". This eliminates the need to include an entire event sheet just to call a single function from another event sheet. This would be very useful for complicated projects that require branch events. Games with Multiplayer, Open-World, Map Generator, Procedural Generation or any large projects that requires complex and modular game management and in-game design.

    Modular design capability is the most important part of this feature, which as of now, Construct 2 / Construct 3 doesn't have. With this 'simple action', the limitation is lifted.

    Wait. How can it be harmful and how can you abuse it? I don't find anything on the plugin that can be abusing or harmful. If it were, we could have done it on Construct 2 long ago. It is just a simple call function from another event sheet. That is actually very convenient considering it has all the benefits without having to make a messy game event design.

    It doesn't lead to bad code organization, as a matter of fact, it improves it since we can then make modular game event designs. AKA, removes messy redundant events, removes unnecessary more event sheets, everything can be modular, build things by parts and not involve global variables which are messy with modular events and especially bad for performance.

    And worrying about beginners, they have to learn it anyway, especially if they want to be serious developers. It is the same with actual programming.

    So to conclude.

    Benefits :

    • Modular Events, game designs built by parts/modules. Better event management.
    • Less event sheets. No more redundant event sheets.
    • Avoid use of global variables as an alternative means for modular events.
    • More organized events. Clean looking with less redundant events.
    • More performance in avoiding global variables for modular designs.
    • Modular Debugging.
    • Multiplayer Games to separate the Server Module with only 1 function to call all clients.
    • 1 function call to toggle/initialize all modules. This is my favorite feature.
    • There are so much possibilities! Not surprising though.

    Disadvantages :

    • 1 action more confusing for a beginner.
    • Call a function from an event sheet, must not call another function.

    There are only 2 disadvantages. Which are very easy to overcome.

    The first disadvantage is that it can be confusing to beginners. But aren't functions confusing to beginners. And that is not a problem since they can learn.

    The second disadvantage is easy to manage. The Function_Advanced has a red-icon indicator, if you see that function, don't call another function within a red-icon function.

    Although, I can see a potential on Construct 3 to overcome that. I believe Construct 3 can make a better version of the Function_Advanced plugin which can remove all those limitations. Which isn't really bad, if you ask me. It's a very very small trade-off for a better Function Plugin.

    For anyone interested in having this on Construct 3, please vote here :

    https://construct3.ideas.aha.io/ideas/C3-I-504

    Thank You.

  • The Function_Advanced is fully compatible, just not available.

    It's a very simple plugin, yet a masterpiece.

    [...]

    If it were, we could have done it on Construct 2 long ago.

    What are you talking about? What function_advanced, what plugin?

    Does a plugin that allows calling functions from another event sheet already exist in C2?

  • dop2000

    > The Function_Advanced is fully compatible, just not available.

    > It's a very simple plugin, yet a masterpiece.

    > [...]

    > If it were, we could have done it on Construct 2 long ago.

    What are you talking about? What function_advanced, what plugin?

    Does a plugin that allows calling functions from another event sheet already exist in C2?

    It's on the link. Included on the Feature Request. I wouldn't have asked something that is not possible and tested.

    construct3.ideas.aha.io/ideas/C3-I-504

  • I didn't notice the attached file, sorry.

  • I think the real problem is, if the functions needs certain objecttypes like a sprite or array, so if i understand correctly your basicly asking for modularity, and it hasn't been officially adressed how this would be handled,

    in other engines you have a script or set of functions that work with certain datatypes, the engine warns you that certain object doesn't exist, you then select the right datatype or its filled in.

    currently construct needs an objecttype to exist if you want to connect events to it , for example a camera function would need some "object" to follow, maybe relies on the keyboard plugin, maybe this object to follow has some variables etc...

    so it would need some of the same functionality that basicly makes it fast to import eventsheets that relies on certain objects

    if you ever copied over some events from another project you know what hassle it is

  • you dont need to use include event sheet to call functions from other sheets o_o

  • you dont need to use include event sheet to call functions from other sheets o_o

    If you haven't included the event sheet containing the function you're calling, it won't work. So if I have declared a function called "TEST" in "Event Sheet 2", and in Event Sheet 1 I try to call TEST, it will not work unless I've also included Event Sheet 2 in Event Sheet 1.

    That said, I have no idea how or why this suggestion could have gotten 106 votes in just a few days (and most of those votes are coming from egg accounts which makes me suspect foul play, haha). I wouldn't complain if that many people really want this feature and Scirra thinks it's a good idea or easy to implement. I personally have yet to encounter a case in my own projects where I needed this sort of thing, but I suppose it comes down to how people want to organize their event sheets and name their functions.

    I just keep thinking I"d rather have that effort go into a scene graph, animation timeline, and event sheet-authored behaviors that we can share between projects. Those are things that would be widely useful and I find myself wishing for them on every single project.

  • That said, I have no idea how or why this suggestion could have gotten 106 votes in just a few days

    Yeah, it got me puzzled too :)

    .

    I would probably like to see a different feature implemented - a Global Event List. When you mark an event list as Global and it becomes "visible" from all other event lists, without the need to include it. Would be useful for generic events and functions.

    EDIT: Event Sheet, not Event List, sorry.

  • IJCT

    you dont need to use include event sheet to call functions from other sheets o_o

    Of course you need to.

    Scoremonger

    ..but I suppose it comes down to how people want to organize their event sheets and name their functions.

    I just keep thinking I"d rather have that effort go into a scene graph, animation timeline, and event sheet-authored behaviors that we can share between projects. Those are things that would be widely useful and I find myself wishing for them on every single project.

    First of all I understand but I don't want to add more problems for the Construct Team before the new C3 runtime is released. I already have a C2 plugin ready for it called "Function_Advanced", and what you are suggesting would do more work when we already have a solution that only needs a port to Construct 3 because the current C3 SDK isn't available for this feature. And I can see the potential that Construct 3 can overcome the limitations with Function_Advanced had on Construct 2.

    dop2000

    I would probably like to see a different feature implemented - a Global Event List. When you mark an event list as Global and it becomes "visible" from all other event lists, without the need to include it. Would be useful for generic events and functions.

    That is very bad for the editor. I don't know if you've ever made a large project on Construct 2 or Construct 3 or any game engine. But as by experience, the more visual popups you have, the slower the editor becomes.

    That would slowdown the editor so bad. The key point for every game engine is to limit the performance overhead as much as possible and avoid redundant visual windows / visual lists that can have the potential to reach the number of thousands of object loads.

    With my current project with 2686+ objects :

    Construct 2 :: Visual Popup, Undo, Redo, Change Events, Image Editor.

    It takes 5 seconds to load.

    Construct 3 :: Visual Popup, Undo, Redo, Create/Change Events, Image Editor.

    All Objects Expanded: It takes 5 seconds to load.

    Some Objects Expanded: It takes 1 second to load.

    dop2000 So, what you are suggesting can really do more harm than good.

    Reference just in case you are curious:

    https://www.construct.net/ph/forum/construct-2/closed-bugs-22/poor-c2-editor-performance-on-131074

    I made the reproducable .capx there so I myself have witnessed the dire effects of too many visual popups.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is very bad for the editor. I don't know if you've ever made a large project on Construct 2 or Construct 3 or any game engine.

    I have and you are not making any sense.

    Say I have an event sheet named "General Functions" with functions like "getValue()" and "setValue()", which I need throughout my project and therefore have to include it in all other event sheets. Which is a bit of a nuisance. What I'm suggesting is a single checkbox to mark this event sheet as Global. How is it different (performance-wise) from including this event sheet to all other event sheets?

  • dop2000

    > That is very bad for the editor. I don't know if you've ever made a large project on Construct 2 or Construct 3 or any game engine.

    I have and you are not making any sense.

    Say I have an event sheet named "General Functions" with functions like "getValue()" and "setValue()", which I need throughout my project and therefore have to include it in all other event sheets. Which is a bit of a nuisance. What I'm suggesting is a single checkbox to mark this event sheet as Global. How is it different (performance-wise) from including this event sheet to all other event sheets?

    You should have just said Global Event Sheets. The Global List you've mentioned was misleading. You should've added more details, it could just be anything like a Global List of Events / Functions. Which is vague or different from your original reply.

    Anyway, you are asking for a feature that would instead limit functions to a single event sheet! You missed the point, that is not how modular events work.

    Here are some breakdown cases:

    • What if the function is needed to be close or under its Group or Mutual Events? If you move those to the Global Event Sheet, you break code organization.
    • You are missing the point. Because groups are the only reason there are pseudo block scopes in Construct 2 and Construct 3. And that is a key feature in modular events. And now you want to take that away from functions? You want them to be always global. We might as well use Includes. That is some redundant feature. As I've mentioned, don't add redundant features, that is bad for editors.

    My solution is far more practical, flexible and creative, with more possibilities. A Function plugin with an indicator, it is as easy as it gets. And we don't get to add more editor changes.

    But if you want to talk about additional features.

    Construct Team can even find a way to make a filter of functions available for every event sheet so that whenever you choose an event sheet, it only shows the functions you can call. Could even make it a separate plugin, could even add function dependencies to include other functions that might be required manually or even automatically.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)