+2 votes

I know that this question was already asked on this forum, but I couldn't find any proper answer to it, they just link to the godot-python repository (https://github.com/touilleMan/godot-python) wich dosen't seen to have a documentation, i just wanna know how to do that in code, how to send and get information from one script to another, I am developing a game in godot and a friend of mine is creating an AI in python for the game.

Godot version 3.3.2
in Engine by (70 points)
edited by

Also, when I went to the Godot python repository, it gave me a 404 error - the author probably removed it or something.

2 Answers

+1 vote

If you don't need to have it update very quickly, you can write to a file in gdscript (eg. input.csv), send it to python, use that data as inputs (using keras/tensorflow or something), then write the outputs to a file in python, and read them in gdscript. You do always need the python script to be running in the background, however.

by (272 points)
+1 vote

Since you've got two agents and you want them to communicate.
Go with a TCP or UDP server and client respectively.

Simply send the instructions in packets (encrypted of course)
Then open up a communication between the python AI and Godot game through the localhost


If you wanted a more direct approach then you could technically operate python through Godot's OS.execute() function or python's subprocess class

by (4,982 points)

Actually, that's much smarter than what I suggessted!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.