how-to

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

how-to

Post by khiren » Wed Apr 25, 2018 3:06 pm

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: 4703
Joined: Sat Mar 14, 2009 3:13 pm

Re: how-to

Post by Vadi » Thu Apr 26, 2018 4:07 am

@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 » Thu Apr 26, 2018 5:24 am

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 » Thu Apr 26, 2018 9:24 am

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 » Sun Apr 29, 2018 2:34 pm

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: 5
Joined: Sat Apr 28, 2018 2:41 pm

Re: how-to

Post by nesferatu » Sun Apr 29, 2018 4:23 pm

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

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

Re: how-to

Post by khiren » Sun Apr 29, 2018 4:52 pm

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: 1099
Joined: Wed Apr 03, 2013 2:19 am

Re: how-to

Post by Jor'Mox » 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

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

Re: how-to

Post by khiren » Sun Apr 29, 2018 5:33 pm

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 » Sun May 13, 2018 8:00 am

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

Who is online

Users browsing this forum: No registered users and 18 guests