Author Topic: Converting a DamageType into a number?  (Read 2010 times)

Well, I want to compare a user-entered damage type in string form (ex. "Sword") then make it a number so I can compare it in the onDeath's %damageType. %damageType is a number and the user-entered type is a string. How can I convert one of them to the other so I can compare?

1) Do a check for all the 'ProjectileData' in the 'DataBlockGroup'
2) Get the DamageType from all of them
3) Check to see if the number input and the damageType number match
4) Return it :)

Thats a 'cheap' way to do it but thats the only way I know how to do it.

Since you know everything that is valid for them to be typing in as teh string you could just use a block to translate that into the corresponding number.

$DamageType::[%string]

It uses Torque's weird "Arrays" functions, allowing you to convert %string (Self Delete, Sword, etc) into $DamageType::Self Delete, $DamageType::Sword, etc.

Thanks, I used Space Guys method, works great!

Erm.. I thought you meant to get all the numbers they returned... Oops.