Thallia's Chatterbox.xml

From Flexible Survival
Revision as of 07:22, 14 July 2015 by Thallia (talk | contribs) (uploading a script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE MudletPackage> <MudletPackage version="1.0">

   <TriggerPackage>
       <TriggerGroup isActive="yes" isFolder="yes" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
           <name>Chatterbox</name>
           <script>-- the following comment is how to send a trigger match to the a window

-- moonlightUI.sendChat ("Order") -- the following comment is how to send it with colors specified: foreground -- is declared first, anything missing is assumed, and "nochange" means don't -- change the colors -- moonlightUI.sendChat ("Order", {255,255,255}) -- moonlightUI.sendChat ("Order", {255,255,255}, {0,0,0}) -- moonlightUI.sendChat ("Order", "nochange", {0,0,0})

-- the following comment is how to replace long text with a shorter version -- (this will replace it in the main window as well as the miniconsole) --[[ selectString("(this is a very long clan name)", 1) setBgColor(getBgColor()) setFgColor(getFgColor()) replace("(shortclanname)") resetFormat () --]]</script>

           <triggerType>0</triggerType>
           <conditonLineDelta>0</conditonLineDelta>
           <mStayOpen>0</mStayOpen>
           <mCommand></mCommand>
           <packageName></packageName>
           <mFgColor>#ff0000</mFgColor>
           <mBgColor>#ffff00</mBgColor>
           <mSoundFile></mSoundFile>
           <colorTriggerFgColor>#000000</colorTriggerFgColor>
           <colorTriggerBgColor>#000000</colorTriggerBgColor>
           <regexCodeList/>
           <regexCodePropertyList/>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>Public</name>
               <script>moonlightUI.sendChat ("Public")

moonlightUI.sendChat ("Other")</script>

               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^\[Public\](.*?)$</string>
                   <string>^\[Newbie\](.*?)$</string>
                   <string>^\[Science\](.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
                   <integer>1</integer>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>OOC</name>
               <script>moonlightUI.sendChat ("OOC")

moonlightUI.sendChat ("Other")</script>

               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^<OOC> (.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>paging</name>
               <script>moonlightUI.sendChat ("OOC")

moonlightUI.sendChat ("Other")</script>

               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^You (page|page-pose), (.*?)$</string>
                   <string>^\[Page\] (.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>Other</name>
               <script>moonlightUI.sendChat ("Other")</script>
               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^\[(Badges|Rp|Pickup|Bile|Update|Science|TG|Links|Radio|Sports|Writing|SYSTEM)\] (.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>Tick</name>
               <script>moonlightUI.sendChat ("Tick")</script>
               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^\[Tick\](.*?)$</string>
                   <string>^\[Market\](.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>Auction</name>
               <script>moonlightUI.sendChat ("Auction")

moonlightUI.sendChat ("Other")</script>

               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^\[Auction\] (.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>Combats</name>
               <script>moonlightUI.sendChat ("Combat")</script>
               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^<Daily Mission>(.*?)$</string>
                   <string>^(.*?)XP Gained(.*?)Freecred Gained(.*?)$</string>
                   <string>^<Salvage> Thallia manages to salvage(.*?)$</string>
                   <string>^(\&lt;give\&gt;|\w* gives ).*$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
                   <integer>1</integer>
                   <integer>1</integer>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>LFG</name>
               <script>moonlightUI.sendChat ("LFG")</script>
               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^\[Lfg\](.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
           <Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
               <name>Faction</name>
               <script>moonlightUI.sendChat ("Other")</script>
               <triggerType>0</triggerType>
               <conditonLineDelta>0</conditonLineDelta>
               <mStayOpen>0</mStayOpen>
               <mCommand></mCommand>
               <packageName></packageName>
               <mFgColor>#ff0000</mFgColor>
               <mBgColor>#ffff00</mBgColor>
               <mSoundFile></mSoundFile>
               <colorTriggerFgColor>#000000</colorTriggerFgColor>
               <colorTriggerBgColor>#000000</colorTriggerBgColor>
               <regexCodeList>
                   <string>^\[(Zephyr|Promethean|RSX Solutions)\] (.*?)$</string>
               </regexCodeList>
               <regexCodePropertyList>
                   <integer>1</integer>
               </regexCodePropertyList>
           </Trigger>
       </TriggerGroup>
   </TriggerPackage>

<ScriptPackage>

       <Script isActive="yes" isFolder="no">
           <name>Chatterbox</name>
           <packageName></packageName>
           <script>--[[

to do: 1) dynamically scale the tabs to the text width --]]


-- I like to set the unused space to a dark red -- it's Red Green Blue, from 1-255, so change as you prefer! -- 0,0,0 is black setBorderColor (25, 0, 0)

-- and let's begin by creating the UI table moonlightUI = moonlightUI or {}

-- we'll set the dimensions so the screen can dynamically scale -- adjust these as you prefer, as well! moonlightUI.dimensions = {} moonlightUI.rightbar = 350 moonlightUI.bottombar = 15 -- oh, and set the font size for the chat windows moonlightUI.fontsize = 8

-- now, we move that pesky main window! setBorderTop (5) setBorderLeft (5) setBorderRight (moonlightUI.rightbar + 10) setBorderBottom (moonlightUI.bottombar + 4)



-- ================ -- Chat Container -- ================

-- let's make the chat container moonlightUI.chatcontainer = Geyser.Container:new ({

 name = "chatcontainer",
 x = "-" .. tostring (moonlightUI.rightbar + 5),
 y = -355,
 width = moonlightUI.rightbar,
 height = 350,
 })


-- here's something to hold the names of chat containers moonlightUI.chatcontainers = {}

-- important part: function to create a new chat window moonlightUI.createchat = function (chatname, buttoncolor)

 -- prepend 'ChatBox' to the name
 local chatboxname = "ChatBox" .. chatname
 -- save that name in the list of chat boxes
 moonlightUI.chatcontainers[#moonlightUI.chatcontainers+1] = chatboxname
 -- and make the chat box!
 moonlightUI[chatboxname] = Geyser.MiniConsole:new ({
   name=chatboxname,
   -- we'll set it against the left, 30px from the top to give room for the tabs,
   -- and as wide as the chat container
   x = 0, y = 30, width = "100%",
   -- the height is set this way so it actually adheres to the height of the chat container
   -- if you just set 100% it actually overflows by an amount equal to the chatbox 'y' value
   height = tonumber((moonlightUI.chatcontainer.height:gsub("px",""))) - 30,
   }, moonlightUI.chatcontainer)
 -- set the buffer, wrap, and background color of the chatbox
 moonlightUI[chatboxname]:setBufferSize (500000, 100)
 local fontwidth, fontheight = calcFontSize (moonlightUI.fontsize)
 moonlightUI[chatboxname]:setWrap (math.floor (moonlightUI.rightbar/fontwidth))
 moonlightUI[chatboxname]:setColor ("black")
 -- set the font size
 setMiniConsoleFontSize (chatboxname, moonlightUI.fontsize)
 -- prepend 'ChatButton' to the name
 local chatbuttonname = "ChatButton" .. chatname
 -- figure out where the button should sit
 local buttonstart = (#moonlightUI.chatcontainers - 1) * 47
 -- and make the chat button!
 moonlightUI[chatbuttonname] = Geyser.Label:new ({
   name = chatbuttonname,
   -- we'll offset the buttons so they don't overlap, and set them against the top
   x = buttonstart, y = 0,
   -- give it some space (needs to be udpated to dynamically scale)
   width = 45, height = 25,
   -- set the font to black
   fgColor = "black",
   -- and the background to the color they wanted!
   color = buttoncolor,
   -- oh, don't forget the text...
   message = [[<center>]] .. chatname .. [[</center>]]
   }, moonlightUI.chatcontainer)
 -- this is so when we click it...
 moonlightUI[chatbuttonname]:setClickCallback ("moonlightUI." .. chatbuttonname .. "_press")
 -- ...we call this function to switch chat windows!
 moonlightUI[chatbuttonname .. "_press"] = function ()
   moonlightUI.chatpress (chatboxname)
 end -- func
 -- now, let's make a tiny tab to indicate which is current
 -- prepend 'CurrentTab' to the name
 local currenttabname = "CurrentTab" .. chatname
 -- now, let's make a tiny tab to indicate which is current
 -- and make the chat button!
 moonlightUI[currenttabname] = Geyser.Label:new ({
   name = currenttabname,
   -- we'll offset the buttons so they don't overlap, and set them against the top
   x = buttonstart, y = 26,
   -- give it some space (needs to be udpated to dynamically scale)
   width = 45, height = 3,
   -- and the background to the color they wanted!
   color = buttoncolor,
   }, moonlightUI.chatcontainer)

end -- func

-- here's that function to switch chat windows moonlightUI.chatpress = function (chatname)

 -- first, hide them all
 for k, v in ipairs (moonlightUI.chatcontainers) do
     moonlightUI[v]:hide ()
     moonlightUI["CurrentTab" .. string.sub(v, 8)]:hide ()
 end -- func
 -- then show the one we want
 moonlightUI[chatname]:show ()
 moonlightUI["CurrentTab" .. string.sub(chatname, 8)]:show ()

end -- func

-- and another function to send chat to window moonlightUI.sendChat = function (chatwindow, fcolor, bcolor)

 -- add a newline, to avoid overcrowding
 moonlightUI["ChatBox" .. chatwindow]:echo ("\n")
 -- and paste in the text!
 selectCurrentLine ()
 -- set fcolor/bcolor 'or' to "nochange" to leave the colors as they are
 -- or set fcolor/bcolor 'or' to {r,g,b} to set your own defaults
 local fcolor = fcolor or "nochange"
 local bcolor = bcolor or "nochange"
 local _br,_bg,_bb = getBgColor ()
 local _fr,_fg,_fb = getFgColor ()
 if fcolor ~= "nochange" then setFgColor(fcolor[1],fcolor[2],fcolor[3]) end
 if bcolor ~= "nochange" then setBgColor(bcolor[1],bcolor[2],bcolor[3]) end
 copy ()
 setBgColor(_br,_bg,_bb)
 setFgColor(_fr,_fg,_fb)
 appendBuffer ("ChatBox" .. chatwindow)
 appendBuffer ("ChatBoxAll")
 resetFormat ()

end -- func

moonlightUI.speak = function (chatwindow, text)

 cecho ("ChatBox" .. chatwindow, text)

end -- func

-- finally, here we make some chat windows moonlightUI.createchat ("Public", "green") moonlightUI.createchat ("OOC", "white") moonlightUI.createchat ("LFG", "yellow") moonlightUI.createchat ("Other", "brown") moonlightUI.createchat ("Auction", "grey") moonlightUI.createchat ("Tick", "red") moonlightUI.createchat ("Combat", "orange")


-- this goes at the end to hide the chat windows for k, v in ipairs (moonlightUI.chatcontainers) do

   moonlightUI[v]:hide ()
   moonlightUI["CurrentTab" .. string.sub(v, 8)]:hide ()

end -- for -- then show the first one moonlightUI[moonlightUI.chatcontainers[1]]:show () moonlightUI["CurrentTab" .. string.sub(moonlightUI.chatcontainers[1], 8)]:show ()


-- the following comment is how to send a trigger match to the a window -- moonlightUI.sendChat ("Public") -- the following comment is how to send it with colors specified: foreground -- is declared first, anything missing is assumed, and "nochange" means don't -- change the colors -- moonlightUI.sendChat ("Public", {255,255,255}) -- moonlightUI.sendChat ("Public", {255,255,255}, {0,0,0}) -- moonlightUI.sendChat ("Public", "nochange", {0,0,0})

-- the following comment is how to replace long text with a shorter version -- (this will replace it in the main window as well as the miniconsole) --[[ selectString("(this is a very long clan name)", 1) setBgColor(getBgColor()) setFgColor(getFgColor()) replace("(shortclanname)") resetFormat () --]]</script>

           <eventHandlerList/>
       </Script>
   </ScriptPackage>

</MudletPackage>