Hello. I'm a nonprogrammer trying to understand Mudlet's treatment of MyEnemies. It says to declare the variable MyEnemies as
MyEnemies = {}
My first question is about where to declare this. My first thought was in "Scripts", but so far this hasn't worked for me.
I have a parallel question about calling the Lua function "table.insert( listName, item )".
table.insert( myEnemies, "Tom" )
table.insert( myEnemies, "Jim" )
Where do I do this? (In "Aliases", or what?) I'm guessing "Aliases", because you're told to set up a pattern, "^add (.*) enemy"
A final question. How do you display the list using
Display { MyEnemies }
I guess I'm asking how to run a script.
Thank you for helping my with these basic questions.
Felix
Tables as Lists
Re: Tables as Lists
Hi - yeah, you do it in scripts. Make a new one and put MyEnemies = {} in. It will create/reset the table whenever the script is run (on Mudlet load and when you save it).
Yes, you'd use table.insert whenever you'd like to insert. So in an alias, since matches[2] would be the name, you would use table.insert(MyEnemies, matches[2]). Note the same capitalization of MyEnemies - it matters.
display(MyEnemies) will display it.
Yes, you'd use table.insert whenever you'd like to insert. So in an alias, since matches[2] would be the name, you would use table.insert(MyEnemies, matches[2]). Note the same capitalization of MyEnemies - it matters.
display(MyEnemies) will display it.