Aardwolf inventory in miniwindow

Posted by Blainer on Tue 07 Jul 2009 03:18 PM — 59 posts, 265,279 views.

#0
Saturday, August 22, 2009 at 05:18:05 UTC
http://code.google.com/p/aardinvwin/

Inventory Window Plugin
Show Aardwolf inventory in a mini window for MUSH Client 4.40.

Features:
-Shows a miniwindow with inventory contents.
-Caches item details in a searchable SQLite database.
-Drag and drop window (click and drag title text).
-Minimize miniwindow to a movable button.
-Apply filters to inventory from menu and command line.
-View contents of bags.
-Reference items by line number from command line.

Commands:
inw                 - show/refresh inventory window.
inw h               - minimize window to a movable button.
inw s               - maximize window, or just "inw".
inw n               - next page.
inw p               - previous page.
inw <page num>      - show page <page num>.
inw f               - show Filters list.
inw <filter name>   - filter inventory list, filter names can be shortened, "inw ar" will match Armour.
inw a               - use filter Show all.
inw s:<item desc>   - search database for an item by description.
inw slist           - add spell list to the database (needs to be done once to display details properly).
inw dbmsg           - toggle script database messages, at install reverts to value set in script.
inw <serial>        - get invdetails on item.
inw getalldetails   - get item details for entire inventory (not items in bags).
inw lines           - toggle show line numbers.
i <command> <num>   - send <command> for item <number>, "i id 1" = id item 1 on inv list.
inw ?               - show this help.



Upgrade Instructions

The script may not function properly if the state file is not deleted before new version is
installed.

1.
Download the plugin again from the here to get the latest version:
http://code.google.com/p/aardinvwin/

2.
Remove the old plugin from the File > Plugins dialog.

3.
Use Window XP search on the start menu with this search "*6dbbeddda02ed2390b58ccd9-state.xml" with out the quotes (").
The search should find a file like this:
777af83cdf336b8bb5207967-6dbbeddda02ed2390b58ccd9-state.xml

Or just use Explorer to browse to this directory:
"C:\Program Files\MUSHclient\worlds\plugins\state\777af83cdf336b8bb5207967-6dbbeddda02ed2390b58ccd9-state.xml"

This is my state file name it may different on your computer
how ever the "dbbeddda02ed2390b58ccd9" will be the same.

4.
Delete this file, it's important that this file be deleted after the plugin has
been removed and before you install the new version.

5.
If requested at begining of post.
Delete the Aardwolfdb.db file. By default this file is installed at:
"C:\Program Files\MUSHclient\worlds\plugins\Aardwolfdb.db"

6.
Then go to the File > Plugins dialog and install the new version.



Install Instructions

Requires MUSH 4.40 the custom Aardwolf MUSH client is here:
http://www.aardwolf.com/play/downloadmc.htm

1.
Three files are required to run this plugin Inventory_Window_2.xml, mw.lua and aardsql.lua.

Inventory_Window_2.xml
Download these from http://code.google.com/p/aardinvwin/:
Inventory_window_2.xml save to MUSH plugin directory (default: C:\Program Files\MUSHclient\worlds\plugins\)
aardsql.lua save to MUSH lua directory (default: C:\Program Files\MUSHclient\lua\)

If you have the latest version of MUSH the file below is included.
mw.lua
Download the file on the site below to the lua directory under the MUSH install directory.
http://www.gammon.com.au/forum/bbshowpost.php?id=8947

2.
If "invmon" is turned on at the MUD when plugin is installed the Plugin will disable this tag and AutoUpdate won't
work I plan to make a set of triggers to solve this.
So before install enter "invmon" until you get "You will no longer see inventory update tags." back from the MUD.

3.
Then install Inventory_Window_2.xml into MUSHclient using the File menu -> Plugins.
http://www.gammon.com.au/forum/?id=9617

4.
After the plugin is installed you need to run the command "inw slist" to load the spells list into the database.

I recommend creating an alias to reload the script from the command line. This is useful if you are editing the settings
in the script file or if the script screws up. Reloading the script won't change setting unless you have edited the script.
I plan to add this alias via the script but for now you'll need to do it manually.
1.
Select and copy between the lines below.
2.
Open "Game -> Configure -> Aliases" or "CTRL+SHIFT+9" menu.
3.
Click the paste button.

--cut--
<aliases>
    <alias
        match="rlinv"
        enabled="y"
        send_to="12"
        sequence="100"
    >
        <send>
            if ReloadPlugin ("6dbbeddda02ed2390b58ccd9") == error_code.eNoSuchPlugin then
                check (LoadPlugin ("/program files/mushclient/worlds/plugins/Inventory_Window_2.xml"))
            end
        </send>
    </alias>
</aliases>
--cut--

Full cut and paste aliases, triggers and timers instructions can be found here:
http://www.gammon.com.au/forum/?id=4777


The settings below will work as default.

A database is created in the plugin directory this can be changed by editing the script file.
change:
db_path = GetPluginInfo (GetPluginID(), 20) .. "\Aardwolfdb.db"

to:
db_path = [[c:\your directory]]



To change the look and behaviour of the plugin open the Inventory_Window_2.xml file
and edit the options below. An editor like Crimson Editor can be configured to display MUSH xml
files with colours making editing MUCH easier.
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=8692

You can find the options below starting at line 316 of Look_Scan.xml, make a backup of
these settings because tests are not done for unreasonable values.


BackgroundColour    = "black"                       -- Background colour for window. Supports Lua codes and MUSH colour names
                                                    -- i.e. "2432272" or "black" or GetInfo(271) can be used, this is your current window colour.
TitleColour         = "dimgray"                     -- Title text colour. Supports Lua codes and MUSH colour names.
LabelColour         = "dimgray"                     -- Colour for labels on popups, flags and values in list. Supports Lua codes and MUSH colour names.
SpellColour         = "65280"                       -- Colour for spell names on popups. Supports Lua codes Edit > Colour in MUSH
LevelColour         = "6908265"                     -- Colour for levels. Supports Lua codes. Supports Lua codes Edit > Colour in MUSH
ValueColour         = "6908265"                     -- Colour for values. Supports Lua codes. Supports Lua codes Edit > Colour in MUSH
WeightColour        = "6908265"                     -- Colour for weight. Supports Lua codes. Supports Lua codes Edit > Colour in MUSH
FontName            = GetInfo(20)                   -- Font for window, i.e. "Times New Roman", GetInfo(20) is current window font.
LFontSize           = 10                                -- List font size.
TFontSize           = 8                             -- Title font size.
CircleAction        = 2                             -- Set shape of boxes, 2="square", 3="rounded". popup shap in mw.lua.
BorderWidth         = 1                             -- Line thickness for display boxes, border width for popups is set in mw.lua.
ButtonGap           = 10                            -- Space between buttons.
OffSet              = BorderWidth + 4               -- Objects offset from window edge.
ItemSpace           = 5                             -- Space between list columns in points.
LineSpaces          = 2                             -- Space between inventory list lines.
PopOffSet           = 1                             -- Number of space characters to place at the begining and end of popup lines.
TitleText           = "Inventory"                   -- Title for window.
BagLabelChars       = 12                            -- Number of characters to display in bag name on bag button after bag open.
ShowBorders         = true                          -- true = draw title and foot boxes.
                                                    -- false = don't draw title and footer boxes.

ShowLineNums        = false                         -- Displays numbered lines that can be use to reference items from the commands line.
ShowValues          = true                          -- Show item values in inventory list (only appear after mouseover and then refresh).
LinesPerPage        = 40                            -- Number of lines per page in inv list.
MaxDescWidth        = 0                             -- Max number of chars in Item Description, 0 for unlitmited.
AutoSize            = false                         -- true = adjust window height to inv list size or LinesPerPage
                                                    -- false = always size to LinesPerPage.

AlignSide           = true                          -- true = Popup window on left
                                                    -- false = Popup window on right.
AlignBottom         = false                         -- false = Popup align bottom of AlignSide.
                                                    -- true = Popup align top of AlignSide.
PopupTop            = 10                            -- Top position of details popup in points

UseCache            = true                          -- "true" = use cached item details from db
                                                    -- "false" = get details from MUD each mouse over.
KeepInvDB           = false                         -- "true" = keep a table of current inventory
                                                    -- "false" is recommended because inventory table is not used atm
                                                    --  and all details are saved in other tables.
ShowWelcome         = true                          -- "true" = Displays msg when script has loaded
                                                    -- "false" = No message on install
AutoRefresh         = true                          -- "true" = uses invmon and invitem tags to trigger inventory refresh


It shouldn't interfere with any other plugins, all triggers are turned on and off as
needed if it does please let me know.


To trigger commands in plugin from other plugins use:

Execute (“inw <arg>”)


To view the contents of the database outside MUSH get SQLite Browser:
http://sourceforge.net/projects/sqlitebrowser/


The commands to reference items in a bag using serials is not completed on the MUD. So items in a bag can
be viewed but no details can be gotten from the MUD.

I would not run commands from this plugin on items in bags at all.

Look here for limitations on the MUD commands used for this plugin:
http://www.gammon.com.au/forum/?id=9461
Amended on Sat 22 Aug 2009 05:18 AM by Blainer
Australia Forum Administrator #1
First test result: mw.lua is not in fact included in the current distribution.
Australia Forum Administrator #2
Bug:

I made a new character and started doing the Academy stuff. I started off with ...


an Aardwolf Adventurer's Guide (type read guide) (0)


in my inventory.

However after doing my first quest I wanted to see if I got anything else in my inventory so I typed "inw" again and saw:


2 x an Aardwolf Adventurer's Guide (type read guide) (0)


Strange, I thought. Why would they give me two of those? Typing "inw" again gives:


3 x an Aardwolf Adventurer's Guide (type read guide) (0)


So it looks like the inventory list is not cleared out when you refresh it.
Australia Forum Administrator #3
To help the plugin look more readable on the web page, I suggest converting tabs to spaces (Crimson Editor will do this for you, as will most editors).

Also change tables like TypesT and WearT to wrap in the source (ie. one item per line) so the web page does not have horizontal scroll bars as much.
Australia Forum Administrator #4
If you type "inw slist" it would be helpful to have a confirmation that something happened. I did it, but there was no confirmation anything had been updated. Something like "spells list now loaded" would help.
Australia Forum Administrator #5

This is how the inventory looked for me on a new chararacter:

It opened on the right-hand side of my window, about half-way down.


Then I opened an exisiting character with more inventory, and saw this:

For some reason, it opened in the top left corner, obscuring the MUD output somewhat. Notice the provision for multiple pages.


Then I realized I could drag the window around (which is nice) by clicking on the word "Inventory", and saw this:

Note the hover-over information when you hover over an item.

Amended on Tue 07 Jul 2009 11:50 PM by Nick Gammon
Australia Forum Administrator #6
The last screen shot above shows that, after dragging, the window text quality seems degraded for some reason.
Australia Forum Administrator #7
The line "Getting details form MUD..." should read "Getting details from MUD...".
Australia Forum Administrator #8
Suggest checking window is visible after reload. Otherwise it might be off the screen somewhere. After these lines:


local x, y, mode, flags =
      tonumber (GetVariable ("windowx")) or 0,
      tonumber (GetVariable ("windowy")) or 0,
      tonumber (GetVariable ("windowmode")) or 8,
      tonumber (GetVariable ("windowflags")) or 4


Add:


-- check miniwindow visible
  if x < 0 or x > GetInfo (281) or
     y < 0 or y > GetInfo (280) then
     x, y = 0, 0  -- reset to top left
  end -- if not visible

Australia Forum Administrator #9

Just discovered the plugin implements click-to-use, like this:

So, to equip an item in the inventory (or quaff a potion, etc.) left-click on it and select the appropriate menu item.

Australia Forum Administrator #10
Got this error when mousing-over "a sharp tooth":


Run-time error
Plugin: Inventory_Display (called from world: Aardwolf)
Function/Sub: invdetailsParse called by trigger
Reason: processing trigger ""
[string "Plugin"]:1492: attempt to index field '?' (a nil value)
stack traceback:
        [string "Plugin"]:1492: in function 'ShowDet'
        [string "Plugin"]:551: in function <[string "Plugin"]:525>
Error context in script:
1488 :    sArm = "@p" .. sTyp .. " (@w" ..  WearT [ tostring (item["items"][1]["Wear"]) ] .. "@p)"
1489 :    inT (sOff .. sArm)
1490 :    inT (" ")
1491 :   elseif sTyp == "Weapon" then
1492*:    sNam = "@pWeapon Type @w" .. tostring (string.upper (item["weapon"][1]["wepName"]))
1493 :    sDmg = "@pAverage Dmg @w" .. tostring (item["weapon"][1]["wepAvgDmg"])
1494 :    sDmt = "@pDamage Type @w" .. tostring (string.upper (item["weapon"][1]["wepDmgType"]))
1495 :    sDmi = "@pInflict     @w" .. tostring (string.upper (item["weapon"][1]["wepInflict"]))
1496 :    inT (sOff .. sNam)



An id of the item shows:



id 163546456

+-----------------------------------------------------------------+
| Keywords   : sharp tooth                                        |
| Name       : a sharp tooth                                      |
| Type       : Weapon                    Level  :    10           |
| Worth      : 10                        Weight :     3           |
| Wearable   : wield                                              |
| Flags      : magic, V3                                          |
+-----------------------------------------------------------------+
| Weapon Type: dagger                Average Dam :      4         |
| Notes      : Item has weapon special flags.                     |
+-----------------------------------------------------------------+

Amended on Wed 08 Jul 2009 02:21 AM by Nick Gammon
Australia Forum Administrator #11
In your database management - I would not keep re-opening the database. In particular, in AardSelect, that is adding quite an overhead to open the database each time you want to query it. I would be opening that in plugin install, and leaving it open.

Also, I can't see the tables being indexed by name. This will make the lookups quite inefficient, as SQL has to do a linear scan to find a particular item.

I would make the "name" field the primary key where appropriate, or add an index like this:


CREATE INDEX xref_Name ON spells (Name);


Now, if you need to look up a particular spell by name, the database can directly index to the right one.
Australia Forum Administrator #12
If you filter in such a way that the window is empty (eg. filter on keys when you don't have any) the page is shown as 1/0 pages.


BTW Blainer, don't take my comments as a criticism. I think the plugin is great - I was hoping someone would do something like this. :-)

Just needs a few tweaks, and I bet it will be very popular.
#13
Thanks for the help and pics, sorry about not posting proper instructions will do that when it works.
Didn't take your comments as criticism, the code is bad I know and to be honest I'm surprised I
didn't get a post saying "LOL!".

I'm fixing all you mentioned but in making the database stay open I created another problem,
I now get SQLite error "21 : Library used incorrectly" returned from DataBaseStep() when doing
AardSelect() from InvDet(). I don't think it's to do with the db being open, I had this error
before with something else. Do you know what this error actually means? I can't find it explained
in my books or online. The SQL the script uses when the error is caused works with SQLite Browser
on the same database.

I can't figure out the blurred text either. The title text is blurred all the time but the list
is always fine on my computer. I messed around with the size of the text box with no luck once
I get the db working again I'll do a bunch of tests in another window see if I can make the problem
again. I'm pretty sure it's the text box height.

Here's a list of features the next post will have as soon as I fix the above error:

-Shows a miniwindow with inventory contents
-Caches item details in a searchable SQLite database
-Drag and drop window
-Minimize miniwindow to a movable button
-Apply filters to inventory from menu and command line
-View contents of bags

Commands:
-Inventory Window plugin commands:
inw - show/refresh inventory window.
inw h - minimize window to a movable button.
inw s - maximize window.
inw n – show next page.
inw p – show previous page.
inw <page num> - show page <page num>.
inw f - show filters list.
inw <filter name> - filter inventory list, filter names can be shortened, "inw ar" will match Armour.
inw a - use filter Show all.
inw s:<item description> - search database for an item.
inw slist - add spell list to the database (needs to be done once to display details properly).
inw dbmsg - toggle script database messages, at install reverts to value set in script.
inw <serial> - get invdetails on item and add to database.
inw getalldetails - get item details for entire inventory (not items in bags).
inw ? - show this help.

I plan on adding these next:
-View bags from command line.
-Display item count, max items count, weight and max weight.
-Add button for refresh/return to page 1 of inventory.
#14
Got it worked fixed the post at the top of this thread should work. I put all the changes except the indexes which I will read about tomorrow.
#15
Got it all done except the blurred text, indexes and a sharp tooth error I'll look at those tomorrow.
Australia Forum Administrator #16
Your post seems truncated, there is no </muclient> tag.
Australia Forum Administrator #17
You seem to have two copies of the database going simultaneously:


if Option then
        DatabaseOpen (db_name, db_path, 6)
        db = assert (sqlite3.open (db_path), "db open error")
        return
    elseif not Option then
        DatabaseClose(db_name)
        db:close ()
        return
    end


Why is that? Why not stick to either the Lua interface or the MUSHclient script interface? I can imagine cases where if one interface is doing something the other one will have "database locked" or something like that.
Australia Forum Administrator #18
Found the problem with the degraded appearance.

You have the mode as 0 (stretch to output view size) and the flags as 2 (absolute position). A "stretch" mode tends to make the window look strange, especially if it only stretches a pixel or so. I fixed it by changing:


	--create the window
	WindowCreate (win, x, y, WinWidth, WinHeight, mode, flags, BackgroundColour)


to:


	--create the window
	if bit.band (flags, 2) then mode = 4 end
	WindowCreate (win, x, y, WinWidth, WinHeight, mode, flags, BackgroundColour)


You can probably come up with a more creative way of doing it. :)
Australia Forum Administrator #19
The problem with the stretching is fixed for good in version 4.42 (but my proposed fix will work for now).

Blainer, the code (which I had suggested) for remembering the window location does not always work reliably.

This post shows some reworked code:

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

The changes basically are:

  • The window location is saved in global variables (window_left and window_top), rather than relying on the current window position
  • Those variables are the ones serialized
  • In dragrelease, the position variables are updated, and the current position is calculated like this, rather than the previous method:

    
    Repaint ()  -- update window location
      
      -- find where window is now
      local newx, newy = WindowInfo (win, 10), WindowInfo (win, 11)
    

  • There is a race condition at world startup - the MUSHclient world size is set up a little while after the world is opened, and the check in the code may precede that (thus making the miniwindow be moved incorrectly). Now, the check for its position is deferred for 5 seconds:

    
      -- give main world window time to stabilize its size and position                
      DoAfterSpecial (5, "check_map_position ()", sendto.script)
    

  • The code to relocate the window, if it is offscreen, is now in a separate function:

    
    function check_map_position ()
     -- check miniwindow visible
      if window_left < 0 or window_left > GetInfo (281) or
         window_top < 0 or window_top > GetInfo (280) then
         window_left, window_top = 0, 0  -- reset to top left
         window_mode = 7
         window_flags = 0
      end -- if not visible
    
      WindowPosition (win, window_left, window_top, window_mode, window_flags)
      
    end -- check_map_position
    



This seems to work more reliably in the map and health bar plugins.
Amended on Wed 08 Jul 2009 11:41 PM by Nick Gammon
#20
Thanks Nick, I think I got all that sorted.

I added line numbers to the inventory list and a command to use them, you can see the instructions with "inw ?".

Changed the default colour so it doesn't look like map, sorry about that didn't think.

Posted new version at:
http://code.google.com/p/aardinvwin/downloads/list

If you can find anything else please let me know.
Amended on Thu 09 Jul 2009 02:57 PM by Blainer
Australia Forum Administrator #21
Looks good so far, but opening a bag (bottom left corner) seems to both make the window disappear, and scroll a whole lot of {invdata} on the screen - maybe that is a side-effect of the window disappearing.

I have a timer that does "inw" every 30 seconds to refresh the inventory - I take it there is no other realistic way of keeping it up to date?
#22
Played with opening and closing bags and got what you described once but can't repeat it.
I'll try and figure out what combination of Filter and Bag commands causes it. It has to be the
triggers being turned off by an RefreshInv() before previous invdata is finished.

Forgot about the database indexes, doing those next.

You also mentioned an error with "a sharp tooth", I've changed a few things since then. Does this item
still cause the error?
I really don't like the way I wrote this section because it tests if "item["items"][1][ "Level" ]" is
false rather than weather it exists at all (a few of these spread around the script).
I tried to re-write it the other day but got no where with it.

if not item["items"][1][ "Level" ] or GetVariable("UseCache") == "false" then
Is this the correct way to do this test?

This is the section with the line above:

--make sql table and select from db
a = {
    ["items"]       = { "Serial", "Description","Level","Type","Value","Weight","Wear","Flags","Owner","Clan","Timer"},
    ["spellmod"]    = { "itUses", "itLevel", "itSn1", "itSn2", "itSn3", "itSn4", "itSn5" },
    ["statmod"]     = { "stName", "stValue" },
    ["resistmod"]   = { "rsName", "rsValue" },
    ["drink"]       = { "drServings", "drContents", "drCapacity", "drQuantity", "drThirst", "drHunger", "drUnknown" },
    ["weapon"]      = { "wepName", "wepAvgDmg", "wepInflict", "wepDmgType" },
    ["food"]        = { "fdPercentage" },
    ["container"]   = { "ctCapacity", "ctHeaviest", "ctHolding", "ctNumber", "ctTotalWieght", "ctBurden", "ctPercentage" },
    }
item = { ["items"] = {},["spellmod"] = {},["statmod"] = {},["resistmod"] = {},["skillmod"] = {},["drink"] = {},["weapon"] = {},["food"] = {},["container"] = {} }

for j in pairs (a) do

    s = ""
    for v,k in pairs (a[j]) do
        s = s .. "\"" .. k .. "\"" .. ","
    end
    s = s:sub(1, s:len() - 1)
    t = {   [ "SELECT" ]    = { s },
            [ "FROM" ]      = { j },
            [ "WHERE" ]     = { "Serial = " .. "'" .. Serial .. "'"}
        }
    res, s = AardSelect (t)

    for i,v in pairs (res) do
        if res[i] ~= nil then
            table.insert (item[j], res[i])
        else
            DBmsg ("cancelmouseoverInfoWin: " .. s)
            return
        end
    end

end --select from db

--get details if not already in database
if not item["items"][1][ "Level" ] or GetVariable("UseCache") == "false" then
    --don't send more than one invdetails at once
    if GetVariable ("GettingDet") == "false" then
        SetVariable ("GettingDet", "true")
        GetInvDet (Serial)
    end
    inT (" @gGetting details form MUD... ")
    mw.popup (infowin, heading_font_id, font_id, "", t, x, y,  TitleColour, BackgroundColour, false, AlignSide, AlignBottom)
    return
end

If a record is found "items" table looks like this.

"items":
  1:
    "Type"="Armor"
    "Description"="@WGueldars @wcrafted leather bracer"
    "Owner"=""
    "Flags"="v3"
    "Timer"=""
    "Clan"=""
    "Weight"=1
    "Wear"="wrist"
    "Level"=1
    "Serial"=155523564
    "Value"=15
"statmod":
"container":
"weapon":
"drink":
"food":
"spellmod":
"skillmod":
"resistmod":

If no record is found "items" table looks like this:

"items":
  1:
    "Serial"=164419843
    "Description"="@WGueldars@w crafted leather cap@w"
"statmod":
"container":
"weapon":
"drink":
"food":
"spellmod":
"skillmod":
"resistmod":



If I do GetInfo(271)(Background colour) I get "-1" When I pass this as a colour code to WindowCreate
I get no error so is "-1" black. And how do I change the window (main window no mini) background colour,
not the one for the text.



Theres a set of tags for updating inventory (added them to: http://www.gammon.com.au/forum/?id=9461)
I should be able to add this with out major changes but it does open up a lot of stuff to add.
Being able to know at all times what container an item is in will be cool.
Amended on Fri 10 Jul 2009 08:53 AM by Blainer
Australia Forum Administrator #23
Quote:

if not item["items"][1][ "Level" ] or GetVariable("UseCache") == "false" then
Is this the correct way to do this test?


No, "false" is a string with the word "false" in it. You want it without quotes, eg.


if not item["items"][1][ "Level" ] or GetVariable("UseCache") == false then



However even that isn't too good. GetVariable returns nil if the variable doesn't exist, not false.

You could use:


if not item["items"][1][ "Level" ] or GetVariable("UseCache") == nil then



Maybe better is:


if not (item["items"][1][ "Level" ] or GetVariable("UseCache")) then


An if test is only true if the variable is anything other than false or nil. Since GetVariable returns nil if the variable doesn't exist, it is logically equivalent to false (but not exactly equal to false).
#24
Wasn't asking about the GetVariable part of the line. It's the test to see if the table item["items"][1]["level"] exists that I think is dodgy.
Amended on Fri 10 Jul 2009 01:37 PM by Blainer
#25
Hello Nick, i am a new user for Mushclient
i have installed Mushclient V 4.40,
but i have a problem with the Aardwolf inventory miniwindow..
i have followed the requirement, but when i tried to install it, i found the problem like this :

Warning: Plugin Inventory_Display is currently disabled.
Run-time error
Plugin: Inventory_Display (called from world: Aardwolf)
Function/Sub: OnPluginDisable called by Plugin Inventory_Display
Reason: Executing plugin Inventory_Display sub OnPluginDisable
[string "Plugin"]:2070: bad argument #1 to 'WindowShow' (string expected, got nil)
stack traceback:
[C]: in function 'WindowShow'
[string "Plugin"]:2070: in function 'OnPluginClose'
[string "Plugin"]:2058: in function <[string "Plugin"]:2056>
[C]: in function 'EnablePlugin'
[string "Plugin"]:1965: in function <[string "Plugin"]:1945>
Error context in script:
2066 : SetVariable ("CurrPage", 1)
2067 : SetVariable ("currSerial", "Show all")
2068 : WindowShow (win, false)
2069 : WindowShow (but, false)
2070*: WindowShow (infowin, false)
2071 : SaveState ()
2072 :
2073 : end -- OnPluginClose

i don't know how to get it fixed..
can you help me how to get it fixed please?

Thank you
#26
Nick has nothing to do with this plugin, he has just been
answering questions about MUSH client.

So I'll try to help you with you problem.

Download the plugin again from the here to get the latest version:
http://code.google.com/p/aardinvwin/downloads/list


Remove the old plugin from the File > Plugins dialog.

Use Window XP search on the start menu with this search "*6dbbeddda02ed2390b58ccd9-state.xml" with out the quotes (").
The search should find a file like this:
777af83cdf336b8bb5207967-6dbbeddda02ed2390b58ccd9-state.xml

Or just use Explorer to browse to this directory:
"C:\Program Files\MUSHclient\worlds\plugins\state\777af83cdf336b8bb5207967-6dbbeddda02ed2390b58ccd9-state.xml"

This is my state file name it may different on your computer
how ever the "dbbeddda02ed2390b58ccd9" will be the same.


Delete this file, it's important that this file be deleted after the plugin has
been removed and before you install the new version.


Then go to the File > Plugins dialog and install the version.

Amended on Fri 10 Jul 2009 02:14 PM by Blainer
#27
Hi
thank you so much Blainer :)
now it works! :)
#28
Check back every couple of days for new versions I am still
working on it.
Amended on Fri 10 Jul 2009 02:39 PM by Blainer
#29
Posted new version: http://code.google.com/p/aardinvwin/downloads/list

Did the database indexes, I removed all the primary keys and
did indexes for them all except inventory table but I think
I'll be removing that table anyway. If I'm understanding it
correctly I don't need keys if I have a unique column and
indexes set up.

It seems to run faster I think.

Fixed a bunch of other small things, I think it displays a little
better now.
Australia Forum Administrator #30
Quote:

This is the section with the line above:

--make sql table and select from db

...

item = { ["items"] = {},["spellmod"] = {},["statmod"] = {},["resistmod"] = {},["skillmod"] = {},["drink"] = {},["weapon"] = {},["food"] = {},["container"] = {} }


That makes my eyes hurt a bit from all the quotes. You can simplify table keys by unquoting them, if they are alpha, like this:


item = { items = {}, spellmod = {}, statmod = {}, resistmod = {}, 
         skillmod = {}, drink = {}, weapon = {}, food = {}, 
         container = {} }


Now look at this:


t = {   [ "SELECT" ]    = { s },
            [ "FROM" ]      = { j },
            [ "WHERE" ]     = { "Serial = " .. "'" .. Serial .. "'"}
        }


Isn't this just too complicated? Instead of SELECT a, b, c, d etc. just do 'SELECT * FROM'. You seem to be wanting everything, so SELECT * gives it to you.

And


WHERE "Serial = " .. "'" .. Serial .. "'"


could be simplified to:


WHERE "Serial = '" .. Serial .. "'"


and indeed:


WHERE "Serial = " .. Serial 


In SQL, you don't have to quote numbers in a WHERE clause, only strings.

Now to answer your question about:


if not item["items"][1][ "Level" ]  ...


I'm not totally sure what you are doing here. You can simplify it to:


if not item.items[1].Level  ...


Quote:

If no record is found "items" table looks like this:

"items":
1:
"Serial"=164419843
"Description"="@WGueldars@w crafted leather cap@w"


Why? You have requested information on serial 155523564 and you got back information for 164419843. That doesn't sound right.



Your use of the SQL database is a great idea - I don't think I had the SQLite support in MUSHclient when I did my inventory plugin. That makes it easier to keep inventory information from one session to the next. I'm just trying to help you make the plugin a bit easier to follow - believe me in a year's time you will be wondering "why did I do that?" if things are too complex.
#31
Quote:

Why? You have requested information on serial 155523564 and you got back information for 164419843. That doesn't sound right.


SELECT will always get the Description and Serial back at this
point in the script. If an invdetials has not been stored
in the database for that Serial then Level will be empty.

When the invdata is parsed I add Description and Serial to
items db table. This is because invdetails does not have the
description. So when invdetails is parsed on an item I don't
need to look up serial and Description, test if there, choose
between update or insert. In writing this it occurs to me that
this may cause a lot of lag when mousing over with big databases,
so maybe my design is just a cache and not an items database as I'd
hoped. And that I'll need to clear that cache when it reaches a
certain size.

One thing that would make alot more sense would be to change the
message about "getting details from MUD..." to Description and
"getting details from MUD..." seeing as the script has the Description
at this point. Thats done now.


The code above is now:

--make sql table and select from db
tablesT =   {   items = {}, spellmod = {}, statmod = {}, resistmod = {},
                skillmod = {}, drink = {}, weapon = {}, food = {},
                container = {} }
item = tablesT

for j,w in pairs (tablesT) do
    t = {   SELECT  = { "*" },
            FROM    = { j },
            WHERE   = { "Serial = " ..  Serial }
        }
    res, s = AardSelect (t)
    DBmsg ("cancelmouseoverInfoWin: " .. s)

    for i,v in pairs (res) do
        if res[i] ~= nil then
            table.insert (item[j], res[i])
        end
    end

end --select from db


Changed all the tables to what you suggested.

Quote:

I'm just trying to help you make the plugin a bit easier to follow - believe me in a year's time you will be wondering "why did I do that?" if things are too complex.


Thanks I really want this plugin to be easy to cut and paste
bits from and stable. If theres anything else please let me
know and I'll get it done.
Amended on Sat 11 Jul 2009 05:45 AM by Blainer
Australia Forum Administrator #32
Don't forget to change:


inT (sOff .. "@gGetting details form MUD... " .. sOff)


to:


inT (sOff .. "@gGetting details from MUD... " .. sOff)

Australia Forum Administrator #33

Just as a suggestion, how about trying to detect this:

... and change 3 lines of "1 use of BLACK LOTUS level 10" into a single line: "3 uses of BLACK LOTUS level 10"?

Australia Forum Administrator #34
The other thing I tried to do with my inventory window months ago, was assess a weapon's usefulness by trying to evaluate if it was good "for its level". By comparison, in WoW, items like weapons are colour-coded, so a gray item is considered pretty useless, white is about average for its level, green is above average, blue is very good, and so on.

Thus, a simple glance can show whether you should throw away, sell, or use, an item that might have dropped from a mob.

My preliminary code used a table of the damage that a certain level *should* cause, like this:


-- see: http://www.aardwolf.com/builders/index.php?option=content&task=view&id=210&Itemid=134

avg_weapon_points = {
    3.0, 3.0, 3.0, 4.5, 4.5, 6.0, 6.0, 6.0, 6.0, 8.0,           -- 1 to 10
    8.0, 10.0, 10.0, 10.0, 10.0, 10.0, 12.0, 12.5, 12.5, 14.0,  -- 11 to 20
    14.0, 14.0, 15.0, 16.0, 16.0, 16.0, 16.0, 18.0, 18.0, 20.0, -- 21 to 30
    21.0, 22.5, 24.5, 27.0, 28.0, 28.0, 28.0, 32.0, 32.0, 35.0, -- 31 to 40
    35.0, 36.0, 36.0, 38.5, 40.5, 40.0, 39.0, 42.0, 42.0, 45.0, -- 41 to 50
    45.0, 48.0, 48.0, 49.5, 49.5, 50.0, 52.0, 52.0, 52.0, 52.0, -- 51 to 60
    55.0, 55.0, 58.5, 58.5, 58.5, 58.5, 60.5, 60.5, 63.0, 63.0, -- 61 to 70
    63.0, 65.0, 66.0, 66.0, 67.5, 70.0, 75.0, 77.0, 76.5, 80.0, -- 71 to 80
    84.5, 90.0, 96.0, 96.0, 98.0, 102.0, 110.5, 120.0, 120.0, 128.0,          -- 81 to 90 
    135.0, 144.0, 144.5, 160.0, 165.0, 162.0, 171.0, 180.0, 190.0, 190.0,     -- 91 to 100
    192.5, 192.5, 200.0, 200.0, 207.0, 207.0, 211.5, 211.5, 214.5, 214.5,     -- 101 to 110
    220.0, 220.0, 222.0, 222.0, 220.5, 220.5, 245.0, 245.0, 231.0, 231.0,     -- 111 to 120
    238.5, 238.5, 242.0, 242.0, 242.0, 242.0, 253.0, 253.0, 255.0, 255.0,     -- 121 to 130
    253.0, 253.0, 259.0, 259.0, 266.5, 266.5, 272.0, 272.0, 276.0, 276.0,     -- 131 to 140
    280.0, 280.0, 280.0, 280.0, 285.0, 285.0, 288.0, 288.0, 294.5, 294.5,     -- 141 to 150
    297.0, 297.0, 304.0, 304.0, 308.0, 308.0, 313.5, 313.5, 315.0, 315.0,     -- 151 to 160
    320.0, 320.0, 323.0, 323.0, 324.0, 324.0, 325.0, 325.0, 330.0, 330.0,     -- 161 to 170
    332.5, 332.5, 333.5, 333.5, 336.0, 336.0, 338.0, 338.0, 330.0, 330.0,     -- 171 to 180
    346.5, 346.5, 350.0, 350.0, 351.0, 351.0, 356.5, 356.5, 360.0, 360.0,     -- 181 to 199
    362.5, 362.5, 368.0, 368.0, 372.0, 372.0, 377.0, 377.0, 384.0, 384.0,     -- 191 to 200
    390.0,                                                                    -- 201
} -- end of avg_weapon_points


Thus, for example, a level 10 weapon might be expected to do 8 damage.

Now we can work out how good a weapon is, for example a level 10 weapon that did 12 damage could be classed as quite good, because from the table, you need a level 17 weapon to do 12 damage. Likewise, a level 10 weapon that did 4.5 damage could be regarded as quite poor.

The code below, which is probably not at all perfect, tried to "walk" the table and work out which was the closest level that matched the actual damage the weapon did (bearing in mind some levels have the same damage in the table), and see how far away from its actual level it is:


    local avg_damage = avg_weapon_points [item.level] or 1
    local rating = 0
    local L = item.level
    local new_points
    
    if item.weapon.avgdamage > avg_damage then
      repeat
        L = L + 1
        if L > #avg_weapon_points then
          break  -- end of table
        end -- if
        if avg_weapon_points [L] > item.weapon.avgdamage then
          break
        end -- if
        new_points = avg_weapon_points [L]
        rating = rating + 1
      until false
      
      -- drop back to first weapon that had this rating
      if new_points then
        rating = rating + 1
        while avg_weapon_points [L - 1] == new_points do
          L = L - 1
          rating = rating - 1
        end -- while
      end -- if
              
    elseif item.weapon.avgdamage < avg_damage then
      repeat
        L = L - 1
        if L < 1 then
          break  -- start of table
        end -- if
        if avg_weapon_points [L] < item.weapon.avgdamage then
          break
        end -- if
        new_points = avg_weapon_points [L]
        rating = rating - 1 
       until false    
       
       -- go forwards to first weapon that had this rating
       if new_points then
         rating = rating - 1
         while avg_weapon_points [L + 1] == new_points do
           L = L + 1
           rating = rating + 1
         end -- while
       end -- if
    end -- if
    
    if rating > 0 then
      infoline (string.format ("Rating: +%i", rating),  "lime")
    elseif rating < 0 then  -- minus sign will be shown anyway
      infoline (string.format ("Rating: %i", rating),  "slategray")
    end -- if


The end result was an information message, if the weapon's rating was not zero, showing either a +level or a -level from the current level (and a colour code).
Amended on Sat 11 Jul 2009 11:33 PM by Nick Gammon
#35
Ok thats next on list. I am thinking colour coded level numbers
on list and maybe the item type and level on popup.


At the moment I am working on getting the db to track item locations
reliably.

I made this cool table last night:

eqT =   {   --flag      --desc                  --keyword   --item tbl          --wear  --table index
        {   "light",    "Used as light",        "light",    currWorn = {}   },  -- 0    -- 1
        {   "head",     "Worn on head",         "head",     currWorn = {}   },  -- 1    -- 2
        {   "eyes",     "Worn on eyes",         "eyes",     currWorn = {}   },  -- 2    -- 3
        {   "lear",     "Worn on left ear",     "ear",      currWorn = {}   },  -- 3    -- 4
        {   "rear",     "Worn on right ear",    "ear",      currWorn = {}   },  -- 4    -- 5
        {   "neck1",    "Worn around neck",     "neck",     currWorn = {}   },  -- 5    -- 6
        {   "neck2",    "Worn around neck",     "neck",     currWorn = {}   },  -- 6    -- 7
        {   "back",     "Worn on back",         "back",     currWorn = {}   },  -- 7    -- 8
        {   "medal1",   "Pinned to chest1",     "medal",    currWorn = {}   },  -- 8    -- 9
        {   "medal2",   "Pinned to chest2",     "medal",    currWorn = {}   },  -- 9    -- 10
        {   "medal3",   "Pinned to chest3",     "medal",    currWorn = {}   },  -- 10   -- 11
        {   "medal4",   "Pinned to chest4",     "medal",    currWorn = {}   },  -- 11   -- 12
        {   "torso",    "Worn on torso",        "torso",    currWorn = {}   },  -- 12   -- 13
        {   "body",     "Worn around body",     "body",     currWorn = {}   },  -- 13   -- 14
        {   "waist",    "Worn about waist",     "waist",    currWorn = {}   },  -- 14   -- 15
        {   "arms",     "Worn on arms",         "arms",     currWorn = {}   },  -- 15   -- 16
        {   "lwrist",   "Worn on left wrist",   "wrist",    currWorn = {}   },  -- 16   -- 17
        {   "rwrist",   "Worn on right wrist",  "wrist",    currWorn = {}   },  -- 17   -- 18
        {   "hands",    "Worn on hands",        "hands",    currWorn = {}   },  -- 18   -- 19
        {   "lfinger",  "Worn on left finger",  "finger",   currWorn = {}   },  -- 19   -- 20
        {   "rfinger",  "Worn on right finger", "finger",   currWorn = {}   },  -- 20   -- 21
        {   "legs",     "Worn on legs",         "legs",     currWorn = {}   },  -- 21   -- 22
        {   "feet",     "Worn on feet",         "feet",     currWorn = {}   },  -- 22   -- 23
        {   "shield",   "Worn as shield",       "shield",   currWorn = {}   },  -- 23   -- 24
        {   "wielded",  "Primary Weapon",       "wield",    currWorn = {}   },  -- 24   -- 25
        {   "second",   "Off-Hand Weapon",      "wield",    currWorn = {}   },  -- 25   -- 26
        {   "hold",     "Held",                 "hold",     currWorn = {}   },  -- 26   -- 27
        {   "float",    "Floating nearby",      "float",    currWorn = {}   },  -- 27   -- 28
        {   "sleeping", "Sleeping",             "sleeping", currWorn = {}   }   -- 28   -- 29
        }

SQL for new db table

eq =    {   -- eq table, holds current eq outfit
        [[
        CREATE TABLE IF NOT EXISTS eq(
        SetName TEXT NOT NULL,
        SetDesc TEXT,
        light INTEGER,
        head INTEGER,
        eyes INTEGER,
        lear INTEGER,
        rear INTEGER,
        neck1 INTEGER,
        neck2 INTEGER,
        back INTEGER,
        medal1 INTEGER,
        medal2 INTEGER,
        medal3 INTEGER,
        medal4 INTEGER,
        torso INTEGER,
        body INTEGER,
        waist INTEGER,
        arms INTEGER,
        lwrist INTEGER,
        rwrist INTEGER,
        hands INTEGER,
        lfinger INTEGER,
        rfinger INTEGER,
        legs INTEGER,
        feet INTEGER,
        shield INTEGER,
        wielded INTEGER,
        second INTEGER,
        hold INTEGER,
        float INTEGER,
        sleeping INTEGER
        );
        INSERT INTO eq (SetName, SetDesc) VALUES ('currEQ', 'Currently equiped items');
        CREATE INDEX xref_eq_SetName ON eq (SetName);
        ]]
        }


The way I have it working at the moment is the user wields sword.
-Script is triggered by invmon.
-Script uses action to decide what to do.
-If wield search invT table for item remove it or reduce stack count
(I may need to figure out new way to do stacks as top serial will be consumed and next serial will not be put in place).
-Add table for item from invT to currWorn above.
-Update db.
-Display modified invT again.

I hate this because it is displaying data not from the MUD in a place
that should be exactly as from MUD.

The other option is to send eqdata and invdata every time invitem or
invmon triggers. But I suspect this will slow things down a lot a "give
all player" would be impossible.

I'm pretty sure I'm over thinking this so I may just play with those colours
for a bit.

Quote:

... and change 3 lines of "1 use of BLACK LOTUS level 10" into a single line: "3 uses of BLACK LOTUS level 10"?

I assumed there was a reason it was displayed that way.

+-----------------------------------------------------------------+
| Keywords   : potion healing thin red light relief               |
| Name       : (!(Light Relief)!)                                 |
| Type       : Potion                    Level  :     1           |
| Worth      : 8                         Weight :     4           |
| Wearable   : hold                                               |
| Flags      : magic, V3                                          |
| Found at   : The Grand City of Aylor                            |
+-----------------------------------------------------------------+
| Spells     : 1 use of level 4 'cure light'                      |
|            : 1 use of level 4 'cure light'                      |
+-----------------------------------------------------------------+



Fixed the item stacks and now form is from but not posting till above
is done because nothing new yet worth testing.
Amended on Sun 12 Jul 2009 06:46 AM by Blainer
#36
New version posted.

Didn't get inventory monitoring completed but I
did get the window to refresh when an item leaves or enters
inventory.

Can anyone with the time run this and let me know if it is
stable please. Thanks.
#37
Sadly, I don't play Aard much anymore but this is really cool. I tried it out today... and I have an issue.

When I mouse over "Bag of Aardwolf" (I have 2) it gives me an error:

Error number: 0
Event:        Run-time error
Description:  [string "Plugin"]:1658: attempt to index field '?' (a nil value)

stack traceback:

	[string "Plugin"]:1658: in function 'ShowDet'

	[string "Plugin"]:753: in function <[string "Plugin"]:727>
Called by:    Function/Sub: invdetailsParse called by trigger

Reason: processing trigger ""


and it puts this on my screen:

TRACE: Executing trigger script "invdetailsParse"
{invheader}35949563|108|Container|1000|-266||unique, glow, hum, magic, nosell, held, nopurge, burn-proof, v3, precious|Myndra|||||
{container}3160|100|293|42|-208|43|20

Because of the error, it refuses to parse anything else.

If I open the bag first (using the "Bags ^" option at the bottom of the window, which only shows one Aard bag and not both), the contents show up just fine. But when I mouse over any of them items, it starts to spam my window with:

TRACE: Executing trigger script "invdetailsParse"
{invheader}35949563|108|Container|1000|-266||unique, glow, hum, magic, nosell, held, nopurge, burn-proof, v3, precious|Myndra|||||
{container}3160|100|293|42|-208|43|20
TRACE: Executing trigger script "invdetailsParse"
TRACE: Executing trigger script "invdetailsParse"
{invheader}35949563|108|Container|1000|-266||unique, glow, hum, magic, nosell, held, nopurge, burn-proof, v3, precious|Myndra|||||
{container}3160|100|293|42|-208|43|20
TRACE: Executing trigger script "invdetailsParse"
TRACE: Executing trigger script "invdetailsParse"

until I disconnect.

I'm guessing it has to do with the fact that I have 2 bags with the same name, so the plugin gets confused.

Edit: I have another container, and it opens fine but when I mouse over the contents of that container, each line causes a carriage return.

TRACE: Executing trigger script "process_prompt"
TRACE: Executing Plugin Inventory_Display script "mouseoverShowDet"
TRACE: Executing trigger script "invdetailsParse"

[  3460/3460hp 2698/2698mn 2208/2208mv 1216tnl] >

TRACE: Executing trigger script "process_prompt"
TRACE: Executing Plugin Inventory_Display script "cancelmouseoverInfoWin"
TRACE: Executing Plugin Inventory_Display script "mouseoverShowDet"
TRACE: Executing trigger script "invdetailsParse"

[  3460/3460hp 2698/2698mn 2208/2208mv 1216tnl] >


Still, this is quite cool. Feels a little like WoW. :)
Amended on Tue 14 Jul 2009 08:27 PM by Norry
#38
That was a bad trigger, didn't account for the - in the trigger.

Grab it again and see if it's working now.



edit
Found another problem with the script trying to stack bags. This is fixed now.
Amended on Wed 15 Jul 2009 03:04 PM by Blainer
#39
Sorry I didn't reply sooner. I just picked up the newest copy, deleted both the state file and the dbase so things are clean. I'm still getting some weird things.

The plugin doesn't seem to notice I have 2 Aard bags. I'm not sure if this is possible to change; no big deal if not. (Side note: I was sure there was a way to combine/uncombine items in the inventory, so instead of "(2) Bag of Aardwolf" they would be listed on 2 separate lines. I can't seem to change this.)

First, random errors. They seem to happen on a reinstall (possibly a fresh install?). Mousing over Aard bag causes this:
Error number: 0
Event:        Run-time error
Description:  [string "Plugin"]:1658: attempt to index field '?' (a nil value)

stack traceback:

	[string "Plugin"]:1658: in function 'ShowDet'

	[string "Plugin"]:753: in function <[string "Plugin"]:727>
Called by:    Function/Sub: invdetailsParse called by trigger

Reason: processing trigger ""



Opening my other container (a collection box) and mousing over the contents causes this:

Error number: 0
Event:        Run-time error
Description:  [string "Plugin"]:1658: attempt to index field '?' (a nil value)

stack traceback:

	[string "Plugin"]:1658: in function 'ShowDet'

	[string "Plugin"]:740: in function <[string "Plugin"]:727>
Called by:    Function/Sub: invdetailsParse called by trigger

Reason: processing trigger ""


Again, these are random and do not always happen; I can't really figure out a pattern, except they seem to happen first thing after a reinstall.

If I don't get an error, mousing over the Aard bag still causes the invdetails to appear on my screen, and the info window to show info from some other, random item.
#1 http://home.comcast.net/~norry/aard_inv_bag_mouseover.jpg

Usually opening the Aard bag shows the contents of one bag, but mousing over the contents causes the invdetails of the bag to spam on my screen until I disconnect. This looks like it's coming from the mud, because my "spam prevention" goes off and tries to send "look" to the mud.
#2 http://home.comcast.net/~norry/aard_bag_contents.jpg

Ocassionally, it's actually let me mouse over the items and not spam, but the info window flashes "Getting details from mud..." for the correct item then displays random information (often the container I'm looking at), not the item I'm mousing over. This always happens when I open the box, plus a carriage return appears to be sent with each mouseover.
#3 (Aard bag open) http://home.comcast.net/~norry/aard_bag_contents2.jpg
#4 (collection box open) http://home.comcast.net/~norry/aard_box_contents.jpg

However, clicking on any of the contents brings up the proper menu. But choosing one of the options seems to try to focus the container, so I get something like:
id 35949507
You do not have that item.

and the miniwindow goes back to displaying the full inventory.
#5 http://home.comcast.net/~norry/aard_box_contents_menu.jpg
#6 (see red box) http://home.comcast.net/~norry/aard_box_id_result.jpg
#40
OK this is basically triggers not matching info coming from the MUD. I have changed all the tiggers to allow for negative numbers. So this should fix that. Posted a new version.
Due to the commands this plugin uses manipulating items using their serial in bags does not work. So if I do “get <serial> from bag” MUD will say no item found. I can however view the item listed when I look in a bag just can’t do anything to it. This script operates in a kind of batch mode. It runs through over and over flipping switches and at this stage there is no switch to say this is a bag list.
I wanted to at least be able to look at items in bags and if the item had been moused over when *not* in a bag (the details would be in the database) I wanted them to display. The way this script works if the serial was not in the database and the item was in a bag it displayed the previous moused over item. So I decided to show the bag details instead of say a sword from main inventory when viewing a sword in a bag. If you want this to stop remove the item from the bag mouse over it or use menu to Update Database then put it back in bag and it will display normally. At this stage I think we are in for a long wait for these commands to be finished. But I think the ability to once an item is in DB view it is better than not viewing bags at all. One other problem is viewing empty bags, the window will disappear. I haven’t fixed that in this version however “inw” will bring the window straight back showing main inventory.
I have been working on another plugin for awhile but intend to look at this again with what I have learned since.
#41
Ha, yeah, that would be my fault for not completely reading the post on the first page, or I'd've known you can't do anything with items in a bag.

I picked up the new copy and it seems to be functional now. It registers the Aard bag correctly, and doesn't freak out when I open it and mouse over the contents.

Thanks for putting this out there. I like seeing new uses for the miniwindows.
#42
Any other errors please post them.
#43
New version at:
http://code.google.com/p/aardinvwin/

- bags will no longer stack
- empty bags will now display an empty window
- added a maximum description width option

Just save the Inventory_Window_2.xml over the old one and
re-install with alias or in File -> Plugins dialog.
#44
Run-time error
Plugin: Inventory_Display (called from world: Aardwolf)
Function/Sub: mouseoverShowDet called by Plugin Inventory_Display
Reason: Executing plugin Inventory_Display sub mouseoverShowDet
[string "Plugin"]:1180: attempt to index field '?' (a nil value)
stack traceback:
[string "Plugin"]:1180: in function 'ShowDet'
[string "Plugin"]:1657: in function <[string "Plugin"]:1654>
Error context in script:
1176 :
1177 : end --select from db
1178 :
1179 : --heading and spaces to ensure popup is never too small
1180*: HeadingText = sOff .. item.items[1].Description:gsub("a ", "", 1) .. sOff
1181 : inT (string.rep (" ", math.max (25, mw.strip_colours(HeadingText):len())))
1182 :
1183 : --get details if not already in database
1184 : if not item.items[1].Level or GetVariable("UseCache") == "false" then
#45
Run-time error
Plugin: Inventory_Display (called from world: Aardwolf)
Function/Sub: invdataParse called by trigger
Reason: processing trigger ""
[string "Plugin"]:165: attempt to index field '?' (a nil value)
stack traceback:
[string "Plugin"]:165: in function <[string "Plugin"]:132>
Error context in script:
161 : FROM = { "items" },
162 : WHERE = { "Serial = " .. iSerial }
163 : }
164 : res, s = AardSelect (t)
165*: SetVariable ("currBag", mw.strip_colours (res[1].Description:sub(1,BagLabelChars) ))
166 : SetVariable ("currBagSerial", iSerial)
167 : else
168 : SetVariable ("currBag", "Inventory")
169 : SetVariable ("currBagSerial", "inv")
#46
Try this:

-remove Inventory_Display from File -> Plugins

-exit MUSH
Use Window XP search on the start menu with this search "*6dbbeddda02ed2390b58ccd9-state.xml" with out the quotes (").
The search should find a file like this:
777af83cdf336b8bb5207967-6dbbeddda02ed2390b58ccd9-state.xml

Or just use Explorer to browse to this directory:
"C:\Program Files\MUSHclient\worlds\plugins\state\777af83cdf336b8bb5207967-6dbbeddda02ed2390b58ccd9-state.xml"

This is my state file name it may be different on your computer
how ever the "dbbeddda02ed2390b58ccd9" will be the same.

Delete this file, it's important that this file be deleted after the plugin has
been removed and before you install the new version.

-delete the file aardwolfdb.db

-download Inventory_Window_2.xml and aardsql.lua and copy Inventory_Window_2.xml over the old and aardsql.lua over the old.

-start MUSH and open File -> Plugins and install the Inventory_Window_2.xml.

Let em know how it goes.
#47
Worked, must of been the new lua file because I did the rest before.
#48
-The script now uses xStat_Detector (link below) to find out if the character is in combat and doesn't update.
Template:post=8776
Please see the forum thread: http://gammon.com.au/forum/?id=8776.

-Tweaked a couple of settings to make it smaller.
#49
Okay, I just watched a video of 'How to play a MUD' that Nick made, and he connected to Aardwolf. I thought, holy crap, those plugins are badass. I would love to use this plugin as well as some of the others on my MUSHclient, but I guess it's not just a cut/paste job and it works in any mud. Anyways, I was wondering if anyone could tell me how to see, or what exactly the MUD has to send to the client for it to be able to parse this information and properly show it in the inventory window.

Thanks,
KeB
Australia Forum Administrator #50
Do you mean, from a MUD admin point of view? I had a considerable amount of cooperation from Lasher, the admin of Aardwolf. He put in extra tags in the MUD output that you could optionally turn on, which had stuff like your inventory in a machine parse-able form.

If you are only a player though, you have to make do with what a particular MUD sends. As an example, yesterday I did an inventory miniwindow demonstration on YouTube, that simply put the inventory as received from the MUD, into a separate window.

Conceptually you should be able to adapt most of the plugins for any MUD, provided you solve problems like identifying the start and end of things (eg. the map, if there is one). Again, Aardwolf helped by putting things like {map} and {mapend} around maps, to make the task much easier.

A polite message to the admins of a MUD may get some cooperation, as it is in their interests to have players keen to play, and a better user interface is going to help with that. Something like a configuration option a player can set, and then the MUD adds extra tags around things like inventory, maps, stats, etc.
#51
Yeah, actually I'm the coder of my game, so I'd gladly put in the necessary code, but seeing as I'm a complete noob as far as everything MUSHclient goes, I was basically wondering about the tagging system, and what I would need to put in so any player could easily use this plugin or a modified one to work on my game. So any pointers on what I would need to add in my code would be of great help.

Thanks,
KeB
Australia Forum Administrator #52
Some example are mentioned here:

http://www.gammon.com.au/forum/bbshowpost.php?id=8936&page=2

There are a number of plugins, so I would choose one - a simpler one to start with, like the map - and get that working first.

I think the map (the minimap) was something like:


{map}
 
... usual minimap here ...

{mapend}


Then the map plugin just picked up between {map} and {mapend} and put all that into a separate window.

There's no particularly fancy protocol here, it just used "omit from output" to hide those lines, and the map itself, from the main window.

As for other things, like player stats, you can just devise something that suits you. For example:


{stats}hp=1233,mana=4343,move=5432,xp=34343


The special line starting with {stats} can be used in a client trigger to tell it to parse the line (and omit from output) and then you can use some easy-to-parse format to supply the individual figures. This is easy enough to do at the MUD end, and easy for the client to parse.
#53
Okay, thanks for the heads up. I'm definitely going to have to delve deeper into the mini-windows things, and have to start breaking some of these down a bit so I can get some of these cool features working on my client for my game.

Thanks
USA #54
I would consider using a protocol like ZMP to communicate data as it provides a generic layer for sending information.

http://www.mudbytes.net/index.php?a=forum&f=41

This avoids having to write your own parsing rules, although it could be overkill depending on how much stuff you're trying to send. One advantage is that it's standardized to some extent (or more accurately, you can influence its standardization at this point) which can hopefully help cross-client compatibility as well as allowing multiple servers to talk to the same client more easily.
#55
first of, let me apologize for reviving an old thread.

i just started using this plugin but when ever i hover my cursor over an item in the inventory mini-window i get this error. the error only shows once on first hover. the only way to get it to show again is to restart the client. i am at a loss as to correct it. i'm new to muds and altering their clients. i've followed blainer's instructions installed/ uninstaleld multiple times. this is where i got the files. http://code.google.com/p/aardinvwin/downloads/list




Run-time error
Plugin: Inventory_Display (called from world: Aardwolf)
Function/Sub: invdetailsParse called by trigger
Reason: processing trigger ""
[string "Plugin"]:1180: attempt to index field '?' (a nil value)
stack traceback:
        [string "Plugin"]:1180: in function 'ShowDet'
        [string "Plugin"]:254: in function <[string "Plugin"]:228>
Error context in script:
1176 : 
1177 :  end --select from db
1178 : 
1179 :  --heading and spaces to ensure popup is never too small
1180*:  HeadingText =  sOff .. item.items[1].Description:gsub("a ", "", 1)  .. sOff
1181 :  inT (string.rep (" ", math.max (25, mw.strip_colours(HeadingText):len())))
1182 : 
1183 :  --get details if not already in database
1184 :  if not item.items[1].Level or GetVariable("UseCache") == "false" then
Trigger function "invdetailsParse" not found or had a previous error.

USA Global Moderator #56
I hate to see something like this just die. I had the same problem as Raizus, which was solved by replacing the pattern for the invheader trigger with


match="^\{invheader\}(-?\d+)\|(-?\d*)\|([A-Za-z ]*)\|(-?\d*)\|(-?-?\d*)\|([A-Za-z ,-]*)\|([A-Za-z0-9 ,-]*)\|([A-Za-z0-9 ]*)\|([A-Za-z0-9 -]*)\|(-?\d*)\|(-?\d*)\|(-?\d*)\|"


It still doesn't work inside containers though. And there are other bugs that sadly make this just a cute toy without further development. :\
Amended on Thu 11 Aug 2011 07:07 AM by Fiendish
#57
I have not used this yet, I'm at work so I cannot play right now... but I'm pretty sure that casting enchant weapon|armor on an item changes it's statmod|resistmod numbers without adjusting the item id. Can the code account for a (c "enchant w" emerald) then do a lookup for items matching "emerald" that are currently in the inv and update stats/resists or something like that?

I'm going to start playing with codes when i get a chance, but I only have passing experience with VBA, so they won't be pretty.

Awesome plugin, don't let it die!


...in related suggestions: right click item in miniwindow and (c "enchant weapon|armor" <item>) might not be too far fetched, nor would a (Get <item> <bag>), right? I can see a lot more awesomeness for this thing...

Fiendish, have id numbers been implemented for inside bags yet(or maybe it was for drop|sac)? Blainer mentioned something about it in an earlier post, just wondered if it had ever been implemented.
#58
a little help if possible:

I scroll over an item and it says

"getting details from MUD.."

but It never gives the info...

Thanks for the Help

Chris