You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
207 lines
5.4 KiB
207 lines
5.4 KiB
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE muclient>
|
|
<!-- Saved on Sunday, August 16, 2015, 9:00 AM -->
|
|
<!-- MuClient version 4.98 -->
|
|
|
|
<!-- Plugin "Note_Write_Helper" generated by Plugin Wizard -->
|
|
|
|
<muclient>
|
|
<plugin name="Note_Write_Helper" author="Arcidayne" id="291e6a78b7457b70ebf24375" language="Lua" purpose="Preformats long lines to break at 79 characters with respect to full words." save_state="y" date_written="2015-08-16 08:56:28" requires="4.00" version="2.0">
|
|
<description trim="y">
|
|
<![CDATA[
|
|
Instead of using the note formatter tool, or figuring out how long your line of text is, this plugin will do it for you!
|
|
|
|
nw <text> No indent character; takes a long line and formats linewraps it.
|
|
nwi <char><text> Same as above, except it takes an indent character.
|
|
nnw <reply|new> Opens up an editor box so you can just type the whole note at once.
|
|
|
|
##Examples##
|
|
|
|
nw This is a long line of text that would be formatted to break at 79 characters with respect to the word boundaries.
|
|
|
|
returns
|
|
|
|
This is a long line of text that would be formatted to break at 79 characters with
|
|
respect to the word boundaries.
|
|
|
|
nwi > This is a long line of text that would be formatted to break at 79 characters with respect to the word boundaries.
|
|
|
|
returns
|
|
|
|
>This is a long line of text that would be formatted to break at 79 characters with
|
|
>respect to the word boundaries.
|
|
|
|
]]>
|
|
</description>
|
|
|
|
</plugin>
|
|
|
|
|
|
<!-- Aliases -->
|
|
|
|
<aliases>
|
|
<alias match="^nw (.*)$" enabled="y" group="NoteHelper" regexp="y" send_to="12" sequence="100">
|
|
<send>Send(note_wrap("%1"))</send>
|
|
</alias>
|
|
<alias match="^nwi\s(.*?)\s(.*)$" enabled="y" group="NoteHelper" regexp="y" send_to="12" sequence="100">
|
|
<send>Send(note_wrap("%2", 79, "%1"))</send>
|
|
</alias>
|
|
|
|
<alias match="^nnw (new|reply)$" enabled="y" group="NoteHelper" regexp="y" send_to="12" sequence="100">
|
|
<send>noteeditor("%1")</send>
|
|
</alias>
|
|
</aliases>
|
|
|
|
<!-- Script -->
|
|
|
|
|
|
<script>
|
|
<![CDATA[
|
|
if not type(string.split) == "function" then
|
|
require 'string_split'
|
|
end
|
|
|
|
function note_wrap(str, limit, indent, indent1)
|
|
indent = indent or ""
|
|
indent1 = indent1 or indent
|
|
limit = limit or 79
|
|
local here = 1-#indent1
|
|
local last_color = ''
|
|
return indent1..str:gsub("(%s+)()(%S+)()",
|
|
function(sp, st, word, fi)
|
|
local delta = 0
|
|
local color_before_current_word = last_color
|
|
word:gsub('()@([@%a])',
|
|
function(pos, c)
|
|
if c == '@' then
|
|
delta = delta + 1
|
|
elseif c == 'x' then
|
|
delta = delta + 5
|
|
last_color = word:sub(pos, pos+4)
|
|
else
|
|
delta = delta + 2
|
|
last_color = word:sub(pos, pos+1)
|
|
end
|
|
end)
|
|
here = here + delta
|
|
if fi-here > limit then
|
|
here = st - #indent + delta
|
|
return "\n"..indent..color_before_current_word..word
|
|
end
|
|
end)
|
|
end
|
|
|
|
function noteeditor(str)
|
|
local board_table = {
|
|
{"Announce", "N"},
|
|
{"Mudinfo", "N"},
|
|
{"General", "Y"},
|
|
{"Misc", "Y"},
|
|
{"Claninfo", "Y"},
|
|
{"Clan", "Y"},
|
|
{"Tech", "Y"},
|
|
{"Ideas", "Y"},
|
|
{"Rankings", "N"},
|
|
{"Forsale", "Y"},
|
|
{"Roleplay", "Y"},
|
|
{"Art", "Y"},
|
|
{"Games", "Y"},
|
|
{"Typos", "Y"},
|
|
{"Bugs", "Y"},
|
|
{"Upgrades", "Y"},
|
|
{"Personal", "Y"},
|
|
{"Lottery", "N"},
|
|
{"Lasertag", "N"},
|
|
{"Jokes", "Y"},
|
|
{"Raiding", "Y"},
|
|
{"Voting", "N"},
|
|
{"Mafia", "N"},
|
|
{"Gquest", "N"},
|
|
{"Epics","Y"}
|
|
}
|
|
|
|
|
|
local note, note_to, note_subj, note_to_send, board_check = false, false, false, false, false
|
|
|
|
if str == "new" then
|
|
note_board = utils.inputbox("To which board are you posting?", "Board")
|
|
|
|
for _,v in ipairs(board_table) do
|
|
if string.upper(v[1]) == string.upper(note_board) and v[2] == "Y" then
|
|
board_check = true
|
|
break
|
|
end
|
|
end
|
|
|
|
if board_check then
|
|
note_to = utils.inputbox("To whom are you writing the note?", "To list", "all")
|
|
|
|
if note_to then
|
|
note_to_send = "board " .. note_board .. ";note write " .. note_to
|
|
note_subj = utils.inputbox("What is the subject of your note?", "Subject")
|
|
|
|
if not note_subj then
|
|
note_subj = ".q"
|
|
note_to_send = "echo Note cancelled!"
|
|
end -- end note_subj
|
|
else
|
|
note_to_send = "echo Note cancelled!"
|
|
end -- end note_to
|
|
else
|
|
note_to_send = "echo Note cancelled!"
|
|
end
|
|
|
|
elseif str == "reply" then
|
|
note_to = utils.inputbox("To which note are you replying?", "Note number")
|
|
if note_to then
|
|
note_to_send = "note reply " .. note_to or ""
|
|
else
|
|
note_to_send = "echo Note cancelled!"
|
|
end -- end note_to
|
|
end
|
|
|
|
Execute(note_to_send)
|
|
|
|
if note_to_send ~= "echo Note cancelled!" then
|
|
if note_subj then
|
|
Send(note_subj)
|
|
end
|
|
|
|
note = utils.editbox("Write your note.", "Note Writer Box")
|
|
|
|
if note then
|
|
local lines = note:split("\n")
|
|
for _, line in ipairs(lines) do
|
|
if line:match("^%c") then
|
|
Send("@")
|
|
else
|
|
Send(note_wrap(line))
|
|
end
|
|
end
|
|
Send(".s")
|
|
else
|
|
Send(".q")
|
|
end
|
|
end
|
|
end
|
|
]]>
|
|
</script>
|
|
|
|
|
|
<!-- Plugin help -->
|
|
|
|
<aliases>
|
|
<alias script="OnHelp" match="nw:help" enabled="y">
|
|
</alias>
|
|
</aliases>
|
|
|
|
<script>
|
|
<![CDATA[
|
|
function OnHelp ()
|
|
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
|
|
end
|
|
]]>
|
|
</script>
|
|
|
|
</muclient>
|