0
$\begingroup$

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?

$\endgroup$

1 Answer 1

0
$\begingroup$

When you register your script it becomes a module which you can then import in another script.

$\endgroup$
3
  • $\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$
    – sambler
    Commented 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .