| Methods: |
| getDistribution |
setFloatNegativeExponential |
| getPara1 |
setFloatNormal |
| getPara2 |
setFloatUniform |
| getProperty |
setIntConst |
| getSeed |
setIntPoisson |
| setBoolBernouilli |
setIntUniform |
| setBoolConst |
setProperty |
| setBoolUniform |
setSeed |
| setFloatConst |
---------- |
|
Inherited
Methods: |
| getExecutePriority |
isA |
| getOwner |
setExecutePriority |
| getName |
---------- |
|
|
getDistribution
getDistribution()
Returns the type of distribution.
Return type: integer
1 = Bool Constant
2 = Bool Uniform
3 = Bool Bernouilli
4 = Int Constant
5 = Int Uniform
6 = Int Poisson
7 = Float Constant
8 = Float Uniform
9 = Float Normal
10 = Float Neg. Exp.
Sample
Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# get distribution method
distrib = actRandom.getDistribution()
getPara1
getPara1()
Returns the first parameter for the distribution being used.
Bool Constant:
Return Type:
bool
1.0 = True
0.0 = False
Bool Uniform:
Return Type:
float
0.0
(first parameter doesn't exist)
Bool Bernouilli:
Return
Type: bool
bool (1.0 or 0.0)
entered in 'Chance'.
Int Constant:
Return
Type: integer
number entered
in 'Value'.
Int Uniform:
Return
Type: integer
number entered in
'Min".
Int Poisson:
Return
Type: integer
number entered in
'Mean'.
Float Constant:
Return
Type: float
number entered
in 'Value'.
Float Uniform:
Return
Type: float
number entered in
'Min".
Float Normal:
Return
Type: float
number entered in
'Mean'.
Float Neg. Exp.:
Return
Type: float
number entered in
'Half-life Time'
Sample
Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# get 1st parameter
paraFirst = actRandom.getPara1()
getPara2
getPara2()
Returns the second parameter for the distribution being used.
Bool Constant:
Return
Type: bool
0.0 (second
parameter doesn't exist)
Bool Uniform:
Return
Type: bool
0.0
(second parameter doesn't exist)
Bool Bernouilli:
Return
Type: bool
0.0
(second parameter doesn't exist)
Int Constant:
Return
Type: integer
0.0
(second parameter doesn't exist)
Int Uniform:
Return
Type: integer
Returns number
entered in 'Max".
Int Poisson:
Return
Type: integer
0.0
(second parameter doesn't exist)
Float Constant:
Return
Type: float
0.0
(second parameter doesn't exist)
Float Uniform:
Return
Type: float
Returns number
entered in 'Max".
Float Normal:
Return
Type: float
Returns number
entered in 'SD'.
Float Neg. Exp.:
Return
Type: float
0.0
(second parameter doesn't exist)
Sample
Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# get 2nd parameter
paraSecond = actRandom.getPara2()
getProperty
getProperty()
Returns the name of the property to set.
Return type: string
Sample
Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# get property
prop = actRandom.getProperty()
getSeed
getSeed()
Return the initial seed the generator uses.
Return type: integer
Sample
Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# get initial seed
seed = actRandom.getSeed()
setBoolBernouilli
setBoolBernouilli(value)
Sets random generator to produce bool using a Bernouilli distribution.
value:
Type:
float.
Range 0.0 to 1.0
value is the
'chance' of generating True.
0.0 will
alway generate True.
1.0 will always generate False.
Sample
Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# set boolbernouilli
actRandom.setBoolBernouilli(0.25)
setBoolConst
setBoolConst(value)
Set the generator to produce a constant bool value
value:
Type: Bool.
True or 1 = always True Bool value
False or 0 = always False Bool value
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# always use True
actRandom.setBoolConst(True)
setBoolUniform
setBoolUniform()
Sets the generator to produce a uniform bool distribution.
A 50/50 chance to be True or False.
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# 50/50 chance to be true or false.
actRandom.setBoolUniform()
setFloatConst
setFloatConst(value)
Sets a value to always be generated.
value:
Type: float
range: 0.0 to 1.0
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# set constant value
actRandom.setFloatConst(0.75)
setFloatNegativeExponential
setFloatNegativeExponential(half_life)
Set the generator to generate negative_exponentially distributed
numbers.
half_life:
Type: float
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# generate negative_exponentially distributed numbers
actRandom.setFloatNegativeExponential(8.5)
setFloatNormal
setFloatNormal(mean, standard_deviation)
Generates a random float from the given normal distribution.
mean:
Type: float
The mean (average) value of the generated numbers.
standard_deviation:
Type: float
The standard deviation of the generated numbers
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# generate a random float from the given normal
distribution
actRandom.setFloatNormal(3.0, 6.0)
setFloatUniform
setFloatUniform(lower_bound, upper_bound)
Generates a random float between upper and lower bounds (max and min)
with a uniform distribution
lower_bound:
Type: float
upper_bound:
Type: float
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# generate a random float between min and max
actRandom.setFloatUniform(3.0, 6.0)
setIntConst
setIntConst(value)
Set the generator to always produce this value.
value:
Type:
integer
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# generate a set value of 6
actRandom.setIntConst(6)
setIntPoisson
setIntPoisson(value)
Generates a Poisson distributed number.
value:
Type: float
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# generate a Poisson distributed number
actRandom.setIntPoisson(3.0)
setIntUniform
setIntUniform(lower_bound, upper_bound)
Generates a random between the upper and lower bounds (inclusive).
lower_bound:
Type:
integer
upper_bound:
Type:
integer
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# generate a Poisson distributed number
actRandom.setIntUniform( 1, 6)
setProperty
setProperty(property)
Sets the property to which the random value is assigned.
property:
Type:
string
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# assign to dice
actRandom.setProperty("dice")
setSeed
setSeed(seed)
Sets the seed of the random number generator.
seed:
Type:
integer
Note:
If seed is 0, the generator will return the same value
on every call.
Equal seeds return equal series.
Sample Code
#get controller
controller = GameLogic.getCurrentController()
# get random actuator named act
actRandom = controller.getActuator("act")
# set seed
actRandom.setSeed(4)
getExecutePriority
getExecutePriority()
Gets the execute priority of the logic brick
Return Type: integer
Doesn't
work:
Crashes Blender
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the actuator named act
act = controller.getActuator("act")
# get brick priority
priority = act.getExecutePriority()
getOwner
getOwner()
Gets the game object that owns the logic brick.
Return Type: KX_GameObject
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the actuator named act
act = controller.getActuator("act")
# get brick owner
owner = act.getOwner()
setExecutePriority
setExecutePriority(priority)
Sets the execution priority of the logic brick.
priority:
Type: integer
0 is first
1 is second
etc.
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the actuator named act
act = controller.getActuator("act")
# set brick priority to be first
act.setExecutePriority(0)
isA
isA(Type)
Checks the Object type.
(KX_GameObject,
SCA_ILogicBrick, KX_Scene, etc.)
Type: String
Return Type: Bool
1 = True
0 = False
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get the object controller attached to
owner = controller.getOwner()
# is owner a GameObject?
gameObject = owner.isA("KX_GameObject")
getName
getName()
Returns the name of actuator
Return Type: string
Sample Code
# get the controller
controller = GameLogic.getCurrentController()
# get a list of the attached actuators
actList = controller.getActuators()
# loop through the list of actuators
for act in actList:
# look for an
actuator named "RocketMotion"
if act.getName() ==
"RocketMotion":
# use it
GameLogic.addActiveActuator(act,
True)
# Done.
Break out of loop
break
|