Ok, I have the following plugin for Python:
And I wanted to convert it to Lua so I could give it to people without worrying about them having Python, and I also wanted to modify it further. But as I read more about Lua's Regex, I learned that it really has minimal support and I don't think I'd want to try to do what this plugin is doing in it. Also, I read that Lua does not support unicode and I was worried that this plugin uses Unicode but I wasn't sure.
So, my questions are: does the Mushclient supplied Regular Expression support in Lua work with Unicode? Does this plugin even use unicode? Or is this plugin just not possible in Lua?
And, maybe, could someone just rewrite this for Lua really quickly? *hope*
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, March 13, 2005, 4:11 PM -->
<!-- MuClient version 3.65 -->
<!-- Plugin "PromptCatcher_Achaea" generated by Plugin Wizard -->
<muclient>
<plugin
name="PromptCatcher_Achaea"
author="Keldar"
id="8f85913ad96bd5bc255e434a"
language="Python"
purpose="Terminates prompts with newlines"
date_written="2005-03-13 16:10:15"
requires="3.65"
version="1.0"
>
</plugin>
<script>
<![CDATA[
import re
lastHealth = None
lastMana = None
pat1 = re.compile(u"(\-\xff\xf9)($|\x0d\x0a)?")
pat2 = re.compile("^\x0d\x0a")
terminated = False
prompt = re.compile('(\x1b[(?:32|1;33|1;31)m)([0-9]+)(h,\x1b[(?:0;)?37m)(\x1b[(?:32|1;33|1;31)m)( [0-9]+)(m\x1b[(?:0;)?37m [c]?[e]?[x]?[k]?[d]?[b]?\-)')
def repl(mo):
global terminated
if mo.groups()[1] == "":
terminated = True
return "-\x0d\x0a"
def repl2(mo):
global lastHealth
global lastMana
currHealth, currMana = int(mo.groups()[1]), int(mo.groups()[4])
if lastHealth is None:
lastHealth = currHealth
if lastMana is None:
lastMana = currMana
healthDiff, manaDiff = currHealth - lastHealth, currMana - lastMana
lastHealth, lastMana = currHealth, currMana
if healthDiff > 0:
healthDiff = "\x1b[37m[\x1B[1;32m+%s\x1b[0;37m]%s" % (str(healthDiff), mo.groups()[0])
elif healthDiff < 0:
healthDiff = "\x1b[37m[\x1b[1;31m%s\x1b[0;37m]%s" % (str(healthDiff), mo.groups()[0])
else:
healthDiff = ""
if manaDiff > 0:
manaDiff = "\x1b[37m[\x1B[1;32m+%s\x1b[0;37m]%s" % (str(manaDiff), mo.groups()[3])
elif manaDiff < 0:
manaDiff = "\x1b[37m[\x1B[1;31m%s\x1b[0;37m]%s" % (str(manaDiff), mo.groups()[3])
else:
manaDiff = ""
return "%s%s%s%s%s%s%s%s" % (mo.groups()[0], mo.groups()[1], healthDiff, mo.groups()[2], mo.groups()[3], mo.groups()[4], manaDiff, mo.groups()[5])
def OnPluginPacketReceived(packet):
packet = prompt.sub(repl2, packet)
global terminated
global pat1
global repl
global pat2
if terminated:
packet = pat2.sub("",packet)
terminated = False
packet = pat1.sub(repl, packet)
return packet
]]>
</script>
</muclient>
And I wanted to convert it to Lua so I could give it to people without worrying about them having Python, and I also wanted to modify it further. But as I read more about Lua's Regex, I learned that it really has minimal support and I don't think I'd want to try to do what this plugin is doing in it. Also, I read that Lua does not support unicode and I was worried that this plugin uses Unicode but I wasn't sure.
So, my questions are: does the Mushclient supplied Regular Expression support in Lua work with Unicode? Does this plugin even use unicode? Or is this plugin just not possible in Lua?
And, maybe, could someone just rewrite this for Lua really quickly? *hope*