how-to

khiren
Posts: 14
Joined: Wed Apr 25, 2018 3:01 pm

how-to

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: how-to

Post 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

Brenex
Posts: 3
Joined: Thu Feb 01, 2018 7:52 am

Re: how-to

Post 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..[[")
  ]])

khiren
Posts: 14
Joined: Wed Apr 25, 2018 3:01 pm

Re: how-to

Post by khiren »

Thank you both for quick reply. I will play around a bit today :)

khiren
Posts: 14
Joined: Wed Apr 25, 2018 3:01 pm

Re: how-to

Post 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 :)

nesferatu
Posts: 6
Joined: Sat Apr 28, 2018 2:41 pm

Re: how-to

Post by nesferatu »

Have you tried:
if(matches[2] == "")
?

khiren
Posts: 14
Joined: Wed Apr 25, 2018 3:01 pm

Re: how-to

Post 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.

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

Re: how-to

Post 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

khiren
Posts: 14
Joined: Wed Apr 25, 2018 3:01 pm

Re: how-to

Post 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! :)

khiren
Posts: 14
Joined: Wed Apr 25, 2018 3:01 pm

Re: how-to

Post 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..

Post Reply