[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 Tiredchris   (17 posts)  [Biography] bio
Date Reply #105 on Tue 11 Dec 2012 05:02 AM (UTC)
Message
I want to get to where I don't need to ask anymore about how the windows work. Slowly getting better at it, but allot still confuses me.

Also, for the mud I'm playing I've been noting everything on our own forums so other people can use mushclient as well. It'd be easier on some of them to just be able to select all and paste into the alias window.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #106 on Tue 11 Dec 2012 06:51 AM (UTC)
Message
Yes, but this is exactly what plugins were designed for.

To handle window dragging, your script has to respond to a mouse-down in the miniwindow. Now that isn't anything to do with someone typing an alias. And to handle loading stuff (like configuration) and saving stuff for next time, and other things, like doing something every minute, suddenly you are asking people to copy and paste a couple of aliases, copy and paste a couple of triggers, add a few timers, modify their script file, set the correct language, etc.

So instead of all this you say: download this file, install it, done!

That's what plugins are for.

- Nick Gammon

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

Posted by CincyMush   (15 posts)  [Biography] bio
Date Reply #107 on Sun 30 Dec 2012 08:09 AM (UTC)
Message
Just a quick question is there an easy way to omit this output from my main display since it is going to the window any way. I know triggers have the flag for omitting output is their something similar for aliases?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #108 on Sun 30 Dec 2012 09:43 PM (UTC)
Message
I'm pretty sure an "omit from output" flag was added, and is discussed in one of the earlier pages of this thread. Just browse through it to find it.

- Nick Gammon

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

Posted by CincyMush   (15 posts)  [Biography] bio
Date Reply #109 on Mon 31 Dec 2012 10:00 AM (UTC)
Message
Oh Sorry I missed that, since they had changed over to a trigger I glossed over it. One more question if I wanted to add a scroll bar to the inventory window and allow it to be resized what should I look at for reference?


Thanks
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #110 on Tue 01 Jan 2013 08:35 PM (UTC)
Message
Quote:
One more question if I wanted to add a scroll bar to the inventory window and allow it to be resized what should I look at for reference?


http://www.mushclient.com/forum/?id=10728&reply=82#reply82


https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Panaku   (34 posts)  [Biography] bio
Date Reply #111 on Tue 05 Mar 2013 05:51 AM (UTC)

Amended on Wed 06 Mar 2013 03:24 AM (UTC) by Panaku

Message
Trying to get this working in my mud and having some difficulties, I got past the first few problems and its not giving any errors for now.

When the alias fires it doesn't recognize that the inventory is being displayed, most likely because of how the inventory is listed in this mud.

<aliases>
  <alias
   name="Inventory_Script"
   match="inv"
   enabled="y"
   group="Inventory"
   send_to="12"
   sequence="100"
  >
  <send>require "wait"

wait.make (function ()

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, "FixedSys", 9)
end -- if

-- 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 receieved 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 string.match (line, "^(.*?) | [Pain: (.*?)") then
    break
  end -- if

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

end -- while loop

require "tprint"
tprint (inv)

end)</send>
  </alias>
</aliases>


Below is an example of output from my mud.
You are carrying four ruelbone monads, a bowie knife, a pair of green gauntlets, a pair of buckskin pants, a pair of green armwraps, a
silver-trimmed blue cloak, a wooden practice sword, and a canvas pouch.
-E-W-- | [Pain: 0 Fatigue: 0 Unbalance: 0 Fear: 0] |  [///] > 
The first few lines are my inventory and the last line is my prompt. Any suggestions on getting it to read each item?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #112 on Tue 05 Mar 2013 06:00 AM (UTC)
Message
Quote:


local x = wait.match ("You are carrying (.*?)", 10)



Change wait.match to wait.regexp, as that looks like a regular expression.

Or change it to:


local x = wait.match ("You are carrying *", 10)

- Nick Gammon

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

Posted by Curtis_D   (32 posts)  [Biography] bio
Date Reply #113 on Tue 01 Apr 2014 05:35 AM (UTC)

Amended on Tue 01 Apr 2014 01:15 PM (UTC) by Curtis_D

Message
I am baffled. I was able to get this to work in the past but now I’m running into an issue. The miniwindow is created and all the data is displayed inside as expected, but the text is not being omitted from the output window like I was striving for. I’m not sure if you would need to see the entire plugin since it seems to just be an issue with this section – I may have an error somewhere that I’m not seeing. I am operating on a Windows 8 computer, that wouldn’t cause an issue would it?

-- wait for list to start

local x = wait.match ("Player Name*", 10,  trigger_flag.OmitFromOutput)

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

local data = {}
local max_width = WindowTextWidth (win, font, "Players")

-- loop until end of data

while true do
  local line, wildcards, styles = wait.match ("*", trigger_flag.OmitFromOutput)
  -- see if end of data

  if string.match (line, "%d+ players are connected.  %(Max was %d+%)") then
    break
  end -- if


Does anyone have any suggestions? If necessary I'll update this message with the full plugin - I just pulled it from earlier in this thread and modified "inv" and "inventory" to "WHO" and "player list" respectively - and added the OmitFromOutput flags.

I had thought I was using the most current version of MushClient but I'll double check that as well when I have the chance, in case it needs it.

Thank you for your time,
Curtis
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #114 on Tue 01 Apr 2014 07:59 PM (UTC)
Message
Template:version Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.


State a number, not "the most current version".

- Nick Gammon

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

Posted by Curtis_D   (32 posts)  [Biography] bio
Date Reply #115 on Thu 03 Apr 2014 01:49 PM (UTC)

Amended on Thu 03 Apr 2014 01:50 PM (UTC) by Curtis_D

Message
Nick Gammon said:

(version)

State a number, not "the most current version".

Sorry, I didn't have my laptop with me at the time because I had emailed it to my work address to look over.

Version 4.84

Thank you
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #116 on Fri 04 Apr 2014 08:42 PM (UTC)
Message
The latest released version is 4.91.

http://www.gammon.com.au/forum/?id=12170

You might want to try that, however I'm not sure it will fix this particular problem.

- Nick Gammon

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

Posted by Curtis_D   (32 posts)  [Biography] bio
Date Reply #117 on Sat 05 Apr 2014 10:51 AM (UTC)
Message
Nick Gammon said:

The latest released version is 4.91.

http://www.gammon.com.au/forum/?id=12170

You might want to try that, however I'm not sure it will fix this particular problem.


Alright, completed.

I noticed something today that I hadn't noticed before. One line is being omited from the output - the first wait.match.

here's the entire thing:

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

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

<muclient>
<plugin
   name="PlayerList_Miniwindow_Demo"
   author="Nick Gammon, mod by Curtis_D"
   id="e49156f49854904ea8b90223"
   language="Lua"
   purpose="Shows list of players 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 "WHO" to see player list in a miniwindow.
]]>
</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   match="WHO"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
require "wait"

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


local win = GetPluginID () .. ":players"
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 online player list

Send "WHO"


-- wait for list to start

local x = wait.match ("Player Name*", 10,  trigger_flag.OmitFromOutput)

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

local data = {}
local max_width = WindowTextWidth (win, font, "Players")

-- loop until end of data

while true do
  local line, wildcards, styles = wait.match ("*", trigger_flag.OmitFromOutput)
  -- see if end of data

  if string.match (line, "%d+ players are connected.  %(Max was %d+%)") then
    break
  end -- if

  -- save data line
  table.insert (data, 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 * (#data + 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, "Players", 5, 5, 0, 0, ColourNameToRGB  "yellow")

-- draw each data line

local y = font_height * 2 + 5

for i, styles in ipairs (data) 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 data 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 () .. "_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>
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #118 on Sat 05 Apr 2014 08:09 PM (UTC)

Amended on Sat 05 Apr 2014 08:12 PM (UTC) by Nick Gammon

Message
The one with "Player name" in it? Yes, that isn't saved. Re-arrange a bit to do that:


-- wait for list to start

local line, wildcards, styles = wait.match ("Player Name*", 10,  trigger_flag.OmitFromOutput)

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

local data = {}

-- save first line
table.insert (data, styles)
-- max width initially is the width of the first line
local max_width = WindowTextWidth (win, font, line)

-- loop until end of data


I saved the first line into the "data" table, therefore that will appear in the miniwindow.

Not tested, but that is the general idea.

- Nick Gammon

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

Posted by Curtis_D   (32 posts)  [Biography] bio
Date Reply #119 on Sun 06 Apr 2014 03:35 AM (UTC)
Message
Nick Gammon said:

The one with "Player name" in it? Yes, that isn't saved. Re-arrange a bit to do that:


-- wait for list to start

local line, wildcards, styles = wait.match ("Player Name*", 10,  trigger_flag.OmitFromOutput)

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

local data = {}

-- save first line
table.insert (data, styles)
-- max width initially is the width of the first line
local max_width = WindowTextWidth (win, font, line)

-- loop until end of data


I saved the first line into the "data" table, therefore that will appear in the miniwindow.

Not tested, but that is the general idea.


Great, that would look better aesthetically. I'm still having the issue of my data not being omitted from the main window however. Should I look at the wait.match module to ensure it’s up to date as well, or would that have been updated when I updated mushclient? I’m at work again so I’ll have to look into it when I get home.
[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.


113,109 views.

This is page 8, 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]