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.
//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.
About the author
#2
//now i make a new object
new t2dSceneObject(LizardMan)
{
$maxSpeed ="100";
Class = "Heroe";
}
Hope that helps
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
Torque Owner Samuel Weeks