Funny bits
Posted: Sun Apr 06, 2014 11:46 pm
Geel is fortunate he survives. It's remarkably hard to type pray heal geal.. er.. pray heel geel... argh....

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
<!ENTITY horizontal "y" >
]>
<muclient>
<plugin
name="Icon_Bar"
author="Nick Gammon"
id="ede0920fc1173d5a03140f0e"
language="Lua"
purpose="Shows a bar of buttons you can click on to do things"
date_written="2009-02-26 09:00"
date_modified="2009-03-29 07:00"
requires="4.40"
save_state="y"
version="2.0"
>
<description trim="y">
<![CDATA[
Install this plugin to show an button bar.
Click on an icon to execute a script or send a command to the MUD.
]]>
</description>
</plugin>
<!-- Script -->
<script>
horizontal = ("&horizontal;"):lower ():sub (1, 1) == "y";
<![CDATA[
-- table of buttons
--[[
Each button can have up to four entries:
icon - filename of the image to draw
tooltip - what to show if you hover the mouse over the button
send - what to send to the MUD
script - a script function to call
--]]
buttons = {
-- button 1
{
icon = "flamehand.png", -- icon image
tooltip = "Fireball", -- tooltip help text
send = "button1", -- what to send
}, -- end of button 1
-- button 2
{
icon = "slow.png",
tooltip = "Slow",
send = "button2",
}, -- end of button 2
-- button 3
{
icon = "vigor.png",
tooltip = "Vigor",
send = "button3",
}, -- end of button 3
-- button 4
{
icon = "fireshield.png", -- icon image
tooltip = "Fire Shield", -- tooltip help text
send = "button4", -- what to send
}, -- end of button 4
-- button 5
{
icon = "dispel.png",
tooltip = "Dispel",
send = "button5",
}, -- end of button 5
-- button 6
{
icon = "portal.png",
tooltip = "Portal",
send = "button6",
}, -- end of button 6
-- button 7
{
icon = "teleport.png", -- icon image
tooltip = "Teleport", -- tooltip help text
send = "button7", -- what to send
}, -- end of button 7
-- button 8
{
icon = "wall.png",
tooltip = "Fire Wall",
send = "button8",
}, -- end of button 8
-- button 9
{
icon = "firesearch.png",
tooltip = "Reveal Hidden",
send = "button9",
}, -- end of button 9
-- button 10
{
icon = "fireskull.png", -- icon image
tooltip = "Summon", -- tooltip help text
send = "button10", -- what to send
}, -- end of button 10
-- button 11
{
icon = "sword.png",
tooltip = "Melee",
send = "button11",
}, -- end of button 11
-- button 12
{
icon = "health.png",
tooltip = "Mend",
send = "button12",
}, -- end of button 12
--> add more buttons here
} -- end of buttons table
-- configuration
ICON_SIZE = 50
BACKGROUND_COLOUR = ColourNameToRGB "bisque"
BOX_COLOUR = ColourNameToRGB "royalblue"
BUTTON_EDGE = ColourNameToRGB "silver"
MOUSE_DOWN_COLOUR = ColourNameToRGB "darkorange"
FONT_NAME = "Fixedsys"
FONT_SIZE = 9
-- where to put the window
WINDOW_POSITION = 6 -- top right
OFFSET = 6 -- gap inside box
EDGE_WIDTH = 2 -- size of border stroke
--[[
Useful positions:
4 = top left
5 = center left-right at top
6 = top right
7 = on right, center top-bottom
8 = on right, at bottom
9 = center left-right at bottom
--]]
function mousedown (flags, hotspot_id)
if hotspot_id == "_" then
-- find where mouse is so we can adjust window relative to mouse
startx, starty = WindowInfo (win, 14), WindowInfo (win, 15)
-- find where window is in case we drag it offscreen
origx, origy = WindowInfo (win, 10), WindowInfo (win, 11)
return
end -- if
local n = tonumber (hotspot_id)
-- draw the button border in another colour for visual feedback
WindowRectOp (win, 1,
frames [n].x1, frames [n].y1, frames [n].x2, frames [n].y2,
MOUSE_DOWN_COLOUR)
Redraw ()
end -- mousedown
function cancelmousedown (flags, hotspot_id)
local n = tonumber (hotspot_id)
-- draw the button border in original colour for visual feedback
WindowRectOp (win, 1,
frames [n].x1, frames [n].y1, frames [n].x2, frames [n].y2,
BUTTON_EDGE)
Redraw ()
end -- cancelmousedown
function mouseup (flags, hotspot_id)
-- fix border colour
cancelmousedown (flags, hotspot_id)
local n = tonumber (hotspot_id)
local button = buttons [n]
-- send to world if something specified
if type (button.send) == "string" and
button.send ~= "" then
local errors = {} -- no errors yet
-- function to do the replacements for string.gsub
local function replace_variables (s)
s = string.sub (s, 2) -- remove the @
replacement = GetPluginVariable ("", s) -- look up variable in global variables
if not replacement then -- not there, add to errors list
table.insert (errors, s)
return
end -- not there
return replacement -- return variable
end -- replace_variables
-- replace all variables starting with @
local command = string.gsub (button.send, "@%a[%w_]*", replace_variables)
-- report any errors
if #errors > 0 then
for k, v in ipairs (errors) do
ColourNote ("white", "red", "Variable '" .. v .. "' does not exist")
end -- for
return
end -- error in replacing
Execute (command)
end -- if
-- execute script if wanted
if type (button.script) == "function" then
button.script (n)
end -- if
end -- mouseup
function dragmove(flags, hotspot_id)
-- find where it is now
local posx, posy = WindowInfo (win, 17),
WindowInfo (win, 18)
-- move the window to the new location
WindowPosition(win, posx - startx, posy - starty, 0, 2);
-- change the mouse cursor shape appropriately
if posx < 0 or posx > GetInfo (281) or
posy < 0 or posy > GetInfo (280) then
SetCursor (11) -- X cursor
else
SetCursor (10) -- arrow (NS/EW) cursor
end -- if
end -- dragmove
function dragrelease(flags, hotspot_id)
local newx, newy = WindowInfo (win, 17), WindowInfo (win, 18)
-- don't let them drag it out of view
if newx < 0 or newx > GetInfo (281) or
newy < 0 or newy > GetInfo (280) then
-- put it back
WindowPosition(win, origx, origy, 0, 2);
end -- if out of bounds
end -- dragrelease
frames = {}
function OnPluginInstall ()
local x, y, mode, flags =
tonumber (GetVariable ("windowx")) or 0,
tonumber (GetVariable ("windowy")) or 0,
tonumber (GetVariable ("windowmode")) or WINDOW_POSITION, -- top right
tonumber (GetVariable ("windowflags")) or 0
win = GetPluginID () -- get a unique name
local gauge_height, gauge_width
if horizontal then
window_width = (#buttons * (ICON_SIZE + OFFSET)) + OFFSET
window_height = ICON_SIZE + (OFFSET * 2)
else
window_width = ICON_SIZE + (OFFSET * 2)
window_height = (#buttons * (ICON_SIZE + OFFSET)) + OFFSET
end -- if
-- make the miniwindow
WindowCreate (win,
x, y, -- left, top (auto-positions)
window_width, -- width
window_height, -- height
mode, -- position mode
flags, -- flags
BACKGROUND_COLOUR)
-- draw the buttons
for n, v in ipairs (buttons) do
if v.icon then
if WindowLoadImage (win, n, GetInfo (66) .. v.icon) ~= error_code.eOK then
ColourNote ("white", "red", "Could not load image '" .. GetInfo (66) .. v.icon .. "'")
end -- if
end -- if icon specified
local x1, y1, x2, y2
-- where to draw the icon
if horizontal then
x1, y1 = (n - 1) * (ICON_SIZE + OFFSET) + OFFSET, OFFSET
x2, y2 = n * (ICON_SIZE + OFFSET), ICON_SIZE + OFFSET
else
x1, y1 = OFFSET, (n - 1) * (ICON_SIZE + OFFSET) + OFFSET
x2, y2 = ICON_SIZE + OFFSET, n * (ICON_SIZE + OFFSET)
end -- if
-- draw the image
WindowDrawImage(win, n,
x1, y1, -- left, top
x2, y2, -- right, bottom
2) -- mode - stretch or shrink
-- remember where to draw the frame, for mouse clicks
frames [n] = {
x1 = x1 - 1,
y1 = y1 - 1,
x2 = x2 + 1,
y2 = y2 + 1
}
-- draw the button border
WindowRectOp (win, 1,
frames [n].x1, frames [n].y1, frames [n].x2, frames [n].y2,
BUTTON_EDGE)
-- make a hotspot we can click on
WindowAddHotspot(win, n,
frames [n].x1, frames [n].y1, frames [n].x2, frames [n].y2, -- rectangle
"", -- mouseover
"", -- cancelmouseover
"mousedown",
"cancelmousedown",
"mouseup",
v.tooltip, -- tooltip text
1, 0) -- hand cursor
end -- for each world
-- draw the border of the whole box
WindowCircleOp (win, 2, 0, 0, 0, 0, BOX_COLOUR, 6, EDGE_WIDTH, 0x000000, 1)
-- make a hotspot
WindowAddHotspot(win, "_",
0, 0, 0, 0, -- whole window
"", -- MouseOver
"", -- CancelMouseOver
"mousedown",
"", -- CancelMouseDown
"", -- MouseUp
"Drag to move", -- tooltip text
10, 0) -- arrow (NS/EW) cursor
WindowDragHandler(win, "_", "dragmove", "dragrelease", 0)
if GetVariable ("enabled") == "false" then
ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
EnablePlugin (GetPluginID (), false)
return
end -- they didn't enable us last time
-- ensure window visible
WindowShow (win, true)
end -- OnPluginInstall
-- hide window on removal
function OnPluginClose ()
WindowShow (win, false) -- hide it
end -- OnPluginClose
-- show window on enable
function OnPluginEnable ()
WindowShow (win, true) -- show it
end -- OnPluginEnable
-- hide window on disable
function OnPluginDisable ()
WindowShow (win, false) -- hide it
end -- OnPluginDisable
function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
SetVariable ("windowx", WindowInfo (win, 10))
SetVariable ("windowy", WindowInfo (win, 11))
SetVariable ("windowmode", WindowInfo (win, 7))
SetVariable ("windowflags", WindowInfo (win, 8))
end -- OnPluginSaveState
]]>
</script>
</muclient>
The other day I threw a bunch of stuff in the Academy pawn trash. I then I went back down to continue hunting in the sewers, and to the north I saw it float by me. I couldn't help but chuckle and wonder what weird stuff I could shove down the pipe to watch float by.Kiriath wrote: I just posted it because I found it amusing, and thought others might add things they felt were funny in the future. (Granted, I am quite easily amused.)