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.
 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ MAP / INVENTORY CAPTURE

MAP / INVENTORY CAPTURE

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


Posted by Fubar   (3 posts)  Bio
Date Thu 09 May 2024 03:08 PM (UTC)
Message
I am trying to capture the map but in a different way.

The map looks like this:

https://imgur.com/a/Gi1RMdF

And I figure I could use the inventory alias to make a window to show it.

Using this:

https://pastebin.com/enrKY0t6

It is not capturing anything.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 10 May 2024 08:58 PM (UTC)
Message
It's better to include the code in the post:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, May 08, 2024, 9:05 AM -->
<!-- MuClient version 5.06 -->

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

<muclient>
<plugin
   name="FA_INVENTORY_WINDOW"
   author="Fubar"
   id="ac4a0f3cff844292345979a6"
   language="Lua"
   purpose="Create an inventory window."
   date_written="2024-05-08 09:02:52"
   requires="5.06"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This will create a small window that scales to the size of your screen. This window will show current inventory. This includes the window and triggeres to make this work.
]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Aliases  -->

<aliases>
  <alias
   match="map"
   enabled="y"
   group="INVENTORY"
   send_to="12"
   omit_from_output="y"
   sequence="100"
  >
  <send>

require "wait"

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


local win = GetPluginID () .. ":inventory"
local font = "f"

WindowDelete (win)

if not WindowInfo (win, 1) then
  WindowCreate (win, 0, 0, 0, 0, 6, 0, 0)
  WindowFont (win, font, "Courier New", 9)  
end -- if

-- request inventory

Execute ("map", 0, trigger_flag.OmitFromOutput)


-- wait for inventory to start

local x = wait.match ("^--\> *", 10, trigger_flag.OmitFromOutput)

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

local inv = {}
local max_width = WindowTextWidth (win, font, "Inventory")

-- loop until end of inventory

while true do
  local line, wildcards, styles = wait.match ("\S\s\n\t\r\n\f.+.*", 0, trigger_flag.OmitFromOutput)

  -- see if end of inventory

  if string.match (line, "^----\> *") then
    break
  end -- if

  -- save inventory line
  table.insert (inv, 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 * (#inv + 2) + 10

-- make window correct size

WindowCreate (win, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB "#000000")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText (win, font, "Inventory:", 5, 5, 0, 0, ColourNameToRGB  "yellow")

-- draw each inventory line

local y = font_height * 2 + 5

for i, styles in ipairs (inv) do

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

end -- for each inventory item

WindowShow (win, true)


end)   -- end of coroutine

</send>
  </alias>
  <alias
   match="nomap"
   enabled="y"
   group="INVENTORY"
   send_to="12"
   sequence="100"
  >
  <send>

local win = GetPluginID () .. ":inventory"

WindowShow (win, false)

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

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="FA_INVENTORY_WINDOW:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 10 May 2024 08:59 PM (UTC)
Message
To explore why it's not capturing anything please copy and paste here the text you are trying to match on.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fubar   (3 posts)  Bio
Date Reply #3 on Sat 11 May 2024 07:23 PM (UTC)

Amended on Sat 11 May 2024 07:25 PM (UTC) by Fubar

Message

MAP
|||__   ___   __|||                R        ^ ^               ~       ~         
|  ||   |||   ||  |         "                  ^                       ~        
|       |||       |              n^H^n "      "^    ~ _                         
|       | |      "|           S"^nn n^     "  ^    ~  | ^^^ ^                   
|    "        "   |       " R   n     n        ^      |^___^n        ~   ~ ~    
|      _   _      |       "   n^~    ^n              n| |||^@n ~               ^
_______|   |______|       "    @n   ^n            ^ ~n n| |n|n           ~    ^@
||||||||"  ||||||||         R  |@nnnn  R           ^  n     n    ~~    ~~   ^ @@
~ nn^      "    "              "|@@~^@       "     ^   n| |n               ^"@^@
   n^        R  @   ___ @    n   @| @|              ^   | |        ~ ~    ^ n^ ^
n   n^         @| @@||| @@@    " |@ |@             ^  ^^| |^n^^    ~  ^^^^@@@   
^^   n^      @ ||@|@||| |@|     @  @~ @@   @      ^  ^_ | |"_  ^    ^^@ @@@H@n n
  ^ R n^     @@ n|@@||| @|@    @   |  @|  "|     ^  ^ | @ @ | @ ^^^^   @  @ n@@@
   ^   n^"   |@n n||||| @@|    @       @ @ |   ^^  ^  | @  @| |  R   R       "" 
  0 ^  n^     |@@ nn| | ||    @  :   ~ @ |    ^~~  ^  @ n@  @      "           n
R "^    n^     |@   @ @@ o R n@  ~   ~@   o  ^  ~  n^^|   @  @@@@@@@@@@@@@@@@@@@
  R~ nn  n^     | R    | @    o@  ~ H@    ""^       nn^^ n @                    
@@n~@^^  n^@@   | nn   |@^^@    @@@@@     ^            n^   @ @@@@@@@@@@@@@@@@@@
||n^| n^ n^@@     n    @^@@^@    "      ^      ~         ^  @ @          "      
   ^ H n^n^|@@         ^@ n^@@ "       ^   ~ ~    n^^^n   ^ @ @      n      n   
 n  ^0 ^   ^@@@  R  "  ^|  ^@@"n      ^          n^___^n   ^@ @                 
 ~   ^^ ~   ^@@      n @^^^@@|    @   ^      ~ ~ n^| |^n   ^| @ n        @|||||@
           n ^@      n |@@@@| R n |   ^           ^@ @^    ^  @"         |     |
ENDMAP


MAP <--before the map

ENDMAP <--after the map
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 12 May 2024 04:44 AM (UTC)
Message
You didn't look for the words "MAP" or "ENDMAP". I've tweaked a few things, see if that works better:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, May 08, 2024, 9:05 AM -->
<!-- MuClient version 5.06 -->

<muclient>
<plugin
   name="MY_MAPPER"
   author="Fubar"
   id="ac4a0f3cff844292345979a6"
   language="Lua"
   purpose="Create a map window."
   date_written="2024-05-08 09:02:52"
   requires="5.06"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This will create a small window that scales to the size of your screen. This window will show current map. This includes the window and triggeres to make this work.
]]>
</description>

</plugin>

<!--  Aliases  -->

<aliases>
  <alias
   match="map"
   enabled="y"
   group="INVENTORY"
   send_to="12"
   omit_from_output="y"
   sequence="100"
  >
  <send>

require "wait"

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


local win = GetPluginID () .. ":map"
local font = "f"

WindowDelete (win)

if not WindowInfo (win, 1) then
  WindowCreate (win, 0, 0, 0, 0, 6, 0, 0)
  WindowFont (win, font, "Courier New", 9)  
end -- if

-- request map

SendNoEcho("map")


-- wait for inventory to start

local x = wait.match ("MAP", 10, trigger_flag.OmitFromOutput)

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

local inv = {}
local max_width = WindowTextWidth (win, font, "Map:")

-- loop until end of map

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

  -- see if end of inventory

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

  -- save map line
  table.insert (inv, 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 * (#inv + 2) + 10

-- make window correct size

WindowCreate (win, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB "#000000")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText (win, font, "Map:", 5, 5, 0, 0, ColourNameToRGB  "yellow")

-- draw each inventory line

local y = font_height * 2 + 5

for i, styles in ipairs (inv) do

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

end -- for each inventory item

WindowShow (win, true)


end)   -- end of coroutine

</send>
  </alias>
  <alias
   match="nomap"
   enabled="y"
   group="INVENTORY"
   send_to="12"
   sequence="100"
  >
  <send>

local win = GetPluginID () .. ":map"

WindowShow (win, false)

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

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="MY_MAPPER:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script> 

</muclient>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fubar   (3 posts)  Bio
Date Reply #5 on Sat 25 May 2024 06:43 PM (UTC)
Message
That made mushclient lock up but i was able to use this.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, May 08, 2024, 9:05 AM -->
<!-- MuClient version 5.06 -->

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

<muclient>
<plugin
   name="FA_MAP_WINDOW"
   author="Fubar"
   id="55153a8014829a865bbf700d"
   language="Lua"
   purpose="MAP window."
   date_written="2024-05-08 09:02:52"
   requires="5.06"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This will create a small window that scales to the size of your screen. This window will show current inventory. This includes the window and triggeres to make this work.
]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   group="MAP"
   match="^North"
   name="maptrigger"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="1"
  >
  <send>Execute ("map", 0, trigger_flag.OmitFromOutput)

EnableTrigger("maptrigger", false)  -- disable trigger
DoAfterSpecial(2, "EnableTrigger ('maptrigger', true)", sendto.script)</send>
  </trigger>

</triggers>

<!--  Aliases  -->

<aliases>

  <alias
   match="map"
   enabled="y"
   group="MAP"
   send_to="12"
   omit_from_output="y"
   sequence="100"
  >
  <send>

require "wait"

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

    local win = GetPluginID() .. ":map"
    local font = "f"

    if not WindowInfo(win, 1) then
        WindowCreate(win, 0, 0, 0, 0, 6, 2, 0)
        WindowFont(win, font, "Courier New", 12)
    end

    -- Request map
    Execute("map", 0, trigger_flag.OmitFromOutput)

    -- Wait for map to start
    local x = wait.regexp("^MAP$", 10, trigger_flag.RegularExpression, trigger_flag.OmitFromOutput)

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

    local map = {}
    local max_width = 0
    local total_height = 0

    -- Loop until end of map lines till you reach endmap
    while true do
        local line, wildcards, styles = wait.regexp(".*", 0, trigger_flag.OmitFromOutput, trigger_flag.RegularExpression)

        -- See if end of map
        if string.match(line, "^ENDMAP$") then
            break
        end

        -- Save inventory line
        table.insert(map, styles)
        -- Work out max width
        max_width = math.max(max_width, WindowTextWidth(win, font, line))
        total_height = total_height + WindowFontInfo(win, font, 1)
    end

    local font_height = WindowFontInfo(win, font, 1)
    local window_width =  500 -- max_width + 10
    local window_height =  500 -- total_height + 10  -- Adjust the height to fit the content

    -- Make window correct size
    WindowCreate(win, 0, 0, window_width, window_height, 6, 0, ColourNameToRGB("#000000"))

    -- Draw each inventory line
    local y = font_height * 2 + 5

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

    WindowShow(win, true)
end)   -- end of coroutine

</send>
  </alias>
  <alias
   match="nomap"
   enabled="y"
   group="MAP"
   send_to="12"
   sequence="100"
  >
  <send>

local win = GetPluginID () .. ":map"

WindowShow (win, false)

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

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="FA_MAP_WINDOW:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[

-- 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 OnHelp ()
  world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</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.


2,253 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.