Help with another alias please...

Post Reply
Vooku
Posts: 72
Joined: Sun Aug 21, 2016 2:42 pm

Help with another alias please...

Post by Vooku »

How would set this up? I would like an alias to drag dead player corpses from a room. I need 'consent' from a player to be able to drag them. Typing 'consent' gives me this list...
Code: [show] | [select all] lua
You have consented to Ssoman.

Muzovaple is consenting you.
Ssoman is consenting you.
Nilan is consenting you.
Mapnanemar is consenting you.
Talomis is consenting you.
The format to drag a player is "drag <player name> <direction>. To drag multiple players it would be "drag <player 1> drag <player 2> drag <player 3> <direction>".

How would I capture the names in the list about and place them in the format I need to drag them?

Thanks in advance!

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

Re: Help with another alias please...

Post by Jor'Mox »

Okay, so first, you want an alias for the "consenting" command, which will reset a table you will use to track the people, and turn on a trigger to capture the names, like so:
Code: [show] | [select all] lua
consent_tbl = {}
-- you can name the trigger whatever you want, but this has to match it exactly
enableTrigger("Consenting Names Trigger")
send("consenting")
-- you can name the trigger whatever you want, but this has to match it exactly
tempTimer(5,[[disableTrigger("Consenting Names Trigger")]]) -- this turns your trigger off after 5 seconds, so you don't get spurious matches
Then your trigger will capture the names, using a pattern like this: ^(\w+) is consenting you
Code: [show] | [select all] lua
table.insert(consent_tbl,matches[2])
Then whatever your dragging alias would look like this:
Code: [show] | [select all] lua
local cmd = matches[2]
for k,v in ipairs(consent_tbl) do
    cmd = string.format("drag %s %s", v, cmd)
end
send(cmd)

Vooku
Posts: 72
Joined: Sun Aug 21, 2016 2:42 pm

Re: Help with another alias please...

Post by Vooku »

Awesome! Works great! Only one issue tho. It seems the consent list always has my name at the top. When I do the drag command the mud does not like me trying to drag my own corpse (which doesn't exist). Any easy way to have my name removed from the table when I capture the other names?

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

Re: Help with another alias please...

Post by Jor'Mox »

Sure, just add an if statement to your trigger (assuming your name is being added to the list by that), like so:
Code: [show] | [select all] lua
if matches[2] ~= "my name" then
    table.insert(consent_tbl,matches[2])
end

Post Reply