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$
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$ Jul 5 '18 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
    Jul 6 '18 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$ Jul 6 '18 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.