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:
authorCampbell Barton <ideasman42@gmail.com>2009-10-31 22:31:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-10-31 22:31:45 +0300
commitf9b19d54b5a07c5d654ecb634aefc5690e07e6fd (patch)
tree746a80208ae1b0a3b98c678af45d37fe26c28325 /release/scripts/templates
parentaf72bb50ae41f5ba1f9f5b2310b2aee77907fecf (diff)
tabs to spaces, remove trailing white space. (apart of pep8)
didnt do "release/scripts/io" since some exporters cant be auto converted
Diffstat (limited to 'release/scripts/templates')
-rw-r--r--release/scripts/templates/gamelogic.py126
-rw-r--r--release/scripts/templates/gamelogic_basic.py20
-rw-r--r--release/scripts/templates/gamelogic_module.py18
-rw-r--r--release/scripts/templates/operator.py74
-rw-r--r--release/scripts/templates/operator_simple.py28
5 files changed, 133 insertions, 133 deletions
diff --git a/release/scripts/templates/gamelogic.py b/release/scripts/templates/gamelogic.py
index af9dbd8a56a..8bfe799bacf 100644
--- a/release/scripts/templates/gamelogic.py
+++ b/release/scripts/templates/gamelogic.py
@@ -4,75 +4,75 @@
# GameLogic has been added to the global namespace no need to import
# for keyboard event comparison
-# import GameKeys
+# import GameKeys
# support for Vector(), Matrix() types and advanced functions like AngleBetweenVecs(v1,v2) and RotationMatrix(...)
-# import Mathutils
+# import Mathutils
# for functions like getWindowWidth(), getWindowHeight()
# import Rasterizer
def main():
- cont = GameLogic.getCurrentController()
-
- # The KX_GameObject that owns this controller.
- own = cont.owner
-
- # for scripts that deal with spacial logic
- 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.name
- input = False
-
- for sens in cont.sensors:
- # The sensor can be on another object, we may want to use it
- own_sens = sens.owner
- print ' sensor:', sens.name,
- if sens.positive:
- print '(true)'
- input = True
- else:
- print '(false)'
-
- for actu in cont.actuators:
- # The actuator can be on another object, we may want to use it
- 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:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
-
- # 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.sensors['key_sensor']
- # actu_motion = cont.actuators['motion']
-
-
- # Loop through all other objects in the scene
- sce = GameLogic.getCurrentScene()
- 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.sensors['collision_sens']
- for ob in actu_collide.objectHitList:
- # Check to see the object has this property
- if ob.has_key('life'):
- own['life'] += ob['life']
- ob['life'] = 0
- print own['life']
- """
+ cont = GameLogic.getCurrentController()
+
+ # The KX_GameObject that owns this controller.
+ own = cont.owner
+
+ # for scripts that deal with spacial logic
+ 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.name
+ input = False
+
+ for sens in cont.sensors:
+ # The sensor can be on another object, we may want to use it
+ own_sens = sens.owner
+ print ' sensor:', sens.name,
+ if sens.positive:
+ print '(true)'
+ input = True
+ else:
+ print '(false)'
+
+ for actu in cont.actuators:
+ # The actuator can be on another object, we may want to use it
+ 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:
+ cont.activate(actu)
+ else:
+ cont.deactivate(actu)
+
+ # 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.sensors['key_sensor']
+ # actu_motion = cont.actuators['motion']
+
+
+ # Loop through all other objects in the scene
+ sce = GameLogic.getCurrentScene()
+ 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.sensors['collision_sens']
+ for ob in actu_collide.objectHitList:
+ # Check to see the object has this property
+ if ob.has_key('life'):
+ own['life'] += ob['life']
+ ob['life'] = 0
+ print own['life']
+ """
main()
diff --git a/release/scripts/templates/gamelogic_basic.py b/release/scripts/templates/gamelogic_basic.py
index c9c2a594309..5e7d19672fe 100644
--- a/release/scripts/templates/gamelogic_basic.py
+++ b/release/scripts/templates/gamelogic_basic.py
@@ -1,15 +1,15 @@
def main():
- cont = GameLogic.getCurrentController()
- own = cont.owner
-
- sens = cont.sensors['mySensor']
- actu = cont.actuators['myActuator']
-
- if sens.positive:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
+ cont = GameLogic.getCurrentController()
+ own = cont.owner
+
+ sens = cont.sensors['mySensor']
+ actu = cont.actuators['myActuator']
+
+ if sens.positive:
+ cont.activate(actu)
+ else:
+ cont.deactivate(actu)
main()
diff --git a/release/scripts/templates/gamelogic_module.py b/release/scripts/templates/gamelogic_module.py
index 1bc221e727d..5a61a3592dc 100644
--- a/release/scripts/templates/gamelogic_module.py
+++ b/release/scripts/templates/gamelogic_module.py
@@ -13,14 +13,14 @@ import GameLogic
# with multiple objects.
def main(cont):
- own = cont.owner
-
- sens = cont.sensors['mySensor']
- actu = cont.actuators['myActuator']
-
- if sens.positive:
- cont.activate(actu)
- else:
- cont.deactivate(actu)
+ own = cont.owner
+
+ sens = cont.sensors['mySensor']
+ actu = cont.actuators['myActuator']
+
+ if sens.positive:
+ cont.activate(actu)
+ else:
+ cont.deactivate(actu)
# dont call main(GameLogic.getCurrentController()), the py controller will
diff --git a/release/scripts/templates/operator.py b/release/scripts/templates/operator.py
index c03d5850237..3e9e65f13f8 100644
--- a/release/scripts/templates/operator.py
+++ b/release/scripts/templates/operator.py
@@ -1,46 +1,46 @@
import bpy
def write_some_data(context, path, use_some_setting):
- pass
+ pass
from bpy.props import *
class ExportSomeData(bpy.types.Operator):
- '''This appiers in the tooltip of the operator and in the generated docs.'''
- bl_idname = "export.some_data" # this is important since its how bpy.ops.export.some_data is constructed
- bl_label = "Export Some Data"
-
- # List of operator properties, the attributes will be assigned
- # to the class instance from the operator settings before calling.
-
- # TODO, add better example props
- path = StringProperty(name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= "")
- use_some_setting = BoolProperty(name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True)
-
- def poll(self, context):
- return context.active_object != None
-
- def execute(self, context):
- if not self.is_property_set("path"):
- raise Exception("filename not set")
-
- write(self.path, context, use_setting, SOME_SETTING = self.use_some_setting)
-
- return ('FINISHED',)
-
- def invoke(self, context, event):
- wm = context.manager
-
- if True:
- # File selector
- wm.add_fileselect(self.__operator__) # will run self.execute()
- return ('RUNNING_MODAL',)
- else if 0:
- # Redo popup
- wm.invoke_props_popup(self.__operator__, event) #
- return ('RUNNING_MODAL',)
- else if 0:
- return self.execute(context)
+ '''This appiers in the tooltip of the operator and in the generated docs.'''
+ bl_idname = "export.some_data" # this is important since its how bpy.ops.export.some_data is constructed
+ bl_label = "Export Some Data"
+
+ # List of operator properties, the attributes will be assigned
+ # to the class instance from the operator settings before calling.
+
+ # TODO, add better example props
+ path = StringProperty(name="File Path", description="File path used for exporting the PLY file", maxlen= 1024, default= "")
+ use_some_setting = BoolProperty(name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True)
+
+ def poll(self, context):
+ return context.active_object != None
+
+ def execute(self, context):
+ if not self.is_property_set("path"):
+ raise Exception("filename not set")
+
+ write(self.path, context, use_setting, SOME_SETTING = self.use_some_setting)
+
+ return ('FINISHED',)
+
+ def invoke(self, context, event):
+ wm = context.manager
+
+ if True:
+ # File selector
+ wm.add_fileselect(self.__operator__) # will run self.execute()
+ return ('RUNNING_MODAL',)
+ else if 0:
+ # Redo popup
+ wm.invoke_props_popup(self.__operator__, event) #
+ return ('RUNNING_MODAL',)
+ else if 0:
+ return self.execute(context)
bpy.ops.add(ExportSomeData)
@@ -52,4 +52,4 @@ menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
# Use for running this script directly
if __name__ == "__main__":
- bpy.ops.export.some_data(path="/tmp/test.ply") \ No newline at end of file
+ bpy.ops.export.some_data(path="/tmp/test.ply")
diff --git a/release/scripts/templates/operator_simple.py b/release/scripts/templates/operator_simple.py
index f0f4b104950..b19ce981833 100644
--- a/release/scripts/templates/operator_simple.py
+++ b/release/scripts/templates/operator_simple.py
@@ -1,20 +1,20 @@
def main(context):
- for ob in context.scene.objects:
- print(ob)
-
+ for ob in context.scene.objects:
+ print(ob)
+
class SimpleOperator(bpy.types.Operator):
- ''''''
- bl_idname = "object.simple_operator"
- bl_label = "Simple Object Operator"
-
- def poll(self, context):
- return context.active_object != None
-
- def execute(self, context):
- main(context)
- return ('FINISHED',)
+ ''''''
+ bl_idname = "object.simple_operator"
+ bl_label = "Simple Object Operator"
+
+ def poll(self, context):
+ return context.active_object != None
+
+ def execute(self, context):
+ main(context)
+ return ('FINISHED',)
bpy.ops.add(SimpleOperator)
if __name__ == "__main__":
- bpy.ops.object.simple_operator()
+ bpy.ops.object.simple_operator()