Updated screendump +mpackage

Share your scripts and packages with other Mudlet users.
User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Updated screendump +mpackage

Post by Vadi »

Well it's something you'll have to find out as part of your project I guess, since the full html that was made passed validation, it was alright.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Updated screendump +mpackage

Post by icesteruk »

Do the attachments on this need updating? or has it already been updated?

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Updated screendump +mpackage

Post by Vadi »

Updating what for... ?

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Updated screendump +mpackage

Post by icesteruk »

some code was posted after, Was wondering if that needed to be added to the script/attachments?
Code: [show] | [select all] lua
function logScreen(logdir, logfile)
if logfile == nil then
        cecho("\n<red>Error:<white> You must sepecify a logname!")
        return false
end

if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else  _sep = "\\" end
local logdir = logdir .. _sep .. logfile .. ".html"
local file_output = io.open(logdir, "w")
local fo = {}
local line_count = getLineCount()
local cur_buffer = getLines(1, line_count-1)
local curcolor = ""
local index = 0
local r,g,b = 0,0,0
local br,bg,bb = 0,0,0
local cbr,cbg,cbb --last bg colors
local cr,cg,cb -- last colors
local tc = 1 -- table count
local perf = createStopWatch()
startStopWatch(perf)

local conversions = {
	["¦"] = "&brvbar;",
	["×"] = "&times;",
	["«"] = "&#171;",
	["»"] = "&raquo;"
}

fo[tc] = [[  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
      <html>
                <head>
                        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
                        <link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<style type="text/css">
body {
  background-color: black;
  font-family: 'Droid Sans Mono';
  white-space: pre; 
  font-size: 12px;
}
</style>
                </head>
                <body><span>]]
tc = tc + 1

for line_num,cur_line in ipairs(cur_buffer) do
  index = 0
 	fo[tc] = string.format([[<span style="color: rgb(192,192,192);background: rgb(0,0,0);">%s</span>]], getTimestamp(line_num))
    tc = tc +1
  while index < #cur_line do
    index = index + 1
    moveCursor("main", index, line_num)
    selectString(cur_line:sub(index), 1)
    r,g,b = getFgColor()
	 br,bg,bb = getBgColor()
    if cr ~= r or cg ~= g or cb ~= b or cbr ~= br or cbg ~= bg or cbb ~= bb then
      cr,cg,cb = r,g,b
		cbr,cbg,cbb = br,bg,bb
      fo[tc] = string.format("</span><span style=\'color: rgb(%d,%d,%d);background: rgb(%d,%d,%d);'>%s", r,g,b,br,bg,bb, cur_line:sub(index, index))
      tc = tc +1
    else
      fo[tc] = cur_line:sub(index, index)
      tc = tc +1
    end
    cur_line:sub(index, index)
  end
  fo[tc] = "\n"
  tc = tc +1
end

fo[#fo+1] = "</span></body></html>"
local s = table.concat(fo)

for from, to in pairs(conversions) do
	s = string.gsub(s, from, to)
end

file_output:write(s)
file_output:close()

-- this can use quite a bit of memory on a large buffer, so free it up right away
collectgarbage("collect")
cecho("\n<cyan>Current buffer saved to: <white>" .. logdir .. "<cyan>, took <white>" .. stopStopWatch(perf) .. "ms<cyan>.")
end

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Updated screendump +mpackage

Post by Vadi »

It doesn't need to be updated, I don't believe. No harm in trying to use it and seeing if background colours work.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Updated screendump +mpackage

Post by icesteruk »

thanks :) I justthought to ask before using it

User avatar
ulysses
Posts: 43
Joined: Fri Jan 05, 2018 7:43 pm

Re: Updated screendump +mpackage

Post by ulysses »

I found a bug with this script I think. I had to write this instead, using selectSection, which is a little more precise than selectString:

Code: Select all

	for i=1,#myline do
		   selectSection(i-1,1)
	           moveCursor(i,getLineNumber())
		   local fr,fg,fb = getFgColor()
		   local br,bg,bb = getBgColor()
		   local ftri = fr .. "," .. fg .. "," .. fb
		   local btri = br .. "," .. bg .. "," .. bb
		   local colour = "<" .. ftri .. ":" .. btri .. ">"
		   table.insert(lineColour, colour)
	end
The problem I've got is that if a letter is repeated in the line, then the first colour read gets applied to the second one!
the second one is actually the last character on the line, so selectString scans for a single letter, which it has a high chance of finding before the end of the line. It happened before with a line like

Code: Select all

'(Darkness) The glass of Leng (worthless)'
the second ess picked up the colour formatting of the first ess in Darkness
Wod :mrgreen:
CthulhuMUD
www.cthulhumud.com
A hugely entertaining MUD based on the horror writings of HP Lovecraft.

Post Reply