Random Example:
mob/var/string = "Hello" |
I know in java you have to use .equals. Is there something syntax based I have to include/change or should I go about doing this a different way?
ID:818213
Jun 16 2012, 8:42 am (Edited on Jun 16 2012, 10:38 am)
(See the best response by Kaiochao.)
|
||
How can I compare a text string to a variable in an if statement
Random Example:
I know in java you have to use .equals. Is there something syntax based I have to include/change or should I go about doing this a different way? | ||
#2 Jun 16 2012, 10:40 am
|
||
The problem is whether I run
I get a runtime error that says: Wrong type of value for list | ||
#3 Jun 16 2012, 10:46 am
|
|
Could you provide a more complete example? You're obviously doing something wrong, but not here. (well, you're missing an end-paren after your cmptext() as well as the () after 'response' in your first example, but I'm sure there could be something else)
| |
#4 Jun 16 2012, 10:53 am
|
|||
Basically I have a proc that checks a var that a player has. If the var equals a value I gave it in a string it should give the player a verb.
I also tried
I figured ^ didnt work possibly because the first parameter of cmptext was a var and not something in text but I could be wrong | |||
The only problem I see with this code is the () after the verb path. It's just a path, so you're not calling anything.
| |
#6 Jun 16 2012, 11:05 am
|
|
Your right it was the mistake of putting () on the end. Thanks
| |
e.g. true == (1 == 1) == ("blah" == "blah")
Of course, == is case-sensitive with strings, so you can use a different method to compare. Look up the cmptext() and cmptextEx() proc in the DM Reference. An alternative would be to compare the lowertext() or uppertext() of both strings, but cmptext() is probably a much better way.