TK kill line in Mudlet

Currently using mudlet and having an issue.

^suffering (\d+) burst blood vessels\.$  (Set to perl regex)

if matches[2] >= "12" then

send("psi id heartburst " .. target)

else

send("psi id throatlock " .. target)

end


If the target as 1 vessel, it'll throatlock.  If it has 2 or more, it'll heartburst.  Now, I'm no mathematician, but I don't think 2 is >= 12.  :(

Best Answer

Answers

  • edited March 2013
    Remove the quotes around 12.  The captured text is a string.  You're performing a string comparison in your example, rather than a number comparison.  By removing the quotes, Lua will automatically coerce the captured string (matches[2]) to a number value.

  • Even without the quotes, it wasn't working.
  • Rightio. I'll try that out tomorrow night. Thanks!
  • edited March 2013
    Huh.

    Try:

    if tonumber(matches[2]) >= 12 then

    send("psi id heartburst " .. target)

    else

    send("psi id throatlock " .. target)

    end


    Er, ninja'd.


  • Yup, that should fix it.  In the future you should know that the table values returned by triggers in mudlet are strings, so if you ever want to use them as numbers, you gotta tonumber(matches[x]) them.

    :D Good luck!
    Take great care of yourselves and each other.
Sign In or Register to comment.