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
➜ Lua
➜ ANSI to styles conversion
|
ANSI to styles conversion
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| FxF
(5 posts) Bio
|
| Date
| Tue 19 May 2009 08:21 AM (UTC) |
| Message
| 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:
<?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. | | Top |
|
| Posted by
| FxF
(5 posts) Bio
|
| Date
| Reply #1 on Tue 19 May 2009 08:25 AM (UTC) |
| Message
| Sorry for not escaping the patterns for the forums.
map_start_reg and map_end_reg should have two \ everywhere, otherwise the plugin won't work. I'm using the MUSHClient from WINE and working with clipboard is tricky sometimes :)
BTW MUSHClient under WINE has some problems but I guess it doesn't belong to this thread.
| | 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.
10,348 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top