Is my understanding correct?
by Aaron Forsman · in Torque Game Engine · 12/28/2002 (1:34 am) · 1 replies
Hello, I purchased the SDK a couple days ago, and since then I've been messing around with it as much as I can. From the start, I was more interested in the coding aspect of the engine, rather than the scripting part, and it took a little bit to wrap my head around the concept of how the engine was able to have the script control all the gameplay.
Anyway, I've got a few questions about how the engine works inside. I'm stumped about the onAdd() method, specifically what the object was supposed to do there, and when it was called. I looked a little deeper and found (from what I could tell) that the only time the onAdd method is actually called is in the SimObject::registerObject method, and the only time that isn't invoked specifically on an object, is in the CodeBlock::exec method, in the switch statement, with case OP_ADD_OBJECT. So, now here is my current understanding... in the script files, when a new object is created, like when a player joins a server, the script calls %player = new player() { ... } etc etc. Is that when the engine reads the OP_ADD_OBJECT and then calls registerObject, and then calls onAdd? If so, then thats cool, I can continue onto other things. If not, does anyone feel like explaining it?
So now back to the first part of my problem... what is it supposed to do there? Is that where constructor-like stuff would go, but would only work if the object was registered with the engine?
I know this is getting a little long, but I just need a couple clarifications on terminology... mount and image. From my understanding, a mount is where things can be added to a model? like a gun could be added to a mount on a ship or something? and when I think of image, I think of a bitmap image or something, but is it considered like a model or something? Sometimes when reading discussions, the typical definition of mount and image doesn't seem to make sense. Would it make sense to say 'I'm going to mount the gun image onto the ship image'? Am I on the right track here?
Sorry about the length, hopefully you made it this far.
Anyway, I've got a few questions about how the engine works inside. I'm stumped about the onAdd() method, specifically what the object was supposed to do there, and when it was called. I looked a little deeper and found (from what I could tell) that the only time the onAdd method is actually called is in the SimObject::registerObject method, and the only time that isn't invoked specifically on an object, is in the CodeBlock::exec method, in the switch statement, with case OP_ADD_OBJECT. So, now here is my current understanding... in the script files, when a new object is created, like when a player joins a server, the script calls %player = new player() { ... } etc etc. Is that when the engine reads the OP_ADD_OBJECT and then calls registerObject, and then calls onAdd? If so, then thats cool, I can continue onto other things. If not, does anyone feel like explaining it?
So now back to the first part of my problem... what is it supposed to do there? Is that where constructor-like stuff would go, but would only work if the object was registered with the engine?
I know this is getting a little long, but I just need a couple clarifications on terminology... mount and image. From my understanding, a mount is where things can be added to a model? like a gun could be added to a mount on a ship or something? and when I think of image, I think of a bitmap image or something, but is it considered like a model or something? Sometimes when reading discussions, the typical definition of mount and image doesn't seem to make sense. Would it make sense to say 'I'm going to mount the gun image onto the ship image'? Am I on the right track here?
Sorry about the length, hopefully you made it this far.
Torque Owner J. Donavan Stanley
As for what it should do.. At a minimum it should call Parent::OnAdd(), as well as perform any initilization based on it's persistant fields.