Weird error from alias

Posted by Xandler on Sun 13 Jun 2021 03:06 PM — 3 posts, 12,499 views.

#0
Not sure quite where to post this, if this is the wrong spot, please move it to the correct area. Anyway, to my error.

I recently made an alias for withdraw/deposit on a mud I play, and sometimes when I'm chatting with people, I get strange errors: for example it errored on this and the message it gave is below that.

snet any good mobs with kame beside bardock and the prison guard?


Run-time error
World: Dragonball Evolution
Immediate execution
[string "Alias: "]:1: attempt to perform arithmetic on global 'kame' (a nil value)
stack traceback:
        [string "Alias: "]:1: in main chunk



I know it's due to this particular alias because I disabled it and typed that it went through re-enabled and it didn't.

The alias(es) is as follows:


<aliases>
  <alias
   match="(with|dep) (.*?)b"
   enabled="y"
   expand_variables="y"
   group="withdraw/deposit"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Send ("%1 " .. (%2 * 10000000))</send>
  </alias>
  <alias
   match="(with|dep) (.*?)m"
   enabled="y"
   expand_variables="y"
   group="withdraw/deposit"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Send ("%1 " .. (%2 * 1000000))</send>
  </alias>
  <alias
   match="bid (.*?)m"
   enabled="y"
   expand_variables="y"
   group="withdraw/deposit"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Send ("bid " .. (%1 * 1000000))</send>
  </alias>
</aliases>


Can anyone tell me how I can fix this random error, or how to better write an alias for this?
Amended on Sun 13 Jun 2021 07:56 PM by Nick Gammon
Australia Forum Administrator #1
Quote:


any good mobs with kame beside bardock and the prison guard?
              ^^^^^^^^^^^



The line you sent matches the alias for withdraw/deposit. You need to make the alias more specific, such as making it match on, say, "!withdraw". Or you could test the wildcard 2 and see if it is a number.

Or maybe make the "with" part match the start of the line, eg.


^(with|dep) (.*?)b


Now it won't match "with" in the middle of a line.

And make it match numbers, and nothing after the "b" like this:


^(with|dep) ([0-9]+)b$
Amended on Sun 13 Jun 2021 10:39 PM by Nick Gammon
#2
Awesome, thanks for the reply! I will try both of your solutions to see if that makes it foolproof.