I have the 'distance' variable in the file 'char.py'. I wanted to get the value of this variable in another script. How do I achieve this?
1 Answer
$\begingroup$
$\endgroup$
3
When you register your script it becomes a module which you can then import in another script.
-
$\begingroup$ I want to access without modules. $\endgroup$ Commented Jul 5, 2018 at 23:43
-
$\begingroup$ @ElektroJavorski if you don't want a module you can add a game property to an object and access that property from every script. See this answer which gets the current scene and accesses the scenes objects. $\endgroup$– samblerCommented Jul 6, 2018 at 4:35
-
$\begingroup$ Access a variable through an object in the scene I know. I want to access this variable directly from one script to another, without modules and without variables in objects. But if there is no way, then I will study about modules to see how it works. Thank you! $\endgroup$ Commented Jul 6, 2018 at 14:17