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 ➜ Plugins ➜ Another Logging Plugin & html colours

Another Logging Plugin & html colours

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


Posted by Gore   (207 posts)  Bio
Date Sun 19 Dec 2004 10:22 PM (UTC)
Message
Heya,

I'm trying to figure out how I can write a logging plugint that doesn't just log the straight up text, but the colours as well in html format.

Any ideas on how I could start this project?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 19 Dec 2004 10:38 PM (UTC)
Message
Go to the plugins page and look at the ANSI_Log plugin.

That does a similar thing. Rather than outputting ANSI codes, generate the appropriate HTML <font color=blah> stuff.

- Nick Gammon

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

Posted by Gore   (207 posts)  Bio
Date Reply #2 on Sun 19 Dec 2004 11:39 PM (UTC)
Message
Problem is, I need to detect what colours are being used on the output, I.E.

You have recovered balance on all limbs.

is shown as green on black..

How would I see that via scripting?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 19 Dec 2004 11:45 PM (UTC)
Message
That's why I suggested that plugin. Did you look at it?

Around here:


for line = firstline to lastline

  styles = GetLineInfo (line, 11)   ' how many styles

  '
  '  process all styles runs in this line
  ' 

  for style = 1 to styles
 
  '
  '  find text style (ANSI code)
  '
    
  fgcolour = GetStyleInfo (line, style, 14) ' RGB colour of style text

 '
 '  now do background
 '
 bgcolour = GetStyleInfo (line, style, 15) ' RGB colour of style background
   
'  ... and so on

  next
next


That gives you the RGB colours. Then simply use RGBColourToName to convert that to an HTML colour.

- Nick Gammon

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

Posted by Scypio   Poland  (50 posts)  Bio
Date Reply #4 on Mon 20 Dec 2004 03:44 PM (UTC)
Message
Erm, can't you just use the MC auto-html-logging feature?
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #5 on Mon 20 Dec 2004 06:25 PM (UTC)
Message
Hah. Yep.

Sometimes we get into the 'working with what we have' aspect of the plugins that we forget that we actually do have this stuff already.

Unless he wants multiple logs, in which case he'll have to script it a bit.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Wed 22 Dec 2004 10:00 PM (UTC)
Message
Assuming for some reason the HTML logging doesn't work for you, another simpler approach these days it to write a plugin using Lua, that has a trigger. In Lua you can get a fourth argument to triggers that is a style list for the matching line. Then simply go through the style list and output the HTML. Pretty easy, and you can make the trigger include/exclude the lines you want.

This sort of thing would do the job, roughly:


function html_log (name, line, wildcards, styles)
  for _, v in styles do
    AppendToNotepad ("log", 
      '<span style="color: ',
      RGBColourToName (v.textcolour),
      '"; background: ',
      RGBColourToName (v.backcolour),
      '">',
      FixupHTML (v.text),
      '</span>');
  end -- for
  AppendToNotepad ("log", "\r\n");
end  -- function  html_log



Example output:


<span style="color: silver"; background: black">&lt;1000/1000hp 100/100m 110/110mv 2000/315816750xp&gt; </span>
<span style="color: red"; background: black">A Marble Corridor</span>
<span style="color: silver"; background: black">Congratulations! You have come far in your training. Your next step is</span>
<span style="color: silver"; background: black">getting your equipment from the cage mobs for your chosen class. North</span>
<span style="color: silver"; background: black">of here is the Academy Healer, Lord Toric. He will cast spells on you,</span>
<span style="color: silver"; background: black">to help with your fights. Sit with him until you are ready to proceed in</span>
<span style="color: silver"; background: black">your training.</span>
<span style="color: lime"; background: black">Exits: north south.</span>


- 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.


20,797 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.