[Bf-committers] game engine / python controller: get actuator by name, broken in
2.34?
Toni Alatalo
bf-committers@blender.org
Tue, 10 Aug 2004 09:48:20 +0300 (EEST)
greetings.
has something changed in the python controller component of the game
engine in 2.34? when <levon> was trying out a system i've made, it gave an
error: TypeError: argument 1 must be KX_GameObject, not str initmover
self.animate_act1 = self.controller.getActuator("animate1")
checking the documentation, there still is 'def getActuator(name): @type
name: string'. resorting back to the source, in SCA_PythonController.cpp
SCA_PythonController::PyGetActuator seems correct to me (but i can hardly
read c++, and would certainly miss lurking bugs in it).
trying to trace back for changes, there seems that something has been done
with at least GetSensors in version 1.6, 2004/05/26 12:09:17 .. but that
does seem quite like it
(http://projects.blender.org/viewcvs/viewcvs.cgi/blender/source/gameengine/GameLogic/SCA_PythonController.cpp.diff?r1=1.5&r2=1.6&cvsroot=bf-blender)
as far as i can see, the current relevant code (where i see no
problems) is: (is the input perhaps type-checked somewhere earlier?)
---cut-from: gameengine/GameLogic/SCA_PythonController.cpp ---
char SCA_PythonController::GetActuator_doc[] =
"GetActuator (char sensorname) return linked actuator that is named
[actuatorname]\n";
PyObject*
SCA_PythonController::PyGetActuator(PyObject* self,
PyObject*
args,
PyObject*
kwds)
{
char *scriptArg;
if (!PyArg_ParseTuple(args, "s", &scriptArg)) {
return NULL;
}
for (unsigned int index=0;index<m_linkedactuators.size();index++)
{
SCA_IActuator* actua = m_linkedactuators[index];
STR_String realname = actua->GetName();
if (realname == scriptArg)
{
return actua->AddRef();
}
}
PyErr_SetString(PyExc_AttributeError, "Unable to find requested
actuator");
return NULL;
}
---end---
hopefully this report is useful, apologies if there is stupidity.
this problems is pretty severe for me, as it makes 2.34 completely
unusable for this system and i know of no sensible workarounds (definitely
don't want to get the ordered list of sensors, and then references by list
index). fortunately, i just yesterday decided to delay the release of the
app.,, that was originally planned for August, for other reasons (need to
refactor the core a bit). (in case someone's interested, the app and docs
can be found from http://studio.kyperjokki.fi/engine/KyperMover )
otherwise, thanks and and congratulations for a great new release! can't
wait to get into the new possibilities.
~Toni
btw: Kester, have you done anything / some thoughts about the
passing object references to actuators -issue that we discussed some time
ago? i afterwards rembered that the problem is preventing the use of
camera/tarck-to actuators also in my system (not only in that of a
friend). my understanding was that satisfactory and feasible solutions
were found, but guess that no-one just hasn't implemented them yet. or
have you, and it is even related to this other problem now?-o
P.S. in another VJing system, by <Pildanovak>, there is another problem
occurring in 2.34 (also discovered by <levon>, who posted about it to
http://www.blender.org/modules.php?op=modload&name=phpBB2&file=viewtopic&t=3202&postdays=0&postorder=asc&start=30
). he's doing own.position = own.position+(velocity / 20) .. somewhere,
and somehow before that the own.position has become a list, instead a
number, in 2.34 so it gives "TypeError: can only concatenate list (not
"float") to list". he's using messages to control the speed of an ipo.