The 1st question is in the title. The 2nd question is, if events are repeated then can we use the “at the beginning of the scene” condition? If events are not repeated then can we use “repeat n times” or “while … repeat”?
Functions are just like builtin events. They’ll do whatever the condition, expression or actions tell it to do. They flow from top to bottom each time they’re triggered from the other events. If there’s a repeat or other event that causes a loop, that part will loop but not the entire function.
I don’t believe **the the beginning ** would work well within a function but you can use it within the main events to control when and how frequently the function gets triggered.
Try to think of functions as identical to builtin events. The best practice is that functions should be self contained. They should also be thought of as being short lived. They shouldn’t retain information. That should normally be done by the main events. The functions should behave the same way each time just like any built in function.
it doesn’t answer the question in the title. In other words, when is the function completed and return its final value? if there’s loop returning several values for example
What type of function are you making? What do you want to do
It returns the value after it finishs its event sheet. It runs from top to bottom. You can set the return value anywhere in the function but the function retains control and doesn’t return to where the function was used until it finishes its events. It then returns the current value.
You can only return 1 value at a time. If you change the return value within the function it changes the return value. Think of it like a variable. If you change a variable several times, it’s the final value that matters.
You can return an array of values or structures with the variable parameter. Or you could use a loop of some form within the main project and repeatedly call the function while changing a parameter.
Instead of returning a list of something, you can add the events to the function and let the function handle that as well.
yeah sorry I should have said I had in mind an asynchronous function. The callback variable that goes into the returned value of the function is changed after the event sheet is finished. So I get the wrong callback variable as a result.
I’ve never used async. I can’t help in that one.
I’m thinking that deleting the scene variable would make it work. But I can’t even find documentation on how to delete a variable…
That part doesn’t make sense to me. I would need to see events and look into how the async works.
I don’t think you can delete a variable. You can change it. I guess if it was a child then you could delete it but not the main variable. I don’t know what you want to do.
yes. Well thank you for your help and time. I should erase this post. I made a new one about the callback variables. This one is too confusing