There have been a few times that I've tried to use a wildcard which picked up text. However, whenever I've tried to use the corresponding variable, MUSHclient always said something about comparing numbers and text. Is there a way to use text in ifchecks?
Variables using text
Posted by Terry on Wed 30 Jan 2008 12:06 PM — 7 posts, 33,612 views.
Can you provide us with a short example, e.g. using the plugin wizard to extract one trigger with the code you try to use?
Here is an example of the error:
You can convert strings to numbers. Wildcards in triggers and aliases are returned as strings, so they must be converted under certain circumstances.
In some cases Lua can deduce what is required by the operator, eg:
print ("5" > 6) --> Error: attempt to compare number with string
You can convert strings to numbers. Wildcards in triggers and aliases are returned as strings, so they must be converted under certain circumstances.
print (tonumber ("5") > 6) --> false
In some cases Lua can deduce what is required by the operator, eg:
print ("5" + 2) --> 7
Words of warning: Make sure to check for sane values before converting a string into a number. Ordinarily, coercion is automatic, so if your script is throwing an error, it might just be due to bad data.
Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio
> =tonumber( 9 )
9
> =tonumber( "9" )
9
> =tonumber( "F" )
nil
> =tonumber( "1,000" )
nil
> =tonumber( nil )
nil
> = tonumber( "F" ) > 9
stdin:1: attempt to compare number with nil
stack traceback:
stdin:1: in main chunk
[C]: ?
>
Agreed.
However if you use a regular expression in your trigger, and make sure that the wildcard in question must be a sequence of numeric digits, then you have eliminated that problem.
However if you use a regular expression in your trigger, and make sure that the wildcard in question must be a sequence of numeric digits, then you have eliminated that problem.
I was talking about having strings compared to strings. Like if %1 = "billy" or something. Is that possible?
See http://www.mushclient.com/faq point 32.