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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Pages: 1  2  3  4  5  6  7 8  9  

Posted by Jsportive-Thalanvor   Netherlands  (71 posts)  [Biography] bio
Date Reply #90 on Sat 14 Apr 2012 10:09 PM (UTC)  quote  ]
Message
worked like a charm. i thank you.
[Go to top] top

Posted by Zedd   USA  (1 post)  [Biography] bio
Date Reply #91 on Tue 14 Aug 2012 09:16 PM (UTC)  quote  ]
Message
I followed your tutorial to the note and everything seems worked fine, but the width of the inventory is very long and it doesn't show everything.

Here's the picture: http://i47.tinypic.com/9jk9ol.png

I looked in the Index to find something to wrap the lines but I couldn't figure out how to do it.

If you could help that would be great! :) Thanks!
[Go to top] top

Posted by Nick Gammon   Australia  (19,385 posts)  [Biography] bio   Forum Administrator
Date Reply #92 on Wed 15 Aug 2012 06:09 AM (UTC)  quote  ]
Message
A simple approach might be to take the raw inventory line, split it at commas (using string.gmatch) and then put each part of the inventory onto its own line.

- Nick Gammon

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

Posted by Darcon   (26 posts)  [Biography] bio
Date Reply #93 on Fri 26 Oct 2012 07:29 AM (UTC)  quote  ]
Message
I seem to have the same problem as Holliday did. Example:

In your inventory:
a vorpal platinum knife of havok
(Ghostly) A Pillar of Blue Flame
an Aesthetic's red velvet robe
a golden sash of metallic silk
( 2) a ring of rough influence
( 2) (Glowing) an etched steel bracer
(Tanned) a beautiful fur cloak
(Woven) a pair of fur leggings
a cloak of displacement
a gladiator shoulder pad
a gold earring
an owl-shaped wooden mask
a mage's robe of electrical resistance
a pair of green dragonleather riding boots
(Glowing) a pair of Albino Sleeves
(Glowing) a golden tiara
A Pair of Roc Claws
the Sphere of Astinus
a heavy clipboard
a brilliant white aura
(dinged) a burnished steel shield

I changed the match line to "In your inventory:" so the alias will work. It Brings up the Inventory window like it is supposed to but only puts the items in it up to where I have more then one of the same item. I have tried to change the if statement to break the loop to several different things and nothing I try seems to work. Unfortunately the mud I play doesn't do Inventory tags like Holliday's does. I though maybe my prompt line would work to break the loop but I cannot seem to get that to work either. Maybe Someone can help me here. This is my prompt line.

<1421/1421HP 1622/1622MP 2044XP Phase On PET: 2098/2098hp 500/500mv>
[Go to top] top

Posted by Darcon   (26 posts)  [Biography] bio
Date Reply #94 on Fri 26 Oct 2012 07:38 AM (UTC)  quote  ]
Message
Never mind, I am an idiot sometimes. After reading some more of this topic... I.E. more pages ... I see that you already found and posted the solution to this problem.
[Go to top] top

Posted by Tiredchris   (17 posts)  [Biography] bio
Date Reply #95 on Sat 08 Dec 2012 08:08 PM (UTC)  quote  ]
Message
I'm trying to do this for the who list. I watched the first part of the youtube and entered in tprint at the end to make sure it worked.

What I'm looking for is when you type "who"
you get


[IMP Djinn  Mag  ] [Discordia-GoS] Commander Astark Caldazar 
[ 97 Gargoy Gla  ] [Sehkma-Mem] Bethany slices and dices and makes Julienne cry! 
[ 91 Orc    Asn K] [Q-ool] Prince Dracmas <<Stalkingwolf>> 
[  7 Dracon Tem  ] [Discordia-FoD] Rizk the Academy Student

Players found: 4


Here is the alias

<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"


-- waiting to recieve who list

local x = wait.match ("[", 10)

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

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

-- loop until end of who list

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

  -- 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))

end -- while loop

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


I'm not sure if it has to do with string.match or the brackets at this point, or if I just completely screwed up.

The first wait match was
local x = wait.match ("[", 10)

The end to see if it's the end of the list was:
if not string.match (line, "^[") then

I'm not sure if it's matching it before it goes into the string or not, so I dont know if it needs a backslash or a percent sign.

Or I could have messed up elsewhere. I get no errors, but it waits 10 seconds after I enter in the alias to tell me it didn't capture the who list.
[Go to top] top

Posted by Nick Gammon   Australia  (19,385 posts)  [Biography] bio   Forum Administrator
Date Reply #96 on Sat 08 Dec 2012 08:24 PM (UTC)  quote  ]
Message
wait.match takes "normal" wildcards, so you need to use an asterisk to indicate "and everything else", eg.


 local x = wait.match ("[*", 10)



Regular expressions (as in string.match) treat "[" as a special character (start of set) so you need to "escape" that, eg.



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


With those two changes, the new alias, namely this:


<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"


-- waiting to recieve who list

local x = wait.match ("[*", 10)

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

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

-- loop until end of who list

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

  -- 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))

end -- while loop

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


Gives this with your test data:


1:
  1:
    "textcolour"=12632256
    "backcolour"=0
    "length"=81
    "style"=0
    "text"="[ 97 Gargoy Gla  ] [Sehkma-Mem] Bethany slices and dices and makes Julienne cry! "
2:
  1:
    "textcolour"=12632256
    "backcolour"=0
    "length"=59
    "style"=0
    "text"="[ 91 Orc    Asn K] [Q-ool] Prince Dracmas <<Stalkingwolf>> "
3:
  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 Reply #97 on Sat 08 Dec 2012 10:43 PM (UTC)  quote  ]

Amended on Sat 08 Dec 2012 10:54 PM (UTC) by Tiredchris

Message
The next problem. I'm not getting everything in the miniwindow.

Here's the output while using the script.

<4465/4465hp 1083/1083mn 2063/2063mv 359etl Q Clan Area>  look
Before the Great Q Temple
  Before you stands the mighty hall of the Q clan.  I certainly hope you
are supposed to be here, because the rumours say that intruders are not
treated kindly inside the compound.  As you gaze upon the mighty structure,
your mind is warped and twisted in such strange ways...  How the HELL does
this thing stand without toppling over?!  Chances are, your mind will never
be free enough to be able to comprehend the answer.  

[Exits: north down]
     (Drunk) A drunken funny man is here, telling jokes.

<4465/4465hp 1083/1083mn 2063/2063mv 359etl Q Clan Area>  wholist
[IMP Djinn  Mag  ] [Discordia-GoS] Commander Astark Caldazar 
[GOD Dryad  Asn k] [Q-een] [AFK] * Lady Engel Shadowwalker 
[ 92 Mantis Gla  ] [Q-ool] Dozer. 
[ 91 Orc    Asn K] [Q-ool] Prince Dracmas <<Stalkingwolf>> 
[ 15 Gholam Asn k] [Discordia-FoD] Zion I 

Players found: 5

<4465/4465hp 1083/1083mn 2063/2063mv 359etl Q Clan Area> 


I type wholist, which is echoed on the end of the prompt. before the who list starts. The problem is that I'm not seeing everyone on the list. I sometimes miss 2 people in the plugin if I use a trigger to catch people logging on and send to:execute wholist.

Using the Alias. The first name that shows up on the wholist miniwindow is Lady Engel. She disappears from the list when executing "wholist alias" from another trigger.

Here's the Alias:

<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, 6, 0, 0)
  WindowFont (win, font, "Lucida Console", 9)
end -- if

-- request who list

Execute "who"


-- waiting to recieve who list

local x = wait.match ("[*", 10)

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

local whol = {} -- whol is who list as a table
local max_width = WindowTextWidth (win, font, "WhoList")

-- loop until end of who list

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

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

  -- save who list
  table.insert (whol, 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 * (#whol + 2) + 10

-- make window correct size

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

-- heading line

WindowText (win, font, "WhoList", 5, 5, 0, 0, ColourNameToRGB "yellow")

-- draw each who line

local y = font_height * 2 + 5

for i, styles in ipairs (whol) 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 person in who

WindowShow (win, true)

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



Edit: the trigger calling the alias where another name disappears off the miniwindow, being two players not showing instead of one is here:

<triggers>
  <trigger
   enabled="y"
   group="IM"
   match="[INFO]: * has decided to join us."
   send_to="10"
   sequence="100"
   sound="C:\Program Files (x86)\MUSHclient\sounds\Buddy In.mp3"
  >
  <send>wholist</send>
  </trigger>
</triggers>


I dont know if the who list right on the next line is causing it to miss the top player on here.

In the trigger that calls the alias when someone logs in, my command echo ends up on the info line, so my who list I need captureing, the first name ends up starting on the end of the prompt, then the 2nd name isnt shown.

<4465/4465hp 1083/1083mn 2063/2063mv 359etl Q Clan Area>  
You disappear into the void.look

<4465/4465hp 1083/1083mn 2063/2063mv 359etl Limbo>  Before the Great Q Temple
  Before you stands the mighty hall of the Q clan.  I certainly hope you
are supposed to be here, because the rumours say that intruders are not
treated kindly inside the compound.  As you gaze upon the mighty structure,
your mind is warped and twisted in such strange ways...  How the HELL does
this thing stand without toppling over?!  Chances are, your mind will never
be free enough to be able to comprehend the answer.  

[Exits: north down]
     (Drunk) A drunken funny man is here, telling jokes.

<4465/4465hp 1083/1083mn 2063/2063mv 359etl Q Clan Area>  
[INFO]: Sasuke has decided to join us.who


<4465/4465hp 1083/1083mn 2063/2063mv 359etl Q Clan Area>  [IMP Djinn  Mag  ] [Discordia-GoS] Commander Astark Caldazar 
[GOD Dryad  Asn k] [Q-een] [AFK] * Lady Engel Shadowwalker 
[ 97 Djinn  Ran  ] [Q-ool] Rojas  
[ 92 Cyclop Gla K] [Q-ool] Sasuke the Gladiator Hero
[ 91 Orc    Asn K] [Q-ool] Prince Dracmas <<Stalkingwolf>> 
[ 15 Gholam Asn k] [Discordia-FoD] Zion I 

Players found: 6

<4465/4465hp 1083/1083mn 2063/2063mv 359etl Q Clan Area>  
[Go to top] top

Posted by Tiredchris   (17 posts)  [Biography] bio
Date Reply #98 on 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

Posted by Nick Gammon   Australia  (19,385 posts)  [Biography] bio   Forum Administrator
Date Reply #99 on 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 Reply #100 on 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 Tiredchris   (17 posts)  [Biography] bio
Date Reply #101 on 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 Nick Gammon   Australia  (19,385 posts)  [Biography] bio   Forum Administrator
Date Reply #102 on 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 Reply #103 on 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  (19,385 posts)  [Biography] bio   Forum Administrator
Date Reply #104 on 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

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.


54,849 views.

This is page 7, subject is 9 pages long:  [Previous page]  1  2  3  4  5  6  7 8  9  [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]