[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  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] Refresh page


Posted by Kathan   USA  (9 posts)  [Biography] 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.

Template:post=7818 Please see the forum thread: http://gammon.com.au/forum/?id=7818.

Template:post=12464 Please see the forum thread: http://gammon.com.au/forum/?id=12464.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[Go to top] 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] Refresh page

Go to topic:           Search the forum


[Go to top] 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.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]