Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | aengus126 |
There aren’t any comprehensive tutorials on this, rather only a few forum posts with bits and pieces of partial answers. I have been using the little information online to barely use this function but I’m at a point where I can’t go on without knowing more.
I’m currently building a bot. I made a python script to do all the typing and I made a Godot UI to control the script. I kept making changes to the script, exporting it to an exe, and then running it using OS.execute() in Godot and it always worked. But recently, I made some changes to it and now the script exe can be opened everywhere except by Godot.
So, could I be using OS.execute() wrong? The function uses three main parameters.
The first is the target application’s path which makes sense.
But the second is the applications arguments. What even are these? Godot doesn’t explain in the documentation, it just gives an example- ["-w", "3", "godotengine.org"]
. I have no clue what those mean and what they are supposed to do to the application. I imagine that my application isn’t running right from Godot because of these arguments.
The last one is blocking which doesn’t really make sense. “If blocking is true, the Godot thread will pause its execution while waiting for the process to terminate. The shell output of the process will be written to the output array as a single string. When the process terminates, the Godot thread will resume execution.” How is Godot supposed to use the shell output if the Godot thread is paused? Godot has a OS.kill() method that states that it uses the PID obtained from OS.execute() to kill the running program. But if the program is running, the godot thread is paused and can’t do anything. This doesn’t really make sense so I just set blocking to false and used other ways to get the script to stop.
Maybe I’m understanding all of this wrong. I don’t know how Windows shell stuff works so if I need to understand that first then it would be appreciated if somebody could give me a link to a tutorial for it or explain how it works. I also would really appreciate some help on how OS.execute works. Thank you!
Update: jgodfrey has provide a super helpful explanation of how OS.execute works. For me, the problem of not running the application correctly was fixed by exporting the godot project and running the exported instance. weird.