i have 2 scripts, one is the external script where i can get 2 external signals from the serial port, and then i write this data in a text file, this script is sending the 2 data continuously.
The other script is in Blender, with this script i get the 2 data from the text file and with these data i can move a cube in BGE.
now my problem, i need to share a variable from the script from blender to the external script. i tried using (from “name of the script of blender” import “the variable”) but doesn’t work, it said “No module named GameLogic”.
I use “import Gamelogic” in the blender script.
i have 2 scripts, one is the external script where i can get 2 external signals from the serial port, and then i write this data in a text file, this script is sending the 2 data continuously.
The other script is in Blender, with this script i get the 2 data from the text file and with these data i can move a cube in BGE.
now my problem, i need to share a variable from the script from blender to the external script. i tried using (from “name of the script of blender” import “the variable”) but doesn’t work, it said “No module named GameLogic”.
I use “import Gamelogic” in the blender script.
You could create another python module where the variable that needs to be shared is defined and import it into both the external and internal scripts. Alternatively the internal script could write the variable value to another text file that the external script can read.
why do you need to use the textfile as interface. Can’t you read the serial port from Blender?
An alternative way would be a socket connection between the program that deals with the port and the BGE.
This avoids the slowdown that you get when dealing with files.