Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Aardwolf inventory in miniwindow

Aardwolf inventory in miniwindow

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


Pages: 1  2 3  4  

Posted by Blainer   (191 posts)  Bio
Date Reply #15 on Wed 08 Jul 2009 04:50 PM (UTC)
Message
Got it all done except the blurred text, indexes and a sharp tooth error I'll look at those tomorrow.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #16 on Wed 08 Jul 2009 09:13 PM (UTC)
Message
Your post seems truncated, there is no </muclient> tag.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #17 on Wed 08 Jul 2009 09:15 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #18 on Wed 08 Jul 2009 10:33 PM (UTC)
Message
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. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #19 on Wed 08 Jul 2009 11:40 PM (UTC)

Amended on Wed 08 Jul 2009 11:41 PM (UTC) by Nick Gammon

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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #20 on Thu 09 Jul 2009 02:09 PM (UTC)

Amended on Thu 09 Jul 2009 02:57 PM (UTC) by Blainer

Message
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.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #21 on Thu 09 Jul 2009 11:56 PM (UTC)
Message
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?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #22 on Fri 10 Jul 2009 08:01 AM (UTC)

Amended on Fri 10 Jul 2009 08:53 AM (UTC) by Blainer

Message
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.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #23 on Fri 10 Jul 2009 08:49 AM (UTC)
Message
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).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #24 on Fri 10 Jul 2009 08:55 AM (UTC)

Amended on Fri 10 Jul 2009 01:37 PM (UTC) by Blainer

Message
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.
Top

Posted by Chronicles   (5 posts)  Bio
Date Reply #25 on Fri 10 Jul 2009 12:09 PM (UTC)
Message
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
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #26 on Fri 10 Jul 2009 01:34 PM (UTC)

Amended on Fri 10 Jul 2009 02:14 PM (UTC) by Blainer

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

Top

Posted by Chronicles   (5 posts)  Bio
Date Reply #27 on Fri 10 Jul 2009 02:13 PM (UTC)
Message
Hi
thank you so much Blainer :)
now it works! :)
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #28 on Fri 10 Jul 2009 02:16 PM (UTC)

Amended on Fri 10 Jul 2009 02:39 PM (UTC) by Blainer

Message
Check back every couple of days for new versions I am still
working on it.
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #29 on Fri 10 Jul 2009 03:45 PM (UTC)
Message
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.
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.


200,403 views.

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

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

Go to topic:           Search the forum


[Go to top] top

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