Inherited types and objects referring to themselves

Slent
19 Sept 2013, 13:11Hello all
I am currently working on making some object types which would make me able to inherit attributes on appropriate objects. One of these object types should always have an equip verb, calling an equip command. This command requires that the object itself is being passed to it by the object running the command through the verb (I hope that is clearly formulated
).
The problem comes when I have inherited this object type. If I on the object type try to call the function and pass on the "<object_type_name>" in the function, when I run the function on the object that inherited this type, it simply states that it cannot find <object_type_name>, instead of searching for the new objects name, which inherit the object type (still hope you're with me - it's hard to formulate
).
Therefore I got to thinking; when referring to the player object we can use game.pov. Is there a similar command just to use on objects? I've tried to search around for something, but haven't been able to find a solution. If I've overlooked a wiki or forum thread/post about it, can you direct me there?
If this is not possible, is there another way to solve this problem? I could just not have the verb and function set on the object type, I just thought it would be handier if it was 
Thanks!
I am currently working on making some object types which would make me able to inherit attributes on appropriate objects. One of these object types should always have an equip verb, calling an equip command. This command requires that the object itself is being passed to it by the object running the command through the verb (I hope that is clearly formulated

The problem comes when I have inherited this object type. If I on the object type try to call the function and pass on the "<object_type_name>" in the function, when I run the function on the object that inherited this type, it simply states that it cannot find <object_type_name>, instead of searching for the new objects name, which inherit the object type (still hope you're with me - it's hard to formulate

Therefore I got to thinking; when referring to the player object we can use game.pov. Is there a similar command just to use on objects? I've tried to search around for something, but haven't been able to find a solution. If I've overlooked a wiki or forum thread/post about it, can you direct me there?


Thanks!
The Pixie
19 Sept 2013, 14:00If you have a script attached to an object, you can refer to that object inside the script with the word "this".

Slent
19 Sept 2013, 14:06Well, that was easy, thanks! I don't know why I didn't try only this. I tried object.this, inherited_object.this etc. but never only this.
HegemonKhan
19 Sept 2013, 23:54as Pixie said, you can use "this" which will become defined to whatever is the script's parent object, which makes it work well with being a script attribute for your Object Type.
and just to use it in scripting, for example:
Object.Attribute
..^
..V
this.Attribute
this.strength
this.alias
etc...
"this" is used instead of the object's name, but will get that (parent) object for the script.
the "this" pointer acts like a "GetObject" function, but only for its script attribute's parent object.
and just to use it in scripting, for example:
Object.Attribute
..^
..V
this.Attribute
this.strength
this.alias
etc...
"this" is used instead of the object's name, but will get that (parent) object for the script.
the "this" pointer acts like a "GetObject" function, but only for its script attribute's parent object.

jaynabonne
20 Sept 2013, 09:03Keep in mind once you get deeper into coding - especially if you start calling your own scripts - that the "this" variable only comes in when you call a script via "do":
do (someobject, "somescript")
That's how Quest assigns the "this" param (someobject, in this case). If you call a script with:
invoke(somescript)
then there will not be a "this" variable. That might be a bit subtle, but I wanted to try to be clear about where "this" comes from. It's not so much an attribute of the script as it is a result of how the script it called.
do (someobject, "somescript")
That's how Quest assigns the "this" param (someobject, in this case). If you call a script with:
invoke(somescript)
then there will not be a "this" variable. That might be a bit subtle, but I wanted to try to be clear about where "this" comes from. It's not so much an attribute of the script as it is a result of how the script it called.

Slent
20 Sept 2013, 10:12That is very true jayna, and something to keep in mind when working on more complex code 
