A little background... i play exile (exile.lurker.net 4000)on a windows 7 machine. I need some assistance with an error in a miniwindow. Enclosed is script for a plugin that displays equipment on my person, that needs either oiling or repairing. When an 'assess' command is ran and an item needs tending, it shoots it to a mini window. Displaying only the items that duration falls to fair or below and items that condition falls to good or below. After fixing each item, is where the problem lies. Once already oiled or repaired, i re-run the 'assess' command and the items that were in the mini window, still appear in the mini window until later in the game when a different piece of equip. needs tending. Any ideas? Some fresh eyes would be appreciated. Thanks ~Eyes
<!-- MuClient version 4.37 -->
<muclient>
<plugin
name="Assess_Window"
author="Nick Doyle"
id="fd1a20e303e48b78eceb123d"
language="Lua"
purpose="Redirects Fair or worse to a miniwindow"
date_written="2009-02-03 17:00"
requires="4.37"
version="1.0"
>
</plugin>
<!-- Triggers -->
characters displayed.
<triggers>
<trigger
enabled="y"
match="Dur: *Con: *"
script="assess"
name="assess"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="*"
script="assess"
name="assess_end"
sequence="10"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
-- configuration
require "checkplugin"
require "commas"
-- font
FONT_NAME = "Lucida Console"
FONT_SIZE = 9
-- where to put the window
WINDOW_POSITION = 6 -- see below (4 is top left)
MAX_STRING = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
--[[
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
--]]
-- colours
window_bg_color = ColourNameToRGB ("violet")
window_text_color = ColourNameToRGB ("#002800")
title_color = ColourNameToRGB ("white")
map_lines = {}
max_width = 0
function Display_Line (line, styles)
local left = 10
local top = (line - 1) * font_height + 5
for _, v in ipairs (styles) do
display_text = v.text
--if string.find(display_text, "]") ~= nil then
-- display_text = string.sub(display_text, string.find(display_text, "]") + 1)
--display_text = string.sub(display_text, string.find(display_text, "]") + 1)
--if string.find(display_text, "(") ~= nil then
-- display_text = string.sub(display_text, 1, string.find(display_text, "(") - 1)
--end
--end
left = left + WindowText (win, "f", display_text,
left, top, 0, 0, v.textcolour)
end -- for each style run
end -- Display_Line
function Display_Map ()
local width = max_width * font_width + 50
local height = (#map_lines + 1) * font_height
-- recreate the window the correct size
check (WindowCreate (win,
0, 0, -- left, top (auto-positions)
width, -- width
height, -- height
8, -- auto-position: bottom right
0, -- flags
window_bg_color) )
-- DrawEdge rectangle
check (WindowRectOp (win, 5, 0, 0, 0, 0, 10, 15))
WindowDeleteAllHotspots (win)
-- title rectangle
--check (WindowRectOp (win, 2, 2, 2, -2, font_height * 2 + 10, title_color))
--check (WindowRectOp (win, 5, 2, 2, -2, font_height * 2 + 10, 5, 8))
-- display each line
for i, v in ipairs (map_lines) do
Display_Line (i, v)
end -- for
-- make_hyperlink ("?", "back_colour", width - 15, height - 5 - font_height,
-- hyperlink_configure_background, "Choose background colour")
-- make_hyperlink ("?", "title_color", width - 15, font_height + 5,
-- hyperlink_configure_title, "Choose title colour")
-- show it now (or refresh)
WindowShow (win, true)
end -- Display_Map
-- processes all triggers
function assess (name, line, wildcards, styles)
if name == "assess_end" and string.find(line, "Dur:") == nil then
map_lines = {}
max_width = 0
end
show_line = 0
if(string.find(line, "Dur: Fair") ~= nil) then show_line = 1 end
if(string.find(line, "Con: Good") ~= nil) then show_line = 1 end
--if(string.find(line, "Con: Excellent") ~= nil) then show_line = 1 end
local len = #line
if(show_line == 1) then
table.insert (map_lines, styles)
max_width = math.max (max_width, len)
Display_Map ()
end
end -- end assess
-- hide window on removal
function OnPluginClose ()
WindowShow (win, false) -- hide it
end -- OnPluginClose
-- hide window on disable
function OnPluginDisable ()
WindowShow (win, false) -- hide it
end -- OnPluginDisable
-- show window on enable
function OnPluginEnable ()
if exits then
WindowShow (win, true) -- show it
end -- if
end -- OnPluginEnable
-- startup stuff
win = GetPluginID () -- get a unique name
-- make the window with zero size to load the font into
WindowCreate (win, 0, 0, 0, 0, WINDOW_POSITION, 0,
window_bg_color) -- create window
-- grab a font
WindowFont (win, "f", FONT_NAME, FONT_SIZE) -- define font
-- work out how high it is
font_height = WindowFontInfo (win, "f", 1) -- height of the font
font_width = WindowFontInfo (win, "f", 6)
]]>
</script>
</muclient>
[EDIT] Edited by Nick to add code tag. |