Random Sensor: lastDraw

lastDraw
  • Returns the last random number generated

Type: 
  • integer
Random Sensor:
  • If the seed is 0, the generator will produce the same value on every call.
  • Sends random pulses to the controller(s).
  • One positive pulse is immediately followed by a negative pulse.
Sample Code


################  Get the last random number generated.

# import bge module
import bge

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

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

sen = cont.sensors["Shuffle"]

# get the last random number
num = sen.lastDraw