Gammon Forum
Entire forum
MUSHclient
Lua
Appending to the end of a line - Solution
Appending to the end of a line - Solution
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Kathan
USA (9 posts) bio
|
Date
| Sun 27 Jul 2014 06:30 PM (UTC) Amended on Sun 27 Jul 2014 06:32 PM (UTC) by Kathan
|
Message
| This is a simple script for appending text to the end of a mud output line while keeping the original colors of original line.
I'm posting this in the hopes that it will help someone else at some point. I spent quite a while looking for a forum topic on appending text to lines in the output window before I stumbled onto some posts about style runs. Once I found out style runs, I was able to find more posts describing what I wanted, but none using the keywords I was looking for.
This snippet can go in the body of any trigger.
Make sure that the trigger is set to send to 14 (Script after Omit), otherwise TriggerStyleRuns won't be available and the script will break.
for k, _ in ipairs(TriggerStyleRuns) do
test = TriggerStyleRuns[k]
ColourTell ( RGBColourToName(test.textcolour), RGBColourToName(test.backcolour), test.text)
end --for
ColourNote ("red", "", " Appended!" )
This code could be as easily modified to prepend by placing the ColourNote before the for loop.
I have to give credit to the following threads for helping me figure out my problem.
| top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #1 on Sun 27 Jul 2014 08:45 PM (UTC) |
Message
| You are calling TriggerStyleRuns twice which is not necessary. This is simpler:
for k, v in ipairs(TriggerStyleRuns) do
ColourTell ( RGBColourToName(v.textcolour),
RGBColourToName(v.backcolour),
v.text)
end --for
ColourNote ("red", "", " Appended!" )
|
- 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.
8,121 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.