[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  error in miniwindow, cant figure out.

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: error in miniwindow, cant figure out.
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Fri 05 Aug 2011 10:41 PM (UTC)  quote  ]

Amended on Fri 05 Aug 2011 10:46 PM (UTC) by Nick Gammon

Message
I think your problem is here:


-- 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


Two Three things hit me here ...


  1. You are displaying all the data for every line, rather than at the end. This must be making the window flicker, surely?

  2. You clear the list of lines at the end (when you get a line without "Dur:" in it), rather than at the start. So you will have left-over from last time.

  3. Strike out the previous comment, as I did that too. Actually the problem is that if *no* item needs repairing you don't display the window again. So it stays there. This is part of problem #1.


So, although untested, I would revamp along these lines:


-- processes all triggers
function assess (name, line, wildcards, styles)
  if name == "assess_end" and 
     not string.find (line, "Dur:") then
    Display_Map ()   -- show all lines we found in map_lines table
    map_lines = {}   -- clear for next time
    max_width = 0
  end  -- if end of list
  
  -- see if we want to display this one
  if string.find (line, "Dur: Fair") or 
     string.find (line, "Con: Good") then
    table.insert (map_lines, styles)
    max_width = math.max (max_width, #line)
  end  -- if wanted

end -- end assess


I also simplified the "if" tests.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Eyes   USA  (4 posts)  [Biography] bio
Date Fri 05 Aug 2011 05:58 PM (UTC)  quote  ]

Amended on Fri 05 Aug 2011 10:32 PM (UTC) by Nick Gammon

Message
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.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


770 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]