<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, July 26, 2006, 3:12 AM -->
<!-- MuClient version 3.74 -->
<!-- Plugin "RecreateANSI_LUA" generated by Plugin Wizard -->
<muclient>
<plugin
name="RecreateANSI_LUA"
author="Onoitsu2"
id="333bc2186715366b0e0c5207"
language="Lua"
purpose="Allows users to retain ANSI formatting and add text before or after the line matched"
date_written="2006-07-26 03:10:43"
requires="3.70"
version="1.0"
>
<description trim="n">
<![CDATA[
RecreateANSI_LUA Helpfile
-------------------
TRIGGER MUST OMIT FROM OUTPUT TO PREVENT DUPLICATION
Add styles to trigger function definition,
i.e.: function NAME(sName,sLine,wildcards,STYLES)
and then pass the variable into the recreateansi function
world.CallPlugin("333bc2186715366b0e0c5207", "recreateansi", STYLES,"text_to_add","before/after","fcolor","bcolor","bold(true/false)")
You can set this to a variable or simply pass the function itself into the AnsiNote()
function. i.e.: AnsiNote(world.CallPlugin("333bc2186715366b0e0c5207", "recreateansi", STYLES,"text_to_add","before/after","fcolor","bcolor","bold(true/false)"))
Breakdown
-----------
AnsiNote(world.CallPlugin("333bc2186715366b0e0c5207", "recreateansi", STYLES,"text_to_add","before/after","fcolor","bcolor","bold(true/false)"))
STYLES = variable named in trigger function function x(sName,sLine,wildcards,STYLES)
---
"text_to_add" = what to append/prepend to the matched line (can be nearly anything that has [return] value convertable to string, i.e. ,"Blah" .. variable, OR
another function that will give the return value)
---
"before/after" = sets position of the "text_to_add" - "Before" or "After", defaults to "After" if "" (CASE INSENSITIVE)
---
"fcolor" = text color of "text_to_add" - valid values "Black","Red","Green","Yellow","Blue","Magenta","Cyan","White" defaults to "White" if "" (CASE INSENSITIVE)
---
"bcolor" = back color of "text_to_add" - valid values "Black","Red","Green","Yellow","Blue","Magenta","Cyan","White" defaults to "Black" if "" (CASE INSENSITIVE)
---
"bold(true/false)") = sets bold or non-bold appended/prepended text - valid values "True","False" defaults to "False" if "" (CASE INSENSITIVE)
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Script -->
<script>
<![CDATA[
function OnPluginInstall()
OnHelp()
end
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
function recreateansi(linestyles,addtext,beforeafter,fcolor,bcolor,bold)
if addtext == nil or addtext == "" then addtext = "" end
if beforeafter == nil or beforeafter == "" then beforeafter = "after" end
if fcolor == nil or fcolor == "" then fcolor = "white" end
if bcolor == nil or bcolor == "" then bcolor = "black" end
if bold == nil or bold == "" or (string.lower(bold) ~= "true" and string.lower(bold) ~= "false") then
bold = 22
elseif string.lower(bold) == "true" then
bold = 1
end
created = ""
styles = table.getn(linestyles)
for style = 1, styles do
-- Note(linestyles[style]["text"])
-- Note(linestyles[style]["textcolour"])
-- Note(linestyles[style]["backcolour"])
-- Note(linestyles[style]["style"])
created = created .. ransi(linestyles[style]) .. linestyles[style]["text"]
end -- for
if string.lower(fcolor) == "black" then
fcolor = 30
elseif string.lower(fcolor) == "red" then
fcolor = 31
elseif string.lower(fcolor) == "green" then
fcolor = 32
elseif string.lower(fcolor) == "yellow" then
fcolor = 33
elseif string.lower(fcolor) == "blue" then
fcolor = 34
elseif string.lower(fcolor) == "magenta" then
fcolor = 35
elseif string.lower(fcolor) == "cyan" then
fcolor = 36
elseif string.lower(fcolor) == "white" then
fcolor = 37
else
fcolor = 37
end -- fcolor
if string.lower(bcolor) == "black" then
bcolor = 40
elseif string.lower(bcolor) == "red" then
bcolor = 41
elseif string.lower(bcolor) == "green" then
bcolor = 42
elseif string.lower(bcolor) == "yellow" then
bcolor = 43
elseif string.lower(bcolor) == "blue" then
bcolor = 44
elseif string.lower(bcolor) == "magenta" then
bcolor = 45
elseif string.lower(bcolor) == "cyan" then
bcolor = 46
elseif string.lower(bcolor) == "white" then
bcolor = 47
else
bcolor = 40
end -- bcolor
if string.lower(beforeafter) == "before" then
return ANSI(bold,fcolor,bcolor) .. addtext .. created
else
return created .. ANSI(bold,fcolor,bcolor) .. addtext
end -- before after check
end -- recreateansi