Name Error with global variable

Hello Everyone, and already thanks a lot for any help…

At beginning of the program I define the global variable “element” as shown:

“Signal arrives” was done for checking if my sensors work… they do.

Then I want to use this variable in a function later on:

NameError: name ‘element’ is not defined

You guys probably have to smile about this Problem… but it makes me crazy…

looking at your screenshots it looks like that “if bge.logic”… is at the top level (no indentation), and the variable “element” is declared inside the if-block, making it a local variable.

saveroutine() is a global function, and you try to read from “element”, which is not a local variable within the scope of that function, nor is a global variable.

Realising it`s about the priorities of the global and local state… I at least made it work.
Only using one local varible and increasing the function… containing everything necessary…

Graazie :slight_smile: