[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]  Getting Started
. . -> [Subject]  YouTube video showing how to make an inventory alias

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: YouTube video showing how to make an inventory alias
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)

Pages: 1  2  3  4 5  6  7  8  

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 05 Mar 2013 06:00 AM (UTC)  quote  ]
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 Panaku   (6 posts)  [Biography] bio
Date Tue 05 Mar 2013 05:51 AM (UTC)  quote  ]

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 Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Tue 01 Jan 2013 08:35 PM (UTC)  quote  ]
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


http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by CincyMush   (15 posts)  [Biography] bio
Date Mon 31 Dec 2012 10:00 AM (UTC)  quote  ]
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 Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 30 Dec 2012 09:43 PM (UTC)  quote  ]
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 Sun 30 Dec 2012 08:09 AM (UTC)  quote  ]
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  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 11 Dec 2012 06:51 AM (UTC)  quote  ]
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 Tiredchris   (17 posts)  [Biography] bio
Date Tue 11 Dec 2012 05:02 AM (UTC)  quote  ]
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  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 11 Dec 2012 02:44 AM (UTC)  quote  ]
Message
I'm not sure. Not all the callbacks are supported outside the plugin environment.

What's the objection to just making it a plugin? You have a plugin assistant to kick the process off.

- Nick Gammon

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

Posted by Tiredchris   (17 posts)  [Biography] bio
Date Tue 11 Dec 2012 12:28 AM (UTC)  quote  ]

Amended on Tue 11 Dec 2012 12:29 AM (UTC) by Tiredchris

Message
So something like, checking to see if the miniwindow is open for the first runing, use variables to set the miniwindow if it isnt there already. Then if the variables are already stored, move it to the window placement instead of creating the default location.

Then to reset, just delete the variables, maybe make an alias to do it.

Does this sound plausible?

I'd move the movewindow lua script into the main script as well of course.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 10 Dec 2012 11:35 PM (UTC)  quote  ]
Message
I think the movewindow stuff only works in a plugin. I suppose you could duplicate the general idea outside one, but it would be simpler to turn your code into a plugin.

- Nick Gammon

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

Posted by Tiredchris   (17 posts)  [Biography] bio
Date Mon 10 Dec 2012 10:38 PM (UTC)  quote  ]
Message
I was looking at your inventory plugin, specifically the part for window movement. The section it would be in would be at the top of the script (if you were just doing an alias and sending to script), at least from what I'm seeing. I'd like to be able to do this without a plugin though.

This is what I'm referring to:

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

Posted by Tiredchris   (17 posts)  [Biography] bio
Date Mon 10 Dec 2012 01:30 AM (UTC)  quote  ]
Message
Thanks allot nick :)
That helped allot definitely! Most of the triggers I want to do are like this so I'm definitely grateful for it.

Next is movable/resizing windows, but that is a different thread!

Thanks again!
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 09 Dec 2012 09:16 PM (UTC)  quote  ]
Message
Good point. In the original version the line which started the process off wasn't actually a line with a name on it. If we rejig a bit it works:


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

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

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

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

-- request who list

Send "who"

local who = {}
local max_width = WindowTextWidth (win, font, "Who List")

-- waiting to recieve who list

local line, wildcards, styles = wait.match ("[*", 10)

if not line then
  ColourNote ("white","blue","No who list recieved within 10 seconds")
  return
end -- if statement

-- loop until end of who list

while true do
 
  -- see if end of who list
  
  if not string.match (line, "^%[") then
    break
  end -- if

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

  line, wildcards, styles = wait.match ("*")

end -- while loop

require "tprint"
tprint (who)
end)   -- end of coroutine
</send>
  </alias>
</aliases>


Output now:


1:
  1:
    "textcolour"=12632256
    "backcolour"=0
    "length"=61
    "style"=0
    "text"="[IMP Djinn  Mag  ] [Discordia-GoS] Commander Astark Caldazar "
2:
  1:
    "textcolour"=12632256
    "backcolour"=0
    "length"=81
    "style"=0
    "text"="[ 97 Gargoy Gla  ] [Sehkma-Mem] Bethany slices and dices and makes Julienne cry! "
3:
  1:
    "textcolour"=12632256
    "backcolour"=0
    "length"=59
    "style"=0
    "text"="[ 91 Orc    Asn K] [Q-ool] Prince Dracmas <<Stalkingwolf>> "
4:
  1:
    "textcolour"=12632256
    "backcolour"=0
    "length"=59
    "style"=0
    "text"="[  7 Dracon Tem  ] [Discordia-FoD] Rizk the Academy Student"

- Nick Gammon

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

Posted by Tiredchris   (17 posts)  [Biography] bio
Date Sun 09 Dec 2012 12:41 AM (UTC)  quote  ]

Amended on Sun 09 Dec 2012 01:18 AM (UTC) by Tiredchris

Message
After doing the tprint test again, the capture isn't picking up the first person on the who list.

Edit: Should have picked up on that on your last post.
I'll have to think of a way to capture right after the prompt all the lines up to a blank line.
[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.


29,171 views.

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

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