|
Syrik Newbie
Joined: 11 Dec 2010 Posts: 4 Location: Kansas
|
Posted: Sat Dec 11, 2010 3:34 am
Help converting a script from Lua to zmud |
Ok I have this trigger in mudlet:
prompt: (\w+) tells you 'command:(.+)' <---- perl regex
Script:
commanders = { "<insert any name here>" } <--- these are manually inserted into the script
if table.contains( commanders, matches[2] ) then
send( matches[3] )
end
A friend wants this script for zmud, anyone now how to put this into zmud script? Thanks :) |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Sat Dec 11, 2010 6:04 am |
It seems straightforward enough. We need some additional information though.
What does the send command do, (I'm assuming it just sends the test to the MUD?)
What about the matches table? What does it contain?
FYI for you and your friend, CMUD now has built-in support for Lua scripts, so I would recommend that he/she consider since zMUD is at EOL. |
|
_________________ Asati di tempari! |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Dec 11, 2010 9:07 am |
Honestly, just seems like it's a string list that lists people able to send commands, then executes the command if it matches... so your script would look like this:
Code: |
#REGEX {(\w+) tells you 'command:(.+)'} {#IF (%ismember(%1, @commanders)) {#EXEC {%2}} |
Then you can add items to the commanders list via #ADDITEM:
#ADDITEM commanders "Charneus"
Hope this helps! |
|
|
|
Syrik Newbie
Joined: 11 Dec 2010 Posts: 4 Location: Kansas
|
Posted: Sat Dec 11, 2010 5:31 pm |
Ok, I don't know zmud code at all, Sorry! But:
prompt: (\w+) tells you 'command:(.+)' <---- perl regex the (\w+) captures whatever name and becomes, matches[2]. The (.+) is matches[3] and it can be anything.
Script:
commanders = { "<insert any name here>" } <--- these are manually inserted into the script
if table.contains( commanders, matches[2] ) then <---- the matches[2] is the sender of the tell and this line runs it by the commanders table to make
sure that its ok to send the command.
send( matches[3] ) <--- this sends the part after the "command:" to the mud.
end
I hope this helps, thank you soo much! |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Dec 11, 2010 6:28 pm |
Yeah, use what I put up there, Syrik.
Then follow what I said about adding items (names) to the commanders list. |
|
|
|
Syrik Newbie
Joined: 11 Dec 2010 Posts: 4 Location: Kansas
|
Posted: Sun Dec 12, 2010 6:16 am |
Ok, thanks!
So how does the #ADDITEM work? Would I just type in something, or would it be put into the script? |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sun Dec 12, 2010 10:47 am |
Well, you can type #ADDITEM Commanders "<name>" each time you want to add a name, or you can make an alias such as:
Code: |
#ALIAS addcom {#ADDITEM Commanders %1} |
To start out though, if you have a long list of commanders, you can do the shorthand and type:
Code: |
commanders="Charneus|Syrik|Tech|Zugg|Whoever|Whatever" |
|
|
|
|
Syrik Newbie
Joined: 11 Dec 2010 Posts: 4 Location: Kansas
|
Posted: Sun Dec 12, 2010 12:54 pm |
ok, thank you so much!
|
|
|
|
|
|