From: <au...@us...> - 2011-03-28 02:10:48
|
Revision: 8095 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8095&view=rev Author: auria Date: 2011-03-28 02:10:42 +0000 (Mon, 28 Mar 2011) Log Message: ----------- Added skeleton of script to convert BGE logic properties to the new Blende 2.5 per-object ID-properties. This script is incomplete, I basically save it here as backup Added Paths: ----------- media/trunk/convert_form_game_logic.py Added: media/trunk/convert_form_game_logic.py =================================================================== --- media/trunk/convert_form_game_logic.py (rev 0) +++ media/trunk/convert_form_game_logic.py 2011-03-28 02:10:42 UTC (rev 8095) @@ -0,0 +1,86 @@ +# THIS IS A SKELETON, NEEDS TO BE COMPLETE + +# This script must be assigned to a python controller +# where it can access the object that owns it and the sensors/actuators that it connects to. + +import bge +import bpy + +# support for Vector(), Matrix() types and advanced functions like Matrix.Scale(...) and Matrix.Rotation(...) +# import mathutils + +# for functions like getWindowWidth(), getWindowHeight() +# import Rasterizer + + +def main(): + cont = bge.logic.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, end=' ') + 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 = bge.logic.getCurrentScene() + print('Scene Objects:', sce.name) + for ob in sce.objects: + print(' ', ob.name, ob.worldPosition) + + has_type = False + try: + print("Type =",ob["type"]) + has_type = True + except: + pass + + if has_type: + bpy.data.objects[ob.name]['type'] = ob['type'] + + # 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() Property changes on: media/trunk/convert_form_game_logic.py ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |