Game Development Community

Need help using classes in script.

by Samuel Weeks · in Torque Game Builder · 03/08/2008 (4:16 pm) · 2 replies

Hi, i cant seem how to use classes in my script. can someone plz review my code and tell me what im doing wrong

//first i make a new datablock
datablock t2dSceneObjectDatablock(heroe
{
classname = SuperPowers;
};


//now i make a new object
new t2dSceneObject(LizardMan)
{
$maxSpeed ="100";
datablock = Heroe;
}


//this is the function that is scoped to SuperPowers
SuperPowers::Activate()
{
echo("Powers are active");
}

new t2dSceneObject(player:LizardMan)
{
$life = "250";
}

this is a mock version of my game code, although the fields from lizard do copy over to the player object , neither the class or the datablock seem to pass on. i really need help with this thx.

#1
03/08/2008 (5:25 pm)
Ok i did some more reseach and it seems in tgb, you use class to set classes not classname. but i still hvae 1 problem. it cant understand why the datablock isnt being passed to the other objects, any ideas?
#2
03/09/2008 (5:51 am)
You need to use the keyword Class not datablock:

//now i make a new object
new t2dSceneObject(LizardMan)
{
$maxSpeed ="100";
Class = "Heroe";
}

Hope that helps