Blockland Forums
Home
Help
Login
Register
Blockland Forums
»
Blockland Forums
»
Modification Help
»
Converting a DamageType into a number?
« previous
next »
Print
Pages: [
1
]
Author
Topic: Converting a DamageType into a number? (Read 2009 times)
Aloshi
June 26, 2007, 10:09:12 AM
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?
Ad Bot
Advertisement
Terror
June 26, 2007, 10:47:34 AM
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.
Anti-Cop
June 26, 2007, 11:00:08 AM
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.
Space Guy
June 26, 2007, 11:08:26 AM
$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.
Aloshi
June 26, 2007, 12:40:18 PM
Thanks, I used Space Guys method, works great!
Terror
June 26, 2007, 01:24:41 PM
Erm.. I thought you meant to get all the numbers they returned... Oops.
Print
Pages: [
1
]
« previous
next »
Blockland Forums
»
Blockland Forums
»
Modification Help
»
Converting a DamageType into a number?