Skip to main content
replaced http://blender.stackexchange.com/ with https://blender.stackexchange.com/
Source Link

This appears to because the module will only be executed oncemodule will only be executed once. Variables assigned directly inside the module will retain their initial value and won't be re-evaluated when accessed later.

To re-evaluate a variable, define it inside a function and call the function from wherever you want to access the current value of the variable.

For example, in the module you might create a function to return True if the W key is pressed:

import bge

def is_w_active():
    return(bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.WKEY])

Then when this is called from a script (or anywhere else) like so:

import bge, keyboardmodule

print(keyboardmodule.is_w_active())

it will return True or False accordingly.

This appears to because the module will only be executed once. Variables assigned directly inside the module will retain their initial value and won't be re-evaluated when accessed later.

To re-evaluate a variable, define it inside a function and call the function from wherever you want to access the current value of the variable.

For example, in the module you might create a function to return True if the W key is pressed:

import bge

def is_w_active():
    return(bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.WKEY])

Then when this is called from a script (or anywhere else) like so:

import bge, keyboardmodule

print(keyboardmodule.is_w_active())

it will return True or False accordingly.

This appears to because the module will only be executed once. Variables assigned directly inside the module will retain their initial value and won't be re-evaluated when accessed later.

To re-evaluate a variable, define it inside a function and call the function from wherever you want to access the current value of the variable.

For example, in the module you might create a function to return True if the W key is pressed:

import bge

def is_w_active():
    return(bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.WKEY])

Then when this is called from a script (or anywhere else) like so:

import bge, keyboardmodule

print(keyboardmodule.is_w_active())

it will return True or False accordingly.

replaced http://blend-exchange.giantcowfilms.com with https://blend-exchange.giantcowfilms.com
Source Link

This appears to because the module will only be executed once. Variables assigned directly inside the module will retain their initial value and won't be re-evaluated when accessed later.

To re-evaluate a variable, define it inside a function and call the function from wherever you want to access the current value of the variable.

For example, in the module you might create a function to return True if the W key is pressed:

import bge

def is_w_active():
    return(bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.WKEY])

Then when this is called from a script (or anywhere else) like so:

import bge, keyboardmodule

print(keyboardmodule.is_w_active())

it will return True or False accordingly.

http://blend-exchange.giantcowfilms.com/embedImage.png?bid=420

This appears to because the module will only be executed once. Variables assigned directly inside the module will retain their initial value and won't be re-evaluated when accessed later.

To re-evaluate a variable, define it inside a function and call the function from wherever you want to access the current value of the variable.

For example, in the module you might create a function to return True if the W key is pressed:

import bge

def is_w_active():
    return(bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.WKEY])

Then when this is called from a script (or anywhere else) like so:

import bge, keyboardmodule

print(keyboardmodule.is_w_active())

it will return True or False accordingly.

http://blend-exchange.giantcowfilms.com/embedImage.png?bid=420

This appears to because the module will only be executed once. Variables assigned directly inside the module will retain their initial value and won't be re-evaluated when accessed later.

To re-evaluate a variable, define it inside a function and call the function from wherever you want to access the current value of the variable.

For example, in the module you might create a function to return True if the W key is pressed:

import bge

def is_w_active():
    return(bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.WKEY])

Then when this is called from a script (or anywhere else) like so:

import bge, keyboardmodule

print(keyboardmodule.is_w_active())

it will return True or False accordingly.

Source Link
gandalf3
  • 158.3k
  • 60
  • 612
  • 1.1k

This appears to because the module will only be executed once. Variables assigned directly inside the module will retain their initial value and won't be re-evaluated when accessed later.

To re-evaluate a variable, define it inside a function and call the function from wherever you want to access the current value of the variable.

For example, in the module you might create a function to return True if the W key is pressed:

import bge

def is_w_active():
    return(bge.logic.KX_INPUT_ACTIVE == bge.logic.keyboard.events[bge.events.WKEY])

Then when this is called from a script (or anywhere else) like so:

import bge, keyboardmodule

print(keyboardmodule.is_w_active())

it will return True or False accordingly.

http://blend-exchange.giantcowfilms.com/embedImage.png?bid=420