Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ mobs from scan to miniwin

mobs from scan to miniwin

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Mahony   (27 posts)  Bio
Date Mon 13 Oct 2014 01:10 PM (UTC)
Message
Hi
I altered invetory miniwin example from this thread
http://www.gammon.com.au/forum/bbshowpost.php?id=9965&page=10
to capture mobs in my room from scan to miniwin. It works but has a little flaw. It doesn't work if the room is empty because there is no "trigger message" "Right here you see:"
I would like to clear the win or put there "Nothing here".
So I think I know where is the problem but I don't see how to fix it. I see the only way is completely different approach. I din't see easy fix to this code. Or is it possible?
Thanx for help

Here is the code:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, October 08, 2014, 3:49 PM -->
<!-- MuClient version 4.93 -->

<!-- Plugin "mahony_scan_win" generated by Plugin Wizard -->

<muclient>
<plugin
   name="mahony_scan_win"
   author="Mahony"
   id="c6dcb8a0fc4043d4a19fdcd7"
   language="Lua"
   save_state="y"
   date_written="2014-10-08 15:48:20"
   requires="4.93"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Aliases  -->

<aliases>
  <alias
   match="noscan"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
   local win = GetPluginID () .. "_scan"
   WindowShow (win, false)
</send>

  </alias>
  <alias
   match="scan_win"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

wait.make (function ()  -- coroutine starts here

-- request scan

Send "scan"

-- wait for scan to start

local x = wait.match ("Right here you see:", 10)

if not x then
  ColourNote ("white", "blue", "No scan received within 10 seconds")
  return
end -- if

local scant = {}
local max_width = WindowTextWidth (win, font, "Scan")

-- loop until end of inventory

while true do
  local line, wildcards, styles = wait.match ("*")

  -- see if end of scan

  if not string.match (line, "     - ") then
    break
  end -- if

  -- save scan line
  table.insert (scant, styles)
  -- work out max width
  max_width = math.max (max_width, WindowTextWidth (win, font, line))

end -- while loop

local font_height = WindowFontInfo (win, font, 1)

local window_width = max_width + 10
local window_height = font_height * (#scant + 2) + 10

-- make window correct size

WindowCreate (win, 
                 windowinfo.window_left, 
                 windowinfo.window_top, 
                 window_width, window_height,              -- width, height
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#373737") 

WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- add the drag handler so they can move the window around
  movewindow.add_drag_handler (win, 0, 0, 0, font_height)
  
-- heading line

WindowText (win, font, "Scan here", 5, 5, 0, 0, ColourNameToRGB  "yellow")

-- draw each scan line

local y = font_height * 2 + 5

for i, styles in ipairs (scant) do

  local x = 5
  for _, style in ipairs (styles) do
    x = x + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each scan item

WindowShow (win, true)


end)   -- end of coroutine

</send>
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[

require "wait"  -- for waiting for inventory lines
require "movewindow"  -- load the movewindow.lua module

win = GetPluginID () .. "_scan"
font = "f"

function OnPluginInstall ()

  -- install the window movement handler, get back the window position
  windowinfo = movewindow.install (win, 6)  -- default to 6 (on top right)
  
  -- make window so I can grab the font info
  WindowCreate (win, 0, 0, 0, 0, 1, 0, 0)

  -- add the font                 
  WindowFont (win, font, "Lucida Console", 9)  
    
end -- OnPluginInstall

function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState


]]>
</script>
</muclient>
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #1 on Mon 13 Oct 2014 04:24 PM (UTC)
Message
What if you clear it every time you scan and then refill it when the trigger fires?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Mahony   (27 posts)  Bio
Date Reply #2 on Mon 13 Oct 2014 07:11 PM (UTC)
Message
Oh crap. Beauty of simplicity. Trying to code that but because I just altered this scipt and I still don't know exactly how it works may I ask for the code that would fix it?
Thank you!
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #3 on Mon 13 Oct 2014 07:35 PM (UTC)
Message
This is the line that clears the window:
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)


Maybe change
-- request scan

Send "scan"

-- wait for scan to start


to

-- request scan

Send "scan"
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- wait for scan to start

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Mahony   (27 posts)  Bio
Date Reply #4 on Mon 13 Oct 2014 07:54 PM (UTC)
Message
It seems it is not enough. It does nothing. May be recreate the window or run WindowShow?
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #5 on Mon 13 Oct 2014 08:22 PM (UTC)

Amended on Mon 13 Oct 2014 08:25 PM (UTC) by Fiendish

Message
You're right. I didn't read carefully, sorry.

You'll need to move the part where it creates the window

local font_height = WindowFontInfo (win, font, 1)

local window_width = max_width + 10
local window_height = font_height * (#scant + 2) + 10

-- make window correct size

WindowCreate (win, 
                 windowinfo.window_left, 
                 windowinfo.window_top, 
                 window_width, window_height,              -- width, height
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#373737") 

WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- add the drag handler so they can move the window around
  movewindow.add_drag_handler (win, 0, 0, 0, font_height)
  
-- heading line

WindowText (win, font, "Scan here", 5, 5, 0, 0, ColourNameToRGB  "yellow")


to happen before you ask for the mob list.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Mahony   (27 posts)  Bio
Date Reply #6 on Mon 13 Oct 2014 09:11 PM (UTC)
Message
Sooo. Here is to code that works "somehow". I do feel that it is not optimal and efficient code. When there ARE mobs in my room I still see the first window with "Nothing here!" flick and then it is redrawn. It would need some optimalization. :)
Thanx very much anyway.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, October 08, 2014, 3:49 PM -->
<!-- MuClient version 4.93 -->

<!-- Plugin "mahony_scan_win" generated by Plugin Wizard -->

<muclient>
<plugin
   name="mahony_scan_win"
   author="Mahony"
   id="c6dcb8a0fc4043d4a19fdcd7"
   language="Lua"
   save_state="y"
   date_written="2014-10-08 15:48:20"
   requires="4.93"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Aliases  -->

<aliases>
  <alias
   match="noscan"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
   local win = GetPluginID () .. "_scan"
   WindowShow (win, false)
</send>

  </alias>
  <alias
   match="scan_win"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

wait.make (function ()  -- coroutine starts here

-- request scan

Send "scan"
local scant = {}
local font_height = WindowFontInfo (win, font, 1)
local max_width = WindowTextWidth (win, font, "Nothing here!")
local window_width = max_width + 10
local window_height = font_height * (#scant + 2) + 10

-- make window correct size

WindowCreate (win, 
                 windowinfo.window_left, 
                 windowinfo.window_top, 
                 window_width, window_height,              -- width, height
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#373737") 

WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- add the drag handler so they can move the window around
  movewindow.add_drag_handler (win, 0, 0, 0, font_height)
  
-- heading line

WindowText (win, font, "Scan here", 5, 5, 0, 0, ColourNameToRGB  "yellow")
WindowText (win, font, "Nothing here!", 5, 20, 0, 0, ColourNameToRGB  "red")
WindowShow (win, true)

-- wait for scan to start

local x = wait.match ("Right here you see:", 10)

--if not x then
--  ColourNote ("white", "blue", "No scan received within 10 seconds")
--  return
--end -- if



-- loop until end of inventory

while true do
  local line, wildcards, styles = wait.match ("*")

  -- see if end of scan

  if not string.match (line, "     - ") then
    break
  end -- if

  -- save scan line
  table.insert (scant, styles)
  -- work out max width
  max_width = math.max (max_width, WindowTextWidth (win, font, line))

end -- while loop

local font_height = WindowFontInfo (win, font, 1)

local window_width = max_width + 10
local window_height = font_height * (#scant + 2) + 10

-- make window correct size

WindowCreate (win, 
                 windowinfo.window_left, 
                 windowinfo.window_top, 
                 window_width, window_height,              -- width, height
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#373737") 

WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- add the drag handler so they can move the window around
  movewindow.add_drag_handler (win, 0, 0, 0, font_height)
  
-- heading line

WindowText (win, font, "Scan here", 5, 5, 0, 0, ColourNameToRGB  "yellow")

-- draw each scan line

local y = font_height * 2 + 5

for i, styles in ipairs (scant) do

  local x = 5
  for _, style in ipairs (styles) do
    x = x + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each scan item

WindowShow (win, true)


end)   -- end of coroutine

</send>
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[

require "wait"  -- for waiting for inventory lines
require "movewindow"  -- load the movewindow.lua module

win = GetPluginID () .. "_scan"
font = "f"

function OnPluginInstall ()

  -- install the window movement handler, get back the window position
  windowinfo = movewindow.install (win, 6)  -- default to 6 (on top right)
  
  -- make window so I can grab the font info
  WindowCreate (win, 0, 0, 0, 0, 1, 0, 0)

  -- add the font                 
  WindowFont (win, font, "Lucida Console", 9)  
    
end -- OnPluginInstall

function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState


]]>
</script>
</muclient>
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.


19,649 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.