Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Syrik
Newbie


Joined: 11 Dec 2010
Posts: 4
Location: Kansas

PostPosted: 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 :)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: 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!
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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!
Reply with quote
Syrik
Newbie


Joined: 11 Dec 2010
Posts: 4
Location: Kansas

PostPosted: 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!
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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.
Reply with quote
Syrik
Newbie


Joined: 11 Dec 2010
Posts: 4
Location: Kansas

PostPosted: 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?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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"
Reply with quote
Syrik
Newbie


Joined: 11 Dec 2010
Posts: 4
Location: Kansas

PostPosted: Sun Dec 12, 2010 12:54 pm   
 
ok, thank you so much!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net