This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+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 ( 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 (76 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

+2 votes

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 (248 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 (6,942 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 Frequently asked questions and 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 [email protected] with your username.