Here's my simplified code:
import bge from bge import logic cont = logic.getCurrentController() own = cont.owner keyboard = bge.logic.keyboard input_just_activated = bge.logic.KX_INPUT_JUST_ACTIVATED primary_input_key = "SPACEKEY" p = "bge.events." + primary_input_key primary_input = keyboard.events[p] if primary_input == input_just_activated: print("it worked!")
As the code suggests, I am trying to print "it worked!" into the console by keyboard input. It works when using
keyboard.events[bge.events.SPACEKEY] as it is in its proper form, but when I change it to
"bge.events." + primary_input_key it seems that it changes its form, making it no longer working. How can I have a string be converted to fit the game-engine's logic's keyboard input's form?