Hi,
I'm trying to move mud minimap to separate miniwindow. This is for Nodeka mud and the problem is that the start and the end of map cannot be triggered by some text pattern. However, I have found out that Nodeka sends some nonprintable chars at the beggining and end of the map.
I have created this plugin so far:
map_start_reg and map_end_reg are the regular expressions that mark the beginning and the end of map. As you can see, they are nonprintable chars. AFAIK I can match nonprintable chars only by regexp and only from raw packets, which complicates the situation. This plugin works, but I would like to change the UpdateMap function to draw the map into the miniwindow. The problem is that map string contains raw text with ANSI escapes. Is there any good way to write this text with colors into miniwindow? I can create my own function in Lua to convert the ANSI into the styled text with the help of regexp, but it might be both quite complex and the result might slow down the things as well.
I'm trying to move mud minimap to separate miniwindow. This is for Nodeka mud and the problem is that the start and the end of map cannot be triggered by some text pattern. However, I have found out that Nodeka sends some nonprintable chars at the beggining and end of the map.
I have created this plugin so far:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, May 18, 2009, 8:38 PM -->
<!-- MuClient version 4.40 -->
<!-- Plugin "nodeka_windows" generated by Plugin Wizard -->
<muclient>
<plugin
name="nodeka_windows"
id="a8260a455abf46e3895aa9e2"
language="Lua"
date_written="2009-05-18 20:38:25"
requires="4.40"
version="1.0"
>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Script -->
<script>
<![CDATA[
map_start_reg = rex.new("\033\[2m\033\[4m\033\[2m")
map_end_reg = rex.new("\033\[4m\033\[2m\033\[4m")
map_line = false
map = ""
function OnPluginPacketReceived(packet)
local map_start_ind, map_end_ind
start, stop, mtable = map_start_reg:match(packet)
if start then
Note("Map start")
map_line = true
map_start_ind = start
end
start, stop, mtable = map_end_reg:match(packet)
if start then
Note("Map end")
map_line = false
map_end_ind = stop
end
if not map_line and not map_start_ind and not map_end_ind then -- we are outside of map packet
packet_left = packet
elseif map_line and not map_start_ind and not map_end_ind then -- we are inside of map packet
map = map .. packet
packet_left = ""
elseif not map_line and map_start_ind and map_end_ind then -- whole map inside of 1 packet
map = string.sub(packet, map_start_ind, map_end_ind)
packet_left = string.sub(packet, 1, map_start_ind)..string.sub(packet, map_end_ind)
UpdateMap()
elseif map_line and map_start_ind and not map_end_ind then -- start of the map
map = string.sub(packet, map_start_ind)
packet_left = string.sub(packet, 1, map_start_ind)
elseif not map_line and not map_start_ind and map_end_ind then -- end of the map
map = map .. string.sub(packet, 1, map_end_ind)
packet_left = string.sub(packet, map_end_ind)
UpdateMap()
else -- corner cases - more maps in one packet etc.
packet_left = packet
end
return packet_left
end
function UpdateMap()
AnsiNote(map)
map=""
end
]]>
</script>
</muclient>
map_start_reg and map_end_reg are the regular expressions that mark the beginning and the end of map. As you can see, they are nonprintable chars. AFAIK I can match nonprintable chars only by regexp and only from raw packets, which complicates the situation. This plugin works, but I would like to change the UpdateMap function to draw the map into the miniwindow. The problem is that map string contains raw text with ANSI escapes. Is there any good way to write this text with colors into miniwindow? I can create my own function in Lua to convert the ANSI into the styled text with the help of regexp, but it might be both quite complex and the result might slow down the things as well.