difference between %this, %obj in the scripts
by Gabe Zingaretti · in Technical Issues · 01/29/2003 (11:14 am) · 6 replies
Hi all,
could anyone tell me the differnece between %this and %obj in the scripts?
thanks,
Gabe
could anyone tell me the differnece between %this and %obj in the scripts?
thanks,
Gabe
About the author
#2
function CrossbowImage::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;
// Decrement inventory ammo. The image's ammo state is update
// automatically by the ammo inventory hooks.
%obj.decInventory(%this.ammo,1);
...
..
...
what about if I do %obj.decInventory(%obj.ammo,1); instead
thanks,
Gabe
01/29/2003 (11:44 am)
thanks so let me understand here is a junk of code:function CrossbowImage::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;
// Decrement inventory ammo. The image's ammo state is update
// automatically by the ammo inventory hooks.
%obj.decInventory(%this.ammo,1);
...
..
...
what about if I do %obj.decInventory(%obj.ammo,1); instead
thanks,
Gabe
#4
The real question you are asking is, what do the different parts of the arguments in onFire mean.
First (%this) is the datablock (the crossbow)
The second (%obj) is the player holding the crossbow
The third is, obviously, the slot.
You can't take %this to mean datablock ALL the time, however. I've seen %this be used to represent an object (not a datablock) in a some function somewhere ( I think it was a collision one)
01/29/2003 (12:06 pm)
%obj and %this aren't internal names, they mean wherever they've been put.The real question you are asking is, what do the different parts of the arguments in onFire mean.
First (%this) is the datablock (the crossbow)
The second (%obj) is the player holding the crossbow
The third is, obviously, the slot.
You can't take %this to mean datablock ALL the time, however. I've seen %this be used to represent an object (not a datablock) in a some function somewhere ( I think it was a collision one)
#5
Thanks,
Gabe
01/29/2003 (1:40 pm)
thanks now it makes more sense...one quick question onFire(...) where does this method get define in the C code. I couldn't find it.Thanks,
Gabe
#6
the ShapeBase object has a state array
and this is one of the functions scripted to be called by it
01/29/2003 (3:43 pm)
yea its a little nasty...the ShapeBase object has a state array
and this is one of the functions scripted to be called by it
Torque Owner Badguy
but I would hope that
%this represents the script class you are working with and obj represents the actual object that owns the datablock reference
example:
PlayerData::somefunction(%this, %obj)
%this would be the datablock and %obj would be the actual Player class