Problem adding "attributes" to the Player class. NEED HELP.
by Austin Zurfluh · in Torque 3D Professional · 03/06/2012 (1:03 pm) · 3 replies
Basically, I'm attempting to add "attributes" to the player class, (Such as strength and whatnot). And I'm having trouble exposing the variables to script.
This is what I have so far... everything compiles fine, but I'm not sure/able to access "updateFortitude()" from script. Right now, I'm trying to call it from within GameConnection::onConnect, then using the command
But I get the error "scripts/server/gameCore.cs (281): Unknown command updateFortitude.
This is what I have so far... everything compiles fine, but I'm not sure/able to access "updateFortitude()" from script. Right now, I'm trying to call it from within GameConnection::onConnect, then using the command
%client.updateFortitude(10)
But I get the error "scripts/server/gameCore.cs (281): Unknown command updateFortitude.
bool Player::updateFortitude(F32 value)
{
fortitude += value;
F32 oldF = fortitude;
if(fortitude < 10)
return false;
Con::printf("Added 10 to fortitude!nFortitude was: %d and is now: %d", oldF, fortitude);
return true;
}
DefineEngineMethod( Player, updateFortitude, bool, ( S32 arg1 ),,"empty for now")
{
return object->updateFortitude(arg1);
}About the author
I currently attend Eastern Washington University, and work as a Web Application Developer. I spend a lot of my free time playing with Torque 3D, for the company I've co-founded, Rynade Software.
#2
%client.getControlObject().updateFortitude() might work assuming the player is your control object.
03/06/2012 (2:44 pm)
%client isn't a player object most likely...it's probably a ClientConnection object.%client.getControlObject().updateFortitude() might work assuming the player is your control object.
#3
That makes me look a little foolish. hahaha.
Anyway, thanks for your speedy reply, and help!
Could you explain or point me to somewhere to read about how the client and player objects interact, and such?
03/06/2012 (4:10 pm)
Oh I got it working now.That makes me look a little foolish. hahaha.
Anyway, thanks for your speedy reply, and help!
Could you explain or point me to somewhere to read about how the client and player objects interact, and such?
Associate Scott Burns
GG Alumni