Using yield with callv(instruction["func"], instruction["args"])
Ok, so I tried to emit a signal when one function is done but I guess that is just the same, function executes and finishes as fast as it can making it look like all functions execute at the same time ... I cannot use a timer, since as said I do not know exactly when each function will be done and the times might differ .... any options I have here?
You would use signals for this. But you wouldn't still call every function. You only call the first function, and then the signals handle the rest of the sequence.
Benny
Why don't you use AnimationPlayer? This is exactly what it's intended for.
DaveTheCoder Why don't you use AnimationPlayer? This is exactly what it's intended for.
Yes, the call method track should be real handy.
Or you could use AnimationPlayer to change an object's properties, without creating a method to do that. The original post doesn't explain much about the overall result that's desired.
DaveTheCoder When and where that is applicable, absolutely.
I wanted to make an automated way of allowing for some actions to happen based on a textfile I have created, I define my actions in the text file like as soon as you reach this area, do the following by calling this function, play a sound by calling that function, show a text by calling this function, walk to this spot by using this part of the code, play another sound etc. etc., I thought I could easily handle it by calling functions automatically using callv (which does work fine using a text file) and then use a yield or any other method to play one function after the other when they are finished (which does not work whatsoever ...., this is where I am stuck) (similar to callbacks or async function in any programming language where you have to pull data from a server ...), anyways this does not seem to work in a satisfiable manner, reason for me to do this is because I want to make it easier and automated for myself to create complete story scenes where stuff is moving around or stuff is being said or done without me having to create for that each time my own scene, add different nodes to it add texts or dialogs to it aso. aso. that is my reason for this, so if anyone has any good solution to build something like this without having to use yield or callv, I am all open
Yes, you would use signals, as I mentioned. If you want to do it generically (e.g. not define a new signal for each function) then make a signal called "next_call". Then you have some sort of manager than connects to "next_call" and calls the next function in the array. At the end of each function, you trigger "next_call" which the manager will be listening for and then call the next function. I think this would be the easiest way to do it.
cybereality Ok I see, I could try that. It seems like a bit more work than I initially expected but I will try it this way and see if it will work as expected. I tried using signals within the function itself already but somehow that did not work too well. I will try to make a signal manager and see if I have success with that, thank you!
Well the standard way to do this is to define signals for each function. Signals can take an arbitrary number of parameters, so they are essentially the same as calling a function, just asynchronously.
And your JSON or text file could be in the same format, but instead of using callv, you just trigger the signal. This is basically the same thing, so not really any benefit feature-wise, but more likely how it is done in Godot.
Though, either way, you'll still need some sort of manager to sequence the function calls, as you won't know ahead of time how long they take.
cybereality Good day! So I looked at this and I simply cannot wrap my mind around this really ... I get what has to be done in theory but I do not understand how I can setup a manager that handles signal calls in sequence, would you perhaps be able to give me a tiny bit of example code to get me started? That would really help ...