Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/scripttemplate_gamelogic.py')
-rw-r--r--release/scripts/scripttemplate_gamelogic.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/release/scripts/scripttemplate_gamelogic.py b/release/scripts/scripttemplate_gamelogic.py
index 01348e86d0a..577847c0dda 100644
--- a/release/scripts/scripttemplate_gamelogic.py
+++ b/release/scripts/scripttemplate_gamelogic.py
@@ -1,7 +1,7 @@
#!BPY
"""
Name: 'GameLogic Example'
-Blender: 245
+Blender: 249
Group: 'ScriptTemplate'
Tooltip: 'Script template with examples of how to use game logic'
"""
@@ -29,63 +29,63 @@ def main():
cont = GameLogic.getCurrentController()
# The KX_GameObject that owns this controller.
- own = cont.getOwner()
+ own = cont.owner
# for scripts that deal with spacial logic
- own_pos = own.getPosition()
+ own_pos = own.worldPosition
# Some example functions, remove to write your own script.
# check for a positive sensor, will run on any object without errors.
- print 'Logic info for KX_GameObject', own.getName()
+ print 'Logic info for KX_GameObject', own.name
input = False
- for sens in cont.getSensors():
+ for sens in cont.sensors:
# The sensor can be on another object, we may want to use it
- own_sens = sens.getOwner()
- print ' sensor:', sens.getName(),
- if sens.isPositive():
+ own_sens = sens.owner
+ print ' sensor:', sens.name,
+ if sens.positive:
print '(true)'
input = True
else:
print '(false)'
- for actu in cont.getActuators():
+ for actu in cont.actuators:
# The actuator can be on another object, we may want to use it
- own_actu = actu.getOwner()
- print ' actuator:', actu.getName()
+ own_actu = actu.owner
+ print ' actuator:', actu.name
# This runs the actuator or turns it off
# note that actuators will continue to run unless explicitly turned off.
if input:
- GameLogic.addActiveActuator(actu, True)
+ cont.activate(actu)
else:
- GameLogic.addActiveActuator(actu, False)
+ cont.deactivate(actu)
- # Its also good practice to get sensors and actuators by names
- # so any changes to their order wont break the script.
+ # Its also good practice to get sensors and actuators by name
+ # rather then index so any changes to their order wont break the script.
- # sens_key = cont.getSensor('key_sensor')
- # actu_motion = cont.getActuator('motion')
+ # sens_key = cont.sensors['key_sensor']
+ # actu_motion = cont.actuators['motion']
# Loop through all other objects in the scene
sce = GameLogic.getCurrentScene()
- print 'Scene Objects:', sce.getName()
- for ob in sce.getObjectList():
- print ' ', ob.getName(), ob.getPosition()
+ print 'Scene Objects:', sce.name
+ for ob in sce.objects:
+ print ' ', ob.name, ob.worldPosition
# Example where collision objects are checked for their properties
# adding to our objects "life" property
"""
- actu_collide = cont.getSensor('collision_sens')
- for ob in actu_collide.getHitObjectList():
+ actu_collide = cont.sensors['collision_sens']
+ for ob in actu_collide.objectHitList:
# Check to see the object has this property
- if hasattr(ob, 'life'):
- own.life += ob.life
- ob.life = 0
- print own.life
+ if ob.has_key('life'):
+ own['life'] += ob['life']
+ ob['life'] = 0
+ print own['life']
"""
main()