Status console - MUSHclient

Text:

Based on the tf work at http://community.pennmush.org/node/481
I've done something similar for MUSHclient. This supports both the C# and C#,# protocols

The script below requires you to create a dummy work "status" (ip 0.0.0.0) and open it up and position it as your status console. The script will write to that world. You copy the script to your clipboard, and then open the Triggers window in your real mush world and hit 'Paste'. You must have Lua scripting enabled in the world's configuration. Replace "TFPREFIX" below with your actual desired secret

Current limitations: It's slower than the tf one, so fast animations (like the fast pig) may not work as mushclient won't trigger fast enough.

Also the regular flying pig behaves a bit weirdly at start and I don't know why. The frogger app works fine.

<triggers>
  <trigger
   enabled="y"
   match="^!TFPREFIXC(\d+) (.*)"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>
  
local w = GetWorld ("status")  -- get "status" world

if w then  -- if present
  style = {}
  myline = tonumber("%1")
  total_lines = w:GetLinesInBufferCount ()
  if total_lines > 5 then
    total_lines = 5
  end
  for line = 1, total_lines do
    style[line] = w:GetStyleInfo(line)  -- A table of tables
  end
  if total_lines < myline then
    total_lines = myline
  end
  
  w:DeleteOutput()

  for line = 1, total_lines do
   styleruns = style[line]
   if line == myline then
     styleruns = TriggerStyleRuns
   end -- if
   for _,v in ipairs (styleruns) do
       v.text = string.gsub(v.text,"^!TFPREFIXC[0-9][0-9]* ","")
       w:ColourTell (RGBColourToName (v.textcolour), 
                  RGBColourToName (v.backcolour), 
                  v.text) 
   end -- for each style run
   w:Note ("")  -- wrap up line
  end -- for line

end -- world found

</send>
  </trigger>

  <trigger
   enabled="y"
   match="^!TFPREFXC(\d+),(\d+) (.*)"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  
  
local w = GetWorld ("status")  -- get "status" world

if w then  -- if present
  style = {}
  myline = tonumber("%1")
  mychar = tonumber("%2")+1
  mylen = string.len("%3")
  total_lines = w:GetLinesInBufferCount ()
  if total_lines > 5 then
    total_lines = 5
  end
  for line = 1, total_lines do
    style[line] = w:GetStyleInfo(line)
  end
  if total_lines < myline then
    total_lines = myline
  end
  
  w:DeleteOutput()

  for line = 1, total_lines do
   if (line == myline) then
     -- First, identify at what style runs (by column) the new text will start and stop
     -- It's the starting column if this style run includes mychar
     -- It's the end column if this style run includes mychar+mylen
     -- Also identify where in each style run (how many chars in)
     startcol = -1
     startchar = 1
     endcol = -1
     endchar = 1
     for _,v in ipairs (style[line]) do
       if (startcol == -1 and v.column <= mychar and v.column+v.length >= mychar) then
         startcol = v.column
         startchar = mychar - v.column
       end
       if (endcol == -1 and v.column <= mychar+mylen and v.column+v.length >= mychar+mylen) then
         endcol = v.column
         endchar = mychar + mylen - v.column + 1
       end
       lastindex = _
     end -- for
     if (startcol == -1) then
       -- Oops, we're trying to write beyond the last column! So we'll extend the last style run's
       -- text and length
       v = style[line][lastindex]
       extraneeded = mychar + mylen - v.column + v.length
       style[line][lastindex].text = v.text .. string.rep(" ",extraneeded)
       style[line][lastindex].length = v.length + extraneeded
       startcol = v.column
       startchar = mychar - v.column
       endcol = v.column
       endchar = v.length
     end
     if (endcol == -1) then
       -- Oops, we've started somewhere, but are trying to write beyond the last column.
       -- We'll extend it, as above.
       v = style[line][lastindex]
       extraneeded = mychar + mylen - v.column + v.length
       style[line][lastindex].text = v.text .. string.rep(" ",extraneeded)
       style[line][lastindex].length = v.length + extraneeded
       endcol = v.column
       endchar = v.length
     end
    inserted = 0
    for _,v in ipairs (style[line]) do
     if (v.column == startcol) then
       -- show up to startchar
       w:ColourTell (RGBColourToName (v.textcolour), 
                  RGBColourToName (v.backcolour),
		string.sub(v.text,1,startchar))
       -- insert here
       for x,v2 in ipairs (TriggerStyleRuns) do
         v2.text = string.gsub(v2.text,"^!TFPREFIXC[0-9][0-9]*,[0-9][0-9]* ","")
         w:ColourTell (RGBColourToName (v2.textcolour), 
                  RGBColourToName (v2.backcolour), 
                  v2.text) 
       end -- for
       inserted = 1
     end -- v.column == startcol
     if (inserted == 0 or v.column >= endcol) then
       -- regular style runs here, possibly with a partial column starting at endchar
       if (v.column == endcol) then
         w:ColourTell (RGBColourToName (v.textcolour), 
                  RGBColourToName (v.backcolour),
		string.sub(v.text,endchar,v.length))
       else
         w:ColourTell (RGBColourToName (v.textcolour), 
                  RGBColourToName (v.backcolour),
		v.text)
       end
     end -- not inserted or v.column >= endcol
    end -- for
     
   else -- if line == myline
    for _,v in ipairs (style[line]) do
       w:ColourTell (RGBColourToName (v.textcolour), 
                  RGBColourToName (v.backcolour), 
                  v.text) 
    end -- for each style run
   end -- if line == myline
   w:Note ("")  -- wrap up line
  end -- for line

end -- world found

</send>
  </trigger>

</triggers>