Game Development Community

Drownin' Code

by Jookia · in Torque Game Engine · 04/17/2007 (3:20 pm) · 4 replies

Hello again, my code below just gives a simple error that it can not find the getposition command for the %obj.

function Armor::onEnterLiquid(%this, %obj, %coverage, %type)
{
switch(%type)
{
case 0: //Water
case 1: //Ocean Water
case 2: //River Water
case 3: //Stagnant Water
case 4: //Lava
%obj.setDamageDt(%this, $DamageLava, "Lava");
case 5: //Hot Lava
%obj.setDamageDt(%this, $DamageHotLava, "Lava");
case 6: //Crusty Lava
%obj.setDamageDt(%this, $DamageCrustyLava, "Lava");
case 7: //Quick Sand
}

if(getword(%obj.getPosition(), 2) - getword(%this.getPosition(), 2) >= 5)
{
%obj.kill("Drown");
}
}

#1
04/17/2007 (4:08 pm)
Which is because the method getPosition doesn't exist. Try getTransform instead.

Gary (-;
#2
04/17/2007 (4:40 pm)
Also, two questions. 'Ow do I get a nickname between the words of my GarageGames forum name? Also, why does " action = (mVelocity.len() < 0.5) ? PlayerData::CrouchAnim : PlayerData::CrouchForwardAnim : PlayerData::CrouchBackAnim : PlayerData::CrouchSideAnim;" get a syntax error?

Player.cs: Unknown command getTransform. "if(getword(%obj.getTransform(), 2) - getword(%this.getTransform(), 2) >= 5)"
#3
04/17/2007 (5:05 pm)
The nickname thing, I did long long long ago, and I think the parser has changed since then. So no idea.


" action = (mVelocity.len() < 0.5) ? PlayerData::CrouchAnim : PlayerData::CrouchForwardAnim : PlayerData::CrouchBackAnim : PlayerData::CrouchSideAnim;"

Because instead of having something of the form
conditional?statement:statement;
Yours is in the form:
assignment(conditional)?statement:statement:statement;
Admittedly, the assignment *should* do something useful, but it's a horrible and obfuscated way of doing that. And in torquescript, doing an assignment may not qualify as a conditional in the sense of returning what you think it's going to return. Don't do it.

Additionally, %this.getTransform() will be being called on an Armor object. Not sure how sensible that is.

Gary (-;
#4
04/17/2007 (5:10 pm)
How do I add different moves to my crouch? I only have forward and I followed the tutorial in the other thread.

I also fixed the player thing by myself by rephasing "action = (mVelocity.len() < 0.5) ? PlayerData::CrouchAnim : PlayerData::CrouchForwardAnim : PlayerData::CrouchBackAnim : PlayerData::CrouchSideAnim;" into "action = (mVelocity.len() < 0.5) ? PlayerData::CrouchAnim : PlayerData::CrouchForwardAnim , PlayerData::CrouchBackAnim, PlayerData::CrouchSideAnim;".