Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Some about triggers...

Some about triggers...

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Madjack   Ukraine  (16 posts)  Bio
Date Tue 10 Jan 2006 09:53 AM (UTC)
Message
1. ANSI Colours.
How i can get to lua script full coded ANSI line from mud, when trigger fires? For example when trigger fires on line "Almo tells you: Hey", where "Almo tells you:" - has white color, and "Hey" - has red color. And calls lua function:

function test_trigger( name, line, wildcards, styles )
...
AnsiNote( line );
...
end;

test_trigger function notes single color line. I need to get full coded ANSI line from mud. So, i need call AnsiNote( line ) and get same colors at the output.

2. Multi-Line Triggers from lua.
How i can create multi-line trigger from lua?

3. How i can replace text in mud output?

Thanks.

Macbook pro late 2008 (MB471)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 11 Jan 2006 02:18 AM (UTC)
Message
Quote:

How i can get to lua script full coded ANSI line from mud, when trigger fires?


A scripted trigger function like this will do it. The "styles" argument has all the colour information in it for each style run.


function mytrigger (name, line, wildcards, styles)

  for k, v in ipairs (styles) do
    ColourTell (RGBColourToName (v.textcolour), 
                RGBColourToName (v.backcolour), 
                v.text)
  end -- for loop
  Note ""

end -- mytrigger


Quote:

How i can create multi-line trigger from lua?


Create a trigger in the usual way, then use SetTriggerOption to set these fields:

multi_line = true
lines_to_match = 10 -- or whatever

For example:


AddTrigger("triggername", "attacks", "flee", 
          trigger_flag.Enabled + trigger_flag.RegularExpression, 
          custom_colour.Custom15, 0, "", "")
SetTriggerOption ("triggername", "multi_line", 1)
SetTriggerOption ("triggername", "lines_to_match", 10)


Quote:

How i can replace text in mud output?


You could omit the original line from the output and then do a "Replace" (or string.gsub) on the line to change the text in it.

If you are confident the text will all be in the same style (ie. the same colour) then you could do it with a modification of the earlier example:


function mytrigger (name, line, wildcards, styles)

  for k, v in ipairs (styles) do
    v.text = string.gsub (v.text, "Exits", "Ways to go")
    ColourTell (RGBColourToName (v.textcolour), 
                RGBColourToName (v.backcolour), 
                v.text)
  end -- for loop
  Note ""

end -- mytrigger


This will change "Exits" to "Ways to go" if it occurs inside a style.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,518 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.