Op_create_object & Registerobject()
by Lateral Punk · in Torque Game Engine · 11/14/2006 (8:25 pm) · 2 replies
So I fell upon this strange bug where the callback to a guictrl::onAdd to script wasn't working for my PlayGui. Basically PlayGui.gui is exec'd during startup, but it seems that inside of
const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, const char **argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
under the case OP_CREATE_OBJECT, a call to currentNewObject->registerObject() is missing. And as a result, onAdd is not being called.
Am I to understand that OP_CREATE_OBJECT is called for .gui instantiated objects & OP_ADD_OBJECT is used for .cs instantiated ones? I would think we want registerObject() to be called for .gui scripts too no?
Am i missing something?
const char *CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, const char **argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
under the case OP_CREATE_OBJECT, a call to currentNewObject->registerObject() is missing. And as a result, onAdd is not being called.
Am I to understand that OP_CREATE_OBJECT is called for .gui instantiated objects & OP_ADD_OBJECT is used for .cs instantiated ones? I would think we want registerObject() to be called for .gui scripts too no?
Am i missing something?
#2
thanks for the response. Can you explain then why a script callback to Playgui::onAdd(%this) does not happen then? Try putting that script funciton into your project, and put an echo statement, let me know if you see the echo.
11/15/2006 (9:47 am)
Hey Tom,thanks for the response. Can you explain then why a script callback to Playgui::onAdd(%this) does not happen then? Try putting that script funciton into your project, and put an echo statement, let me know if you see the echo.
Torque 3D Owner Tom Bampton
Regardless of where in script you create an object, OP_CREATE_OBJECT does the new, then fields, other objects, etc are set with seperate opcodes, then OP_ADD_OBJECT is called to actually register it.
This is the correct way to do it and you will cause big problems by registering the object in OP_CREATE_OBJECT.
T.