Q. Functions triggered without being called?

0 favourites
  • 12 posts
From the Asset Store
Basic clone of a 80's arcade game called Gyruss that was quite fun to play!
  • Hi everyone!

    One quick issue.

    I have a bunch of functions in a separate functions event sheet (included in main event sheet) that fire off at start of layout, although I do not call them anywhere in the code! For example, I have a function that triggers something when the cursor is over a certain object, however, I wanted that to happen only when the function is being called. This is not what I got. Even if I don't call the function anywhere, it will still trigger.

    Anyone has any ideas why and what can I do to stop this from happening?

    Cheers!

  • That shouldn’t happen. If you’re sure you’re not calling the functions, then I guess it may be a bug. All I can say is I’ve used functions a lot and they only run when I call them.

  • even though they are disabled at start of layout, they still trigger when i run the code.

    image of even sheet here: ibb.co/haAm7H

    I have a separate event sheet for functions which is included in the main even sheet. if I disable the groups of functions in the functions event sheet, then they won't work. but otherwise, no matter if I call them or not in the main even sheet, they all run at layout start... It's quite annoying as I don't know why this happens! Is it really a bug? Can I circumvent it or do I need to start fresh (I'd rather not..)?

  • Post the capx, and i'll narrow it down if it's a bug. Disable actions don't run, if the functions run, then they must be called from somewhere. I can't guess anything from a screenshot of events.

  • here's the .CAPX: ufile.io/bq3oa

    it's not a lot of code, shouldn't take you long <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    thank you very much! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

  • Had a quick look. I can't open the capx because it uses plugins i don't have and likely will never install. Anyways looked in the event sheet xmls. You have functions that do some things but you also have events that will run that aren't part of the functions. Are you sure it's not just those events that are running and making you think it's the functions?

  • I don't think I'm using any of the 3rd party plugins... I've installed a few a while ago to check some examples of things I was interested in but never really used any.

    As for events outside any functions, I will check to see if I misplaced something somewhere.

    Please let me know if there're any plugin names that popup when you try to open the .Capx and I'll upload another version without those.

    Thanks again!

  • I disabled all the functions except for a simple one. In the main even sheet, I also disabled the action of calling it, yet it still triggers.

    hopefully, this image can tell you more: ibb.co/eVnzSH

  • As R0J0hound pointed out, the majority of your code isn't even in the function. It is in the Group, but that is different. You can't put triggers in functions. You can't use Every X seconds in a function. You need to read up on Functions and Groups. Most of what you have would work in the Groups, but you need to disable/enable the Group when needed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I know how to disable and activate Groups, but I thought doing it via functions would work just as well. I did not know that I can't use Every x seconds in a function, never came up in everything I read on functions so far...

    I also just realized that in the first function there is an "Every x seconds" event. Would that be why it triggers at start of layout in spite of the disabled action to call it?

    I'll have to get rid of all the functions for now until I learn them better. and work with groups instead, I guess.

    Btw, if you have any links to any tutorials / articles of what one CAN'T do within a function would be really appreciated, as this never was a topic in everything I've read so far, which lead me to believe that any piece of code within the function will work. Btw, if you haven't noticed already I don't have a background in programming so please have mercy on me

    Thanks again for the pointers!

  • You have your on function events and then events right after that. Those right after aren’t part of the function event, so they will run as normal. So it’s not a case of the function triggering, it’s just events running as normal.

    If those events were sub-events I’d the function then they would be part of the function and wouldn’t run without the function being called.

  • Got you! I thought that events running after a function will be part of the function for some reason.. I'll look at the code again.

    Live and learn.

    Thanks again!

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