Moving From zMUD

Sloan
Posts: 11
Joined: Sat Apr 07, 2018 3:23 pm

Moving From zMUD

Post by Sloan »

I have been a longtime user of zMUD and have many triggers, variables I need to convert and need some help.

In zMUD I have two variables, the first is a simple string called Tank and I set that to whomever the tank in my group is.

The other variable is called AutoAssist and it's a string like this

{crushes|who|misses|sends|strikes|slashes|pierces|massacres|barely|slightly|pounds|hits|backstabs|wounds|injures|mauls|obliterates|bites}

So then I have a trigger that is @Tank @AutoAssist makes me assist tank, such as assist Bob. I then disable this trigger until the is dead! thing pops up or something that notifies me the battle is over.

I am having a hard time finding the proper way to convert this to use in mudlet. Any help would be appreciated.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Moving From zMUD

Post by Jor'Mox »

As far as I know there is no way to put a variable into a trigger pattern in the way that you could with zMUD, so you will have to use a more generic trigger pattern and then check what text it captures against your variable to see if it is a match. In this case, unless there is some reason you NEED to have the "AutoAssist" text in a variable, I would make a trigger pattern like this:

Code: Select all

^(\w+) (crushes|who|misses|sends|strikes|slashes|pierces|massacres|barely|slightly|pounds|hits|backstabs|wounds|injures|mauls|obliterates|bites)
[note that I don't know if you want the ^ character to anchor to the beginning of the line or not, so leave it off if needed, also, in case that isn't clear, that is supposed to all be one line... it is just really long.]

Then in the code block for the trigger, just add a simple if statement, like so:

Code: Select all

if matches[2] == Tank then
   send("assist " .. Tank)
   disableTrigger("Full Exact Name of Trigger HERE")
end
Whatever triggers you have in place to turn the trigger back on would obviously then use enableTrigger with the correct trigger name to enable it again when you need to.

Sloan
Posts: 11
Joined: Sat Apr 07, 2018 3:23 pm

Re: Moving From zMUD

Post by Sloan »

Could you show me where in the trigger UI i put each of those expressions you gave me? Does the if statement go in the command? And the other go in one of the lines below?

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Moving From zMUD

Post by Jor'Mox »

The pattern I gave goes in the box labeled "1", found just below the box for the name, and you need to change the dropdown box just to the right of it to "perl regex". The code goes in the large, unlabeled box at the bottom. The Command box remains blank, and is only ever used when you want to send fixed plain text.

Sloan
Posts: 11
Joined: Sat Apr 07, 2018 3:23 pm

Re: Moving From zMUD

Post by Sloan »

Thanks for helping here is the trigger I have. It doesn't seem to be firing.
Capture2.PNG
Here is the MUD window, I would expect assist Sloan to be sent to the MUD.
Capture3.PNG
Capture3.PNG (24.55 KiB) Viewed 21416 times

Sloan
Posts: 11
Joined: Sat Apr 07, 2018 3:23 pm

Re: Moving From zMUD

Post by Sloan »

Sorry I had Tank and needed Tank1 instead. I am going to have multiple people to add in order to autoassist, do I need a new trigger for each of them or is there a way to create a list for the Tank variable?

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Moving From zMUD

Post by Jor'Mox »

It is pretty simple to make and use a list for what you are talking about. Your list would need to be a table (if you need help constructing a table in Lua let me know, and I can explain what is needed), and you would simply check if the name the trigger captured was in the table or not, and then send the appropriate command to assist the named person. I would do it like this:

Code: Select all

local index = table.index_of(Tank_table, matches[2])
if index then
   send("assist " .. Tank_table[index])
   disableTrigger("AutoAssist1")
end

Sloan
Posts: 11
Joined: Sat Apr 07, 2018 3:23 pm

Re: Moving From zMUD

Post by Sloan »

Do I need to store the table in the variables? Does it just get created in the trigger code? Is there a way to quickly change what's in this table from the command line? So let's say I have three people in the table and want to quicly change can I do something like TankList=Bill,Bob

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Moving From zMUD

Post by Jor'Mox »

The table does need to be stored in a variable. I think the easiest way to make quick changes to the list would be to make an alias for that purpose. To do so, I would use a pattern like this for the alias: ^tanklist (.*)$
And then code like so:

Code: Select all

TankList = string.split(matches[2],"[ ,]+")
print("Tank List set to: " .. table.concat(TankList,", "))
Using that, you can quickly set your list, separating names with any combination of spaces and/or commas. If you wanted, you could also force the names to all have their first letter capitalized, so that you wouldn't have to type the names that way each time. That might look like this:

Code: Select all

TankList = string.split(matches[2],"[ ,]+")
for k,v in ipairs(TankList) do
    TankList[k] = string.title(v)
end
print("Tank List set to: " .. table.concat(TankList,", "))
Alternatively, you could use the "lua" alias included with new profiles that lets you execute arbitrary code from the command line, like so:
lua TankList = {"Bill","Bob","Frank"}

Sloan
Posts: 11
Joined: Sat Apr 07, 2018 3:23 pm

Re: Moving From zMUD

Post by Sloan »

Okay thanks I now believe the auto assist is working as intended. I really appreciate the help. How do I make it so that the triggers and aliases I put on one character apply to all the others? I play up to 3 at a time on one MUD.

Post Reply