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
➜ 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 (23,173 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.
11,393 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top