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
This commit is contained in:
2009-06-04 07:42:03 +00:00
parent 06fe5deaec
commit cf6ed23578
3 changed files with 10 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
#!BPY #!BPY
""" """
Name: 'GameLogic Example' Name: 'GameLogic Example'
Blender: 245 Blender: 249
Group: 'ScriptTemplate' Group: 'ScriptTemplate'
Tooltip: 'Script template with examples of how to use game logic' Tooltip: 'Script template with examples of how to use game logic'
""" """
@@ -82,10 +82,10 @@ def main():
actu_collide = cont.sensors['collision_sens'] actu_collide = cont.sensors['collision_sens']
for ob in actu_collide.objectHitList: for ob in actu_collide.objectHitList:
# Check to see the object has this property # Check to see the object has this property
if hasattr(ob, 'life'): if ob.has_key('life'):
own.life += ob.life own['life'] += ob['life']
ob.life = 0 ob['life'] = 0
print own.life print own['life']
""" """
main() main()

View File

@@ -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"); 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"); 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"); 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); 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"); 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");

View File

@@ -392,6 +392,8 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* args ) {
} }
m_axis = axis; m_axis = axis;
m_axisf = axisflag; m_axisf = axisflag;
CheckAxis((void *)this, NULL); /* clamp values */
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@@ -533,6 +535,8 @@ PyObject* SCA_JoystickSensor::PySetHat( PyObject* args ) {
} }
m_hat = hat; m_hat = hat;
m_hatf = hatflag; m_hatf = hatflag;
CheckHat((void *)this, NULL); /* clamp values */
Py_RETURN_NONE; Py_RETURN_NONE;
} }