Page 1 of 3

how-to

Posted: Wed Apr 25, 2018 3:06 pm
by khiren
Hi guys, I am pretty new to the mudlet and I am struggling with one simple thing (used to be simple in tintin++)...not sure if it's possible here.

So, I've created trigger which does following:
trigger capture
^You join (.*)'s group.$
trigger output
leader = matches[2]

Now I have variable leader set, and I am trying to re-use it other trigger string capture, but I am failing badly.
trigger capture
^@leader orders all his followers to '(.*)'.$
trigger output
send ("order all" .. matches[2])

Please help.

Re: how-to

Posted: Thu Apr 26, 2018 4:07 am
by Vadi
@leader isn't a Mudlet thing - use (\w+) instead, and check that variable against the one you saved, so:
Code: [show] | [select all] lua
if matches[2] == leader then
  send("order all "..matches[3])
end

Re: how-to

Posted: Thu Apr 26, 2018 5:24 am
by Brenex
and here is an example from my script where I make new triggers using parts from other triggers. This is basically what you are asking how to do. You can see how matches[3] is being grabbed from the trigger line and permBeginOfLineStringTrigger makes a new trigger with the contents of matches[3] in it.

Code: Select all

local trigger_name  = matches[3].." (Venom)"

permBeginOfLineStringTrigger(trigger_name, "Venom Wipe Triggers", {[[Being careful not to poison yourself, you wipe off all the venoms from ]]..matches[3]}, [[
  nightfallUI.Combat.venomed_weapons["]]..matches[3]..[["] = nil
  disableTrigger("]]..trigger_name..[[")
  ]])

Re: how-to

Posted: Thu Apr 26, 2018 9:24 am
by khiren
Thank you both for quick reply. I will play around a bit today :)

Re: how-to

Posted: Sun Apr 29, 2018 2:34 pm
by khiren
Another thing with alias.

I have alias with this pattern
^spells (.*)$

output of alias
if (matches[2] == NIL) then
send ("abil -l spell ")
else
send ("abil -l spell " ..matches[2])
end

basically I want to test on the fly if there is something in matches[2] or not. Alias works only when I put something after spells (for example spells ranger).

Please help :)

Re: how-to

Posted: Sun Apr 29, 2018 4:23 pm
by nesferatu
Have you tried:
if(matches[2] == "")
?

Re: how-to

Posted: Sun Apr 29, 2018 4:52 pm
by khiren
nesferatu wrote:
Sun Apr 29, 2018 4:23 pm
Have you tried:
if(matches[2] == "")
?
I just tested it now and it doesn't work.

Re: how-to

Posted: Sun Apr 29, 2018 5:08 pm
by Jor'Mox
Try this. Pattern: ^spells(?: (.*))?$
Code:

Code: Select all

if matches[2] then
    send("abil -| spell " .. matches[2])
else
    send("abil -| spell ")
end

Re: how-to

Posted: Sun Apr 29, 2018 5:33 pm
by khiren
Jor'Mox wrote:
Sun Apr 29, 2018 5:08 pm
Try this. Pattern: ^spells(?: (.*))?$
Code:

Code: Select all

if matches[2] then
    send("abil -| spell " .. matches[2])
else
    send("abil -| spell ")
end
Perfect - it works, thanks! :)

Re: how-to

Posted: Sun May 13, 2018 8:00 am
by khiren
Another how-to question :)

How to setup mudlet so when I type 10w my character moves ten times w?

also I tend to use multiple chains like 10w5w2nd something along those lines..