From cf6ed235784c6b5658fe53a2e52199ac87263b5c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Jun 2009 07:42:03 +0000 Subject: [PATCH] BGE small fixes - script template use new property syntax - Python could set the axis/hat to a negative index and crash blender (nobody complained) - Servo control UI had overlapping text --- release/scripts/scripttemplate_gamelogic.py | 10 +++++----- source/blender/src/buttons_logic.c | 2 +- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release/scripts/scripttemplate_gamelogic.py b/release/scripts/scripttemplate_gamelogic.py index 8711783a5f8..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' """ @@ -82,10 +82,10 @@ def main(): 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() diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 9fb6ec4752b..6a14bbaec6c 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1864,7 +1864,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh } uiDefBut(block, LABEL, 0, "Servo", xco, yco-152, 45, 19, NULL, 0, 0, 0, 0, "Coefficients of the PID servo controller"); uiDefButF(block, NUMSLI, B_REDR, "P: ", xco+45, yco-152, wval*3, 19, oa->forcerot, 0.00, 200.0, 100, 0, "Proportional coefficient, typical value is 60x Integral coefficient"); - uiDefBut(block, LABEL, 0, "Slow", xco, yco-152, 45, 19, NULL, 0, 0, 0, 0, "Low value of I coefficient correspond to slow response"); + uiDefBut(block, LABEL, 0, "Slow", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Low value of I coefficient correspond to slow response"); but = uiDefButF(block, NUMSLI, B_REDR, " I : ", xco+45, yco-171, wval*3, 19, oa->forcerot+1, 0.0, 3.0, 1, 0, "Integral coefficient, low value (0.01) for slow response, high value (0.5) for fast response"); uiButSetFunc(but, update_object_actuator_PID, oa, NULL); uiDefBut(block, LABEL, 0, "Fast", xco+45+3*wval, yco-171, 45, 19, NULL, 0, 0, 0, 0, "High value of I coefficient correspond to fast response"); diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 16061d6fb6e..336529667d7 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -392,6 +392,8 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* args ) { } m_axis = axis; m_axisf = axisflag; + + CheckAxis((void *)this, NULL); /* clamp values */ Py_RETURN_NONE; } @@ -533,6 +535,8 @@ PyObject* SCA_JoystickSensor::PySetHat( PyObject* args ) { } m_hat = hat; m_hatf = hatflag; + + CheckHat((void *)this, NULL); /* clamp values */ Py_RETURN_NONE; }