I can't seem to get Telnet_Options.lua working with this plugin, as far as I can tell
it is exactly the same as the Map plugin. The file is in the same dir as the plugin.
One other problem is that not all the tags I need to switch on and off are listed on the
Aardworlf site or in the 'help Telopts'. Heres the tags I need to toggle:
tags ROOMNAMES on
tags ROOMDESCS on
tags ROOMOBJS on
tags ROOMCHARS on
tags EXITS on
Anyone with any ideas on how I might do this with no user intervention? I don't really
want a stream of 5 commands at Enable and Disable.
This is the plugin:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, July 16, 2009, 9:58 PM -->
<!-- MuClient version 4.42 -->
<!-- Plugin "Scan_Window" generated by Plugin Wizard -->
<muclient>
<plugin
name="Look_Scan"
author="Blainer"
id="73766b7b4dfab1cd1ce9494d"
language="Lua"
purpose="Put scan and Look in miniwindow"
date_written="2009-07-16 21:58:17"
requires="4.42"
version="1.0"
save_state="y"
>
</plugin>
<triggers>
<!-- look triggers -->
<trigger
enabled="y"
group="look"
name="name"
lines_to_match="1"
keep_evaluating="n"
match="^\{rname\}(.+)$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="LookTrigger"
>
</trigger>
<trigger
enabled="y"
group="look"
name="desc"
lines_to_match="1"
keep_evaluating="n"
match="^\{\/?rdesc\}$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="LookTrigger"
>
</trigger>
<trigger
enabled="y"
group="look"
name="exits"
lines_to_match="1"
keep_evaluating="n"
match="^\{exits\}(\[Exits\: .+\])"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="LookTrigger"
>
</trigger>
<trigger
enabled="y"
group="look"
name="objs"
lines_to_match="1"
keep_evaluating="n"
match="^\{\/?roomobjs\}$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="LookTrigger"
>
</trigger>
<trigger
enabled="y"
group="look"
name="chars"
lines_to_match="1"
keep_evaluating="n"
match="^\{\/?roomchars\}$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="LookTrigger"
>
</trigger>
<trigger
enabled="n"
name="catch_line"
lines_to_match="1"
keep_evaluating="n"
match="^(.*)$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="999"
script="LookTrigger"
>
</trigger>
<trigger
enabled="n"
name="catch_desc"
lines_to_match="1"
keep_evaluating="n"
match="^(.*)$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="999"
script="LookTrigger"
>
</trigger>
<!-- end look triggers -->
<!-- scan triggers -->
<trigger
enabled="y"
group="scan"
lines_to_match="1"
keep_evaluating="n"
match="^\d* ?(Up|Down|Right|North|South|East|West) .*here you see:$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="ScanTrigger"
>
</trigger>
<trigger
enabled="y"
group="scan"
lines_to_match="1"
keep_evaluating="n"
match="^You see a [A-Za-z0-9 ]+?(up|down|right|north|south|east|west)\.$"
multi_line="n"
match_text_colour="y"
text_colour="10"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="ScanTrigger"
>
</trigger>
<trigger
enabled="y"
group="scan"
lines_to_match="1"
keep_evaluating="n"
match="^\s{5}\- (?!--+).+$"
multi_line="n"
omit_from_output="y"
regexp="y"
send_to="12"
sequence="101"
script="ScanTrigger"
>
</trigger>
<trigger
enabled="n"
name="endTrigger"
lines_to_match="1"
keep_evaluating="n"
match=".+"
multi_line="n"
omit_from_output="n"
regexp="y"
send_to="12"
sequence="999"
script="EndScan"
>
</trigger>
<!-- end scan triggers -->
<trigger
enabled="n"
name="combat"
lines_to_match="1"
keep_evaluating="y"
match="^You receive (\d+(?:\+\d+)*) experience points?\.$"
multi_line="n"
omit_from_output="n"
regexp="y"
send_to="0"
sequence="999"
>
<send>scan</send>
</trigger>
</triggers>
<aliases>
<alias
script="Execs"
match="^sl (.+)$"
regexp="y"
enabled="y"
send_to="12"
ignore_case="y"
sequence="100"
></alias>
</aliases>
<script>
<![CDATA[
require "checkplugin"
--Keys
MiniScan = "ALT+s" -- Minimize/Show scan window
MiniLook = "ALT+l" -- Minimize/Show look window
--end keys
--Settings
FontName = GetInfo(20) -- Font for window, i.e. "Times New Roman", GetInfo(20) is current window font.
BackgroundColour = GetInfo (271) -- Background colour for window. Supports Lua codes and MUSH colour names
-- i.e. "2432272" or "black" or GetInfo(271) can be used, last one is your current window colour.
TitleColour = "lime" -- Colour of title text. Supports Lua codes and MUSH colour names
BannerColour = "925008" -- Title Banner colour. Supports Lua codes and MUSH colour names.
ButtonColour = "white" -- Button body colour.
ButtonBorderColour = "black" -- Button border colour.
BorderColour = "white" -- Window border colour.
LFontSize = 8 -- Window font size.
FontName = GetInfo(20) -- Font for window, i.e. "Times New Roman", GetInfo(20) is current window font.
BorderWidth = 1 -- Line thickness borders.
ButtonGap = 5 -- Space between buttons.
LineSpace = 3 -- Space in points between lines of text.
OffSet = BorderWidth + 4 -- Objects offset from window edge.
ShowBorders = true -- "true" = Draw borders, "false" = Don't draw borders
ShowWelcome = true -- Show "plugin installed" msg when plugin enabled.
ScanAfterCombat = true -- Will send scan to MUD after you recieve experience
CaptCharObjs = true -- "true" = display objects and characters in look window
-- "false" = display objects and characters in output window (unchanged)
EchoDesc = true -- "true" = show room descriptions in display
-- "false" = only display room descriptions in miniwindow
EchoName = true -- "true" = show room names in display
-- "false" = only display room names in miniwindow
ShowRoomSep = true -- "true" = will print "[-]" after look output is finished
-- "false = won't print anything
--End Settings
ScanT = {}
LookT = {}
--assigns commands to keyboad keys
function SetKeys ()
AcceleratorTo (MiniScan, "sl scan", 10)
AcceleratorTo (MiniLook, "sl look", 10)
end --SetKeys
--for execute commands from Accelerator keys
function Execs (name, line, wildcards)
sWin = GetPluginID () .. wildcards[1]
--if window is hidden then do nothing
if WindowInfo (sWin, 3) == 0 then
Refresh (sWin)
return
end
--if window is minimized do Restore
if GetVariable ("do" .. wildcards[1]) == "false" then
Restore ("", sWin)
return
end
--Minimize window
Minimize ("", sWin)
end -- Execs
--triggered by Look output
function LookTrigger (name, line, wildcards, styles)
-- put styles table into LookT
local function addT ()
-- fill table one index per line, replacing long flags
t = { ["(Translucent)"] = "(Trans.)",
["(White Aura)"] = "(W.Aura)"
}
for i,v in ipairs (styles) do
v.text = v.text:gsub ("%([%a ]+%)",
function (str)
return t [str]
end)
end
table.insert (LookT, styles)
end -- addT
--set options for window and call ShowWindow()
local function LookFinish ()
EnableTrigger ("catch_line", false)
--set window height for Look
Height = #LookT * (FontHeight + LineSpace) + THeight + (OffSet * 2)
--get max line width for Look
Width = 0
for i,v in ipairs (LookT) do
s = ""
for j,w in ipairs (v) do
s = w.text .. s
Width = math.max (Width, WindowTextWidth (sLookWin, FontId, s) + (OffSet * 2))
end
end
--
if GetVariable ("dolook") == "true" then
--show window WinName, Width, Height, TitleText, styles table
ShowWindow (LookWinT, Width, Height, "You See", LookT)
end
--clear table for next time
LookT = {}
--look is finished send scan if not minimized
if GetVariable ("doscan") == "true" then
SendNoEcho ("scan")
end
end --LookFinish
if line:match("%{rname%}") then
sLookTitle = line:match ("{rname}(.+)")
if EchoName then
ColourNote("lime", GetInfo (271), sLookTitle)
end
--table.remove (styles, 1)
return
end
if line:match("%{rdesc%}") then
EnableTrigger ("catch_desc", true)
return
end
if line:match("%{%/rdesc%}") then
EnableTrigger ("catch_desc", false)
return
end
if line:match("%{exits%}") then
table.remove (styles, 1)
addT ()
if not CaptCharObjs then
LookFinish ()
end
return
end
if line:match("%{roomobjs%}") then
if CaptCharObjs then
EnableTrigger ("catch_line", true)
end
return
end
if line:match("%{%/roomobjs%}") then
EnableTrigger ("catch_line", false)
return
end
if line:match("%{roomchars%}") then
if CaptCharObjs then
EnableTrigger ("catch_line", true)
end
return
end
--at end of Look output from MUD call ShowWindow
if line:match ("%{%/roomchars%}") then
EnableTrigger ("catch_line", false)
if CaptCharObjs then
LookFinish ()
end
if ShowRoomSep then
ColourTell("brown", GetInfo (271), "[")
ColourTell("gray", GetInfo (271), "-")
ColourTell("brown", GetInfo (271), "]")
end
return
end
addT ()
end --LookTrigger
--triggered by scan output
function ScanTrigger (name, line, wildcards, styles)
if line:match ("here you see:") or line:match (" - ") or line:match ("You see ") then
t = { ["(Translucent)"] = "(Trans.)",
["(White Aura)"] = "(W.Aura)",
["(Animated)"] = "(Anim.)",
["Up"] = "UP",
["Down"] = "DOWN",
["Right"] = "RIGHT",
["North"] = "NORTH",
["South"] = "SOUTH",
["East"] = "EAST",
["West"] = "WEST"
}
for i,v in ipairs (styles) do
v.text = v.text:gsub ("%([%a ]+%)",
function (str)
return t [str]
end)
v.text = v.text:gsub ("(%a+)",
function (str)
return t [str]
end)
v.text = v.text:gsub (" ", " ")
end
table.insert (ScanT, styles)
EnableTrigger ("endTrigger", true)
end
end --ScanTrigger
--triggered after scan output
function EndScan (name,line,wildcards)
EnableTrigger ("endTrigger", false)
Height = #ScanT * (FontHeight + LineSpace) + THeight + (OffSet * 2)
--get max line width for Look
Width = 0
for i,v in ipairs (ScanT) do
s = ""
for j,w in ipairs (v) do
s = w.text .. s
Width = math.max (Width, WindowTextWidth (sLookWin, FontId, s) + (OffSet * 3))
end
end
ShowWindow (ScanWinT, Width, Height, "Scan", ScanT, true)
ScanT = {}
end
--create a window with banner and buttons
function ShowWindow (WinT, Width, Height, sTitleText, stylesT, bMenu)
--use last WinName window if not passed one
if WinT then
WinName = WinT.win
end
-- recreate the window the correct size and position
WindowCreate (WinName,
WinT.window_left,
WinT.window_top,
Width, -- width
Height, -- height
WinT.window_mode, -- whatever
WinT.window_flags,
BackgroundColour)
--draw draw border
if ShowBorders then
WindowCircleOp (WinName, 2, 0, 0, Width, Height, BorderColour, 0, BorderWidth, ButtonColour, 1, 5, 5)
else
BorderWidth = 0
end
--title banner width
Twidth = Width - (BorderWidth * 2)
-- draw drag bar rectangle
WindowRectOp (WinName, 2, BorderWidth, BorderWidth, Twidth , THeight, BannerColour)
--draw minimize button
BoxSq = LFontSize
Left = OffSet
Top = (THeight / 2) - (BoxSq / 2)
Right = Left + BoxSq
Bottom = Top + BoxSq
WindowCircleOp (WinName, 2, Left, Top, Right, Bottom, ButtonBorderColour, 0, BorderWidth, ButtonColour, 0)
WindowAddHotspot(WinName, WinName, Left, Top, Right, Bottom, "", "", "","", "Minimize", "Minimize " .. sTitleText, 1, 0)
--draw refresh button
CircleSize = LFontSize
Left = Right + ButtonGap
Right = Left + CircleSize
Bottom = Top + CircleSize
WindowCircleOp (WinName, 1, Left, Top, Right, Bottom, ButtonBorderColour, 0, BorderWidth, ButtonColour, 0)
WindowAddHotspot (WinName, sTitleText, Left, Top, Right, Bottom, "", "", "", "", "Refresh", "Refresh " .. sTitleText, 1, 0)
-- add the drag handler so they can move the window around
Left = Right + ButtonGap
movewindow.add_drag_handler (WinName, Left, 0, 0, THeight)
--draw title text
if sLookTitle == nil then
sLookTitle = "scan"
end
sTitleText = sLookTitle .. " - " .. WinName:gsub("^.", string.upper):sub(-4, -1)
TextWidth = WindowTextWidth (WinName, FontId, sTitleText)
if TextWidth > Width - (Left + TextWidth) then
sTitleText = sTitleText:sub(1, math.modf ((Width / 1.5) / WindowFontInfo (WinName, FontId, 6))) .. "..."
TextWidth = WindowTextWidth (WinName, FontId, sTitleText)
end
Left = Right + ButtonGap
Right = Left + TextWidth
Top = LineSpace
Bottom = Top + FontHeight
WindowText (WinName, FontId, sTitleText, Left, Top, Right, Bottom, TitleColour, false)
--draw lines from stylesT
Top = FontHeight + LineSpace + OffSet
Left = 0
iLin = 0
t = { ["(Trans.) "] = "",
["(W.Aura) "] = "",
["(Linkdead) "] = "",
["(Charmed) "] = "",
["(Anim.) "] = ""
}
for i,v in ipairs (stylesT) do
Left = OffSet
Bottom = Top + FontHeight
sLine = ""
iLin = iLin + 1
for j,w in ipairs (v) do
Right = Left + WindowTextWidth (WinName, FontId, w.text)
Left = Left + WindowText (WinName, FontId, w.text, Left, Top, Right, Bottom, w.textcolour, false)
sLine = sLine .. w.text:gsub ("[,.';:]", "")
end
if bMenu then
for k in sLine:gmatch (" %- (.+)$") do
s = k:gsub ("(%(.+%) )",
function (str)
return t [str]
end)
if s:match(" ") then
s = s:match (" ([%a%d]+)$")
end
s = s .. ":" .. iLin .. ":" .. WinName
WindowAddHotspot (WinName, s, OffSet, Top, Right, Bottom, "", "", "", "", "Menu", "Right Click for menu. CTRL Left Click to copy keyword to clipboard", 1, 0)
end
end
Top = Bottom + LineSpace
end
--show the window
WindowShow (WinName)
end --ShowWindow
--send look or scan to refresh window
function Refresh (sWin)
if sWin:match("scan") then
SetVariable ("doscan", "true")
SendNoEcho ("scan")
elseif sWin:match("look") then
SetVariable ("dolook", "true")
SendNoEcho ("look")
end
end -- refresh
--set vaiable to allow ShowWindow to display window
function Restore (id, hotspotid)
if hotspotid:match("scan") then
SetVariable ("doscan", "true")
SendNoEcho ("scan")
elseif hotspotid:match("look") then
SetVariable ("dolook", "true")
SendNoEcho ("look")
end
end -- Restore
--display small window as when minimize clicked
function Minimize (flags, hotspotid)
--get window name
WinName = hotspotid
--set the window object table based on hotspotid
if hotspotid:match("scan") then
WinT = ScanWinT
sTit = "Scan"
elseif hotspotid:match("look") then
WinT = LookWinT
sTit = "Look"
else
Note("Minimize: no window object table.")
end
--window is minimized don't update
SetVariable ("do" .. sTit, "false")
--title banner width
Twidth = WindowTextWidth (WinName, FontId, sTit) + LFontSize + (OffSet * 2) + ButtonGap + (BorderWidth * 2)
-- recreate the window the correct size and position
WindowCreate (WinName,
WinT.window_left,
WinT.window_top,
Twidth, -- width
THeight, -- height
WinT.window_mode, -- whatever
WinT.window_flags,
BackgroundColour)
-- draw drag bar rectangle
WindowRectOp (WinName, 2, BorderWidth, BorderWidth, Twidth , THeight, BannerColour)
--draw draw border
if ShowBorders then
WindowCircleOp (WinName, 2, 0, 0, Twidth, THeight, BorderColour, 0, BorderWidth, ButtonColour, 1, 5, 5)
else
BorderWidth = 0
end
--draw restore button
BoxSq = LFontSize
Left = OffSet
Top = (THeight / 2) - (BoxSq / 2)
Right = Left + BoxSq
Bottom = Top + BoxSq
WindowCircleOp (WinName, 2, Left, Top, Right, Bottom, ButtonBorderColour, 0, BorderWidth, ButtonColour, 0)
WindowAddHotspot(WinName, WinName, Left, Top, Right, Bottom, "", "", "","", "Restore", "Restore " .. sTit, 1, 0)
--draw title text
TextWidth = WindowTextWidth (WinName, FontId, sTit)
if TextWidth > Width / 2 then
sTitleText = sTitleText:sub(1, math.modf ((Width / 3) / WindowFontInfo (WinName, FontId, 6))) .. "..."
TextWidth = WindowTextWidth (WinName, FontId, sTitleText)
end
Left = Right + ButtonGap
Right = Left + TextWidth
Top = LineSpace
Bottom = Top + FontHeight
WindowText (WinName, FontId, sTit, Left, Top, Right, Bottom, TitleColour, false)
-- add the drag handler so they can move the window around
movewindow.add_drag_handler (WinName, Left, 0, Twidth, THeight)
--show the window
WindowShow (WinName)
end -- Minimize
--display menu when clicked
function Menu (flags, hotspotid)
if bit.band (flags, 0x20) ~= 0 then
--get the keyword from the hotspotid passed from the WindowAddHotspot
s = hotspotid:match("^([%a%d]+):%d+:.+$")
--get the window from hotspotid
sWin = hotspotid:match("^[%a%d]+:%d+:(.+)$")
--make the menu string
sMen = "^Action Menu|" .. "|Examine ".. s .. "|Look ".. s .. "|kill ".. s .. "|Kick ".. s .. "|Bash ".. s
--show the menu
result = WindowMenu (sWin, WindowInfo (sWin, 14), WindowInfo (sWin, 15), sMen)
--send the command from menu to the MUD
if result ~= "" then
Send (result)
end
elseif bit.band (flags, 0x02) ~= 0 then
--copy the keyword to the the clipboard
s = hotspotid:match("^(%a+):%d+:.+$")
SetClipboard(s)
end
end --Menu
--http://www.gammon.com.au/forum/bbshowpost.php?id=9594
function OnPluginInstall ()
require "movewindow"
sScanWin = GetPluginID () .. "scan"
sLookWin = GetPluginID () .. "look"
FontId = "fn"
-- install the window movement handler, get back the window position
ScanWinT = movewindow.install (sScanWin, 7) -- default to 7 (on right, center top/bottom)
-- make window so I can grab the font info for Scan Window
WindowCreate (sScanWin,
ScanWinT.window_left,
ScanWinT.window_top,
0, 0, -- width, height
ScanWinT.window_mode,
ScanWinT.window_flags,
BackgroundColour)
WindowFont (sScanWin, FontId, FontName, LFontSize, false, false, false, false, 0, 0)
FontHeight = WindowFontInfo (sScanWin, FontId, 1)
-- install the window movement handler, get back the window position
LookWinT = movewindow.install (sLookWin, 7) -- default to 7 (on right, center top/bottom)
-- make window so I can grab the font info for Scan Window
WindowCreate (sLookWin,
LookWinT.window_left,
LookWinT.window_top,
0, 0, -- width, height
LookWinT.window_mode,
LookWinT.window_flags,
BackgroundColour)
WindowFont (sLookWin, FontId, FontName, LFontSize, false, false, false, false, 0, 0)
FontHeight = WindowFontInfo (sLookWin, FontId, 1)
--title border height
THeight = FontHeight + (LineSpace * 2.3) - BorderWidth
--convert colour variables to Lua codes
if tostring (BackgroundColour):match ("%a") then
BackgroundColour = ColourNameToRGB (BackgroundColour)
end
if tostring (TitleColour):match ("%a") then
TitleColour = ColourNameToRGB (TitleColour)
end
if tostring (BannerColour):match ("%a") then
BannerColour = ColourNameToRGB (BannerColour)
end
if tostring (ButtonColour):match ("%a") then
ButtonColour = ColourNameToRGB (ButtonColour)
end
if tostring (ButtonBorderColour):match ("%a") then
ButtonBorderColour = ColourNameToRGB (ButtonBorderColour)
end
if tostring (BorderColour):match ("%a") then
BorderColour = ColourNameToRGB (BorderColour)
end
--set trigger option to echo room desc
if EchoDesc then
SetTriggerOption ("catch_desc", "omit_from_output", "0")
end
--enable trigger to send scan after experience from combat
if ScanAfterCombat then
EnableTrigger ("combat", true)
end
--set script to do look and scan, these are used to stop scan or look
SetVariable ("doscan", "true")
SetVariable ("dolook", "true")
--Set keys from global variables
SetKeys ()
OnPluginEnable () -- do initialization stuff
if ShowWelcome then
Note("Scan_Look.xml installed")
end
end --OnPluginEnable
function OnPluginEnable ()
-- if we are connected when the plugin loads, it must have been reloaded whilst playing
if IsConnected () then
OnPluginConnect ()
end -- if already connected
end -- OnPluginEnable
--http://www.gammon.com.au/forum/bbshowpost.php?id=8775
-- pull in telnet option handling
dofile (GetPluginInfo (GetPluginID (), 20) .. "telnet_options.lua")
function OnPluginConnect ()
TelnetOptionOn (TELOPT_ROOM_NAMES)
TelnetOptionOn (TELOPT_EXIT_NAMES)
end -- function OnPluginConnect
--http://www.gammon.com.au/forum/bbshowpost.php?id=9594
function OnPluginSaveState ()
-- save window current location for next time
movewindow.save_state (sLookWin)
movewindow.save_state (sScanWin)
end -- function OnPluginSaveState
function OnPluginClose()
WindowShow (sLookWin, false)
WindowShow (sScanWin, false)
TelnetOptionOff (TELOPT_ROOM_NAMES)
TelnetOptionOff (TELOPT_EXIT_NAMES)
end -- OnPluginClose
]]>
</script>
</muclient>
|