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-05-26 11:41:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-26 11:41:34 +0400
commit7ba91ddcc37bbc8cd6c417e588d7ca7a3bb65e24 (patch)
treea48e47d95c8ebf987ff561ddc38d3542d5a35e37 /release/scripts
parent5f82855a07eb1cfbb89aba654c9c8f7da1544c5b (diff)
BGE Script template for a python module (set EOL to native this time)
BGE PyAPI use defines for error return values - del gameOb['var'] error message was wrong.
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/scripttemplate_gamelogic_module.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/release/scripts/scripttemplate_gamelogic_module.py b/release/scripts/scripttemplate_gamelogic_module.py
new file mode 100644
index 00000000000..2ef4950917b
--- /dev/null
+++ b/release/scripts/scripttemplate_gamelogic_module.py
@@ -0,0 +1,45 @@
+#!BPY
+"""
+Name: 'GameLogic Module'
+Blender: 249
+Group: 'ScriptTemplate'
+Tooltip: 'Basic template for new game logic modules'
+"""
+
+from Blender import Window
+import bpy
+
+script_data = \
+'''
+# This module can be accessed by a python controller with
+# its execution method set to 'Module'
+# * Set the module string to "gamelogic_module.main" (without quotes)
+# * When renaming the script it MUST have a .py extension
+# * External text modules are supported as long as they are at
+# the same location as the blendfile or one of its libraries.
+
+import GameLogic
+
+# variables defined here will only be set once when the
+# module is first imported. Set object spesific vars
+# inside the function if you intend to use the module
+# 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)
+
+# dont call main(GameLogic.getCurrentController()), the py controller will
+'''
+
+new_text = bpy.data.texts.new('gamelogic_module.py')
+new_text.write(script_data)
+bpy.data.texts.active = new_text
+Window.RedrawAll()