SimObjects can't be deleted in script anymore?
by William Hilke · in Torque 2D Beginner · 02/12/2013 (10:42 pm) · 5 replies
In the new codebase there is a guard added to SimObject::deleteObject()
the guard is set/unset in Con::execute() with this:
Isn't that basically setting a guard around every script function called? How are we to delete SimObjects now?
// Sanity!
AssertISV( getScriptCallbackGuard() == 0, "SimObject::deleteObject: Object is being deleted whilst performing a script callback!" );the guard is set/unset in Con::execute() with this:
object->pushScriptCallbackGuard();
SimObject *save = gEvalState.thisObject;
gEvalState.thisObject = object;
const char *ret = ent->execute(argc, argv, &gEvalState);
gEvalState.thisObject = save;
object->popScriptCallbackGuard();Isn't that basically setting a guard around every script function called? How are we to delete SimObjects now?
#2
02/13/2013 (9:07 am)
So what is the correct way to delete SimObjects from TorqueScript then?
#3
The guard is only on if trying to delete a SimObject from within the execution of a script function of that same SimObject.
You can ignore my other question :).
02/13/2013 (9:37 am)
I understand what's going on now, not sure why I wasn't seeing it before.The guard is only on if trying to delete a SimObject from within the execution of a script function of that same SimObject.
You can ignore my other question :).
#4
02/13/2013 (9:50 am)
Cool. Glad you got it.
#5
02/13/2013 (6:17 pm)
I guess if a SimObject needs to suicide, you should schedule a call to delete. That way the delete will happen outside the function call, when the event queue is evaluated.
Employee Michael Perry
ZombieShortbus