I’ve use code like this:
own = cont.owner
if not "variable" in own:
own["variable"] = 1
but I don’t know what to do with global variables. I’ve tried things like this:
g = GameLogic
if not "variable" in g:
g.variable = 1
from bge import logic
if not hasattr(logic, "variable"):
logic.variable = 1
The hasattr function checks If the module logic (or bge) (the first argument) doesn’t have a function or attribute named “variable” (the second argument), it return True or False.
Why do you import gamelogic and bge? AFAIK, They are the same thing.
EDIT: gamelogic is bge.logic
I dunno. I probably learned it from an old guide. it’s one of the problems of being self taught. I sometimes pick up outdated information.