Custom Function Don't Work

Hello guys,
i have a function like here ;

when i call this like this ;

the second one not even creating a hole , and not spawning enemies as expected.
But when i call them manually not even changing a single argument ;

it works awesome. What i couldnt solve is my algorithm wrong ? or is this a bug ?
Note: when i call the functions with same start and end time , enemies pop up from both holes , so its working.
**Note 2 : ** when we call with same start time , but with different ending time , it’s working again .

What’s going on behind the scene ?

edit notes: uploaded wrong func. picture before now its fixed

You’re using the same scene timer (maintimer) for both, but it gets reset after the first function is called.

Yeah why it gets reset ? When first function called , its initializing , and doesn’t second call keeps going where its left ? Does not timers work like a scene variable ?
And if thats the case , its not the answer why its working in a hard coded way but not in a function.

Hmm, I think I got your timers mixed up when I first looked at your events. :sweat_smile:

My guess is that the second hole is deleted by the first function. Try to disable the “delete hole” action and see.
Also, I recommend you to display your timers in text objects visible on the scene, it might help you figure out the problem.

1 Like

Tried, i didn’t worked either. I suspected that deleting like you did , and you would be right if i used same object reference, thats why i created seperate 2 hole object in scene.the enemy1hole keeps getting deleted.
But not affecting 2nd hole object.
I could not figure it out yet.If scene timers being a problem , or object timers being a problem , i dont know , i give up.I will just copy paste same events.
And should i open a github issue , i dont know if this is a bug i cant decide , i’ve been only using gdevelop for 1 week.
(By the way ,copy paste always breaks the event order.)

I reproduced your issue in an empty project. I think the problem is that your object timer is used for all instances.
You need to use a for each event:

Didn’t worked either.Here i share a link of project if you want to inspect more.And of course for anyone who read this.
the project

So… I think that the trigger once inside the function doesn’t reset because the first function keeps running.

If we write events with conditions like yours , yeah it seems like not resetting.But ın my example i log them to the screen texts and they seem getting reset. And they are object timers , they shouldn’t intermix.
Soo… The functions still behave weird :sweat_smile:
Its gotta be something with game engine which i don’t know , the event’s algorithm seems logical to me.

The engine has its logic which is not necessarily yours :slight_smile:
I’m talking about the scene timer, not the object timers. You use a scene timer condition with a trigger once. You’re calling the function twice but it’s twice the same, and you don’t disable the first call before the second call and you don’t reset the scene timer.
So I think the trigger once condition is still “used/spent” (false) during the second call.
Not sure if I’m being very clear. :confused:

1 Like

I get it. I will try to cancel first func. and update the results in this answer. :+1:Probably going to work never noticed it before :man_facepalming:
Edit : I managed to get function work as i want.I gave first trigger once’s condition a inverse condition , and gave deleting trigger a 0.1 delay so it wont get called and wont delete latter holes.

Thanks for your help :clap:

1 Like