Accessing Modules in BGE

How can I access the data of a variable stored in a module .py file, while inside the game engine? I have a main python script that I am running but I want to be able to read, and make changes to, variables that are stored in other python scripts, from the main script. Can someone post an example of how to do this?

variable = 2

import settings

variable = settings.variable
settings.variable = 4

Aggose77 shows you the right way for module access.

You can’t access variables of a script. Scripts live as long as the controller runs. The script dies when the controller ends the execution.
If the script didn’t stored references outside of the script context the variables are lost.


Yes, what i have showed you allows you to use a python file to store data during runtime, or you could use the same with classes.

This worked for me, thanks.