Alias causes mudlet to close (crash) [SOLVED]

Post Reply
sickasabat
Posts: 2
Joined: Wed Apr 21, 2010 1:27 am

Alias causes mudlet to close (crash) [SOLVED]

Post by sickasabat »

Hello, this is my first post because I've found an error with mudlet.

I have set up a global variable (variable outside function) in scripts. I have created it thus:

Code: Select all

moves = {}
I then have an alias which checks for n,s,e or w being pressed. If it occurs I add it to moves and then output it to the server like this:

Pattern: ^n|s|e|w
Substitution: matches[0]

Code: Select all

function move()
                  listadd(moves, matches[0])
                  return true
          end
But when I type anything that matches the pattern, mudlet closes down. Can anyone think why?

thanks
Last edited by sickasabat on Wed Apr 21, 2010 1:49 am, edited 1 time in total.

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Alias causes mudlet to close (crash)

Post by naftali »

You need to look at www.lua.org/manual/5.1/manual.html to see what lua functions work in Mudlet. Dunno what you're used to, but search on that page for table.insert, that's the function you need. No idea what listadd() is.

sickasabat
Posts: 2
Joined: Wed Apr 21, 2010 1:27 am

Re: Alias causes mudlet to close (crash)

Post by sickasabat »

According to the manual you can use listAdd(list, item)

http://mudlet.git.sourceforge.net/git/g ... ml;hb=HEAD

edit: I've realised I'm using "listadd()" not "listAdd()". Changing this stops it crashing.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Alias causes mudlet to close (crash)

Post by tsuujin »

Well, there's a problem with your pattern.

It should read:
^(n|e|s|w)

The vertical bar does represent an "or", but doesn't work unless grouped in parenthesis.

Honestly, though, I use this:
^[neswud]{1.2}$

^ = "start of line"
[,] = "a range of possible characters"
{1,2} = "one or two of anything from the previous group"
$ = "end of line"

This will get all of your directions, save in or out. I do have one to get in or out, but I'll save that from you because it's a bit more complex.

Next, you are calling a function "listadd". Does this exist? have you defined it? I think what you really want is table.add(moves,matches[1])

Also, instead of using the Substitution line, you can just add
send(matches[1])
below the table entry.

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Alias causes mudlet to close (crash) [SOLVED]

Post by naftali »

listAdd() is indeed listed in the manual. There is indeed a function defined by that name. It appears to work like a less versatile version of table.insert(). Won't be using that any time soon.

On the other hand, the other two related functions look interesting. listPrint() prints a list in a slightly more listy format than display(), and listRemove() removes the named element from the list - THAT could certainly come in handy.

Post Reply