Page 1 of 1
Help with another alias please...
Posted: Sun Sep 09, 2018 6:02 pm
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...
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!
Re: Help with another alias please...
Posted: Sun Sep 09, 2018 8:53 pm
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:
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
table.insert(consent_tbl,matches[2])
Then whatever your dragging alias would look like this:
local cmd = matches[2]
for k,v in ipairs(consent_tbl) do
cmd = string.format("drag %s %s", v, cmd)
end
send(cmd)
Re: Help with another alias please...
Posted: Mon Sep 10, 2018 2:25 am
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?
Re: Help with another alias please...
Posted: Mon Sep 10, 2018 10:59 am
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:
if matches[2] ~= "my name" then
table.insert(consent_tbl,matches[2])
end