Keyboard Sensor: toggleProperty

toggleProperty:
  • gets/sets the name of the Bool property that you added.
     
  • Keyboad Sensor Name: Log Toggle

Type: 
  • string

Bool Property that you added:

  • Bool = True = All keystrokes will be saved as a string to the Target (string variable).
     
  • Bool = False = Keystrokes won't be saved.
Keyboard Sensor:
  • When the selected key is pressed, it sends one positive pulse to the connected controller(s).
     
  • When the selected key is released, it sends one negative pulse to the connected controller(s).
Sample Code


################  Get name of the Bool property Log Toggle is using

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Gas

sen = cont.sensors["Gas"]

# get the Bool property name
toggle_name = sen.toggleProperty
 
Sample Code


################  Set name of Bool Property for Log Toggle to use

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Gas

sen = cont.sensors["Gas"]

# set Log Toggle name
# my Bool Property name is Key_Log_Switch

sen.toggleProperty = "Key_Log_Switch"