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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Getting Started
. . -> [Subject]  Video showing how to make an inventory alias
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Video showing how to make an inventory alias

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


Pages: 1  2 3  4  5  6  7  8  9  10  

Posted by Jocan   (2 posts)  [Biography] bio
Date Reply #15 on Sat 13 Mar 2010 07:35 AM (UTC)
Message
Greetings I had the same tag problem in inventory

( 2 ) Insert name here

wich block the inventory to work.

The mud im playing on doesnt have the nice little tags so i was wondering if there was a change you could help me setting up an expetion so it include these (*) before the inventory.

Im totally clueless....
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #16 on Sat 13 Mar 2010 09:11 PM (UTC)
Message
Can you show the whole inventory list to put it into context please? Including the first line or two that is *not* in the inventory.

- Nick Gammon

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

Posted by Jocan   (2 posts)  [Biography] bio
Date Reply #17 on Mon 15 Mar 2010 04:16 PM (UTC)
Message
Here is an example
(126/144hp 144/144m 100/100mv) 
i
You are carrying:
     (Glowing) a silver ring carved in the shape of a snake's tail
( 2) an iron kite shield
     a ringmail shirt
     (Humming) a bloodstained steel bardiche
     (Glowing)(Humming) a potion of haste
     a bronze necklace
     a consecrated iron hammer
     a floating disc

(126/144hp 144/144m 100/100mv) (126/144hp 144/144m 100/100mv) 
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #18 on Mon 15 Mar 2010 08:24 PM (UTC)
Message
This should work (two lines changed in bold):


<aliases>
  <alias
   name="inv"
   match="inv"
   enabled="y"
   send_to="12"
   sequence="40"
  >
  <send>require "wait"

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


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

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

-- request inventory

Send "inventory"


-- wait for inventory to start

local x = wait.match ("*You are carrying:", 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 ("*", 0, trigger_flag.OmitFromOutput)

  -- see if end of inventory

  if not string.match (line, "^     ") and
     not string.match (line, "^%([ %d]%d%) ") 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, 4, 0, ColourNameToRGB "#373737")
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 + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each inventory item

WindowShow (win, true)


end)   -- end of coroutine</send>
  </alias>
</aliases>


- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #19 on Sun 02 May 2010 05:55 AM (UTC)
Message
In response to a query about how to move the window around, I have changed the alias into a plugin, and added a few extra lines that allow you to drag the inventory around by clicking on the top line (the one with Inventory on it).

Template:saveplugin=Inventory_Miniwindow_Demo To save and install the Inventory_Miniwindow_Demo plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Inventory_Miniwindow_Demo.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Inventory_Miniwindow_Demo.xml (which you just saved in step 3) as a plugin
  7. Click "Close"


If you use this, remove your alias otherwise you will have two lots of inventory windows (the alias is now in the plugin).


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, May 02, 2010, 3:37 PM -->
<!-- MuClient version 4.51 -->

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

<muclient>
<plugin
   name="Inventory_Miniwindow_Demo"
   author="Nick Gammon"
   id="e49156f49854904ea8b90223"
   language="Lua"
   purpose="Shows Inventory in a miniwindow"
   save_state="y"
   date_written="2010-05-02 15:35:51"
   requires="4.51"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Type "inv" to see your inventory in a miniwindow.
]]>
</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   match="inv"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

wait.make (function ()  -- coroutine starts here
  
  -- request inventory
  
  Send "inventory"
  
  
  -- wait for inventory to start
  
  local x = wait.match ("You are carrying:", 10)
  
  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 ("*")
  
    -- see if end of inventory
  
    if not 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, 
                 windowinfo.window_left, 
                 windowinfo.window_top, 
                 window_width, window_height,              -- width, height
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#373737") 
                   
  -- draw border
  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, "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 + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
    end -- for
    y = y + font_height
  
  end -- for each inventory item
  
  -- now show the window
  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 () .. "_inventory"
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>


- Nick Gammon

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

Posted by Leonhardt   (24 posts)  [Biography] bio
Date Reply #20 on Sat 28 Aug 2010 05:30 AM (UTC)
Message
Is there any way to remove the output from the screen because when I get all from backpack it overloads and boots me. And I cant seem to get the solution posted here to work where you edit the lua.wait file. PLEASE HELP ME.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #21 on Sat 28 Aug 2010 08:29 PM (UTC)
Message
Which version of MUSHclient are you using? Can you post the code you have written, and which doesn't work?

- Nick Gammon

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

Posted by Leonhardt   (24 posts)  [Biography] bio
Date Reply #22 on Sun 29 Aug 2010 09:27 AM (UTC)
Message
require "wait"

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


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

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

-- request inventory

Send "inventory"


-- wait for inventory to start

local x = wait.match ("*In your inventory:", 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 ("*", 0, trigger_flag.OmitFromOutput)

-- see if end of inventory

if not string.match (line, "^ ") and
not string.match (line, "^%([ %d]%d%) ") 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 "#373737")
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 + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
end -- for
y = y + font_height

end -- for each inventory item

WindowShow (win, true)


end)










Using Ver. 4.43

This is the script im using it creates the window fine I just cant figure out how to remove the inventory from the output and leave it in the miniwindow.
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #23 on Sun 29 Aug 2010 10:05 AM (UTC)
Message
That seems like it should work. You're passing trigger_flag.OmitFromOutput to wait.match, and I just looked and it does properly pass that flag to MUSHclient. So it shouldn't be visible, unless it's not matching at all.

Also, what you said here confuses me:
Leonhardt said:
when I get all from backpack it overloads and boots me.

By "boots me", do you mean that the MUD actually disconnects you? That's not something we can fix by gagging output. Gagging just hides things client-side, it changes nothing about what's sent between the client and the MUD.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #24 on Sun 29 Aug 2010 11:12 AM (UTC)
Message
Version 4.46 had the stuff in wait.lua that omits the inventory from your output. I suggest upgrading.

The latest version is available from here:

http://www.gammon.com.au/forum/?bbtopic_id=1

- Nick Gammon

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

Posted by Leonhardt   (24 posts)  [Biography] bio
Date Reply #25 on Sun 19 Sep 2010 09:24 PM (UTC)
Message
Is there a way to slow down input to the mud for getting/putting thing in backpacks like how you can for speedwalks?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #26 on Sun 19 Sep 2010 10:36 PM (UTC)
Message
Can you start a new thread please? This is not directly to do with making a window showing your inventory.

- Nick Gammon

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

Posted by Tseris   (98 posts)  [Biography] bio
Date Reply #27 on Fri 14 Jan 2011 12:26 AM (UTC)
Message
Having trouble getting my inventory miniwindow to end the list at the prompt.

Heres my prompt:

[Cor:5000 Ener:9000 Blood:7316 ]>


Heres my trigger:

Send "inventory"
  
  
  -- wait for inventory to start
  
  local x = wait.match ("*You are carrying:", 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 ("*", trigger_flag.OmitFromOutput)
  
    -- see if end of inventory
  
    if string.match (line, "^[Cor*") 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




Heres my error message:


Error raised in trigger function (in wait module)
stack traceback:
        [C]: in function 'match'
        [string "Alias: "]:29: in function <[string "Alias: "]:3>
Run-time error
Plugin: Inventory_Miniwindow_Demo (called from world: Animus)
Function/Sub: wait.trigger_resume called by trigger
Reason: processing trigger "wait_trigger_38"
C:\Users\Nihilism\Desktop\MUSHclient\lua\wait.lua:67: [string "Alias: "]:29: malformed pattern (missing ']')
stack traceback:
        [C]: in function 'error'
        C:\Users\Nihilism\Desktop\MUSHclient\lua\wait.lua:67: in function <C:\Users\Nihilism\Desktop\MUSHclient\lua\wait.lua:59>

[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #28 on Fri 14 Jan 2011 02:14 AM (UTC)
Message
Lua regular expressions (and indeed MUSHclient ones) don't allow for solitary square brackets like that since they have a special meaning. They need to be "escaped". For regular expressions in triggers you put a backslash in front of them. For string.match you put a % symbol in front of them.

So, change:


    if string.match (line, "^[Cor*") then


to:


    if string.match (line, "^%[Cor") then

- Nick Gammon

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

Posted by Tseris   (98 posts)  [Biography] bio
Date Reply #29 on Fri 14 Jan 2011 02:22 AM (UTC)
Message
Ah see I just realized that when I pasted it on the forum, it didnt appear, but I knew it had to be escaped and used the backslash character right before the [, as outlined in

http://www.gammon.com.au/mushclient/funwithtriggers.htm

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


112,768 views.

This is page 2, subject is 10 pages long:  [Previous page]  1  2 3  4  5  6  7  8  9  10  [Next page]

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]