GMCP Inventory Organizer (Achaea)

Share your scripts and packages with other Mudlet users.
Guolin
Posts: 4
Joined: Sun Jul 29, 2012 2:07 am

Re: GMCP Inventory Organizer (Achaea)

Post by Guolin »

Would you mind uploading that on here?

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: GMCP Inventory Organizer (Achaea)

Post by Rakon »

Sorry guys, I know from Trilliana that the 'new' one is having issues. I am working to fix it!
Just a little bit hard to narrow down the issue, with the utterly non-helpful, generic error messages given by the debug output of Mudlet.

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: GMCP Inventory Organizer (Achaea)

Post by Rakon »

This package has been fixed. PLEASE delete your old ones, and check out/download the most recent one on the first post.

Let me know if you run into any more issues, but I believe I have gotten the script exactly working now.

Guolin
Posts: 4
Joined: Sun Jul 29, 2012 2:07 am

Re: GMCP Inventory Organizer (Achaea)

Post by Guolin »

There is still one problem:
<[string "function display_inventory(match)..."]:70: bad argument #1 to 'find' (string
expected, got table)>
After looking at the code, it seems that the function it's complaining about is "if string.find(wield[num],'Bow') or string.find(wield[num],'warhammer') or ...etc...". Since wield is a 2D array, wield[num] is still an array, which the find() function doesn't seem to like. :cry:

Everything else (after commenting out that little tidbit) works perfectly! It's very nice. Two minor comments though:

1. isn't the "Get a few prompts before doing inv again please" message redundant if 'inv reset' automatically gets the regular inventory?
2. is there any way you can automatically get the regular inventory automatically when entering 'inv', then gag everything in the regular inventory (maybe every time 'inv' is entered, activate a trigger that does deleteLine() in response to ^.*$, and deactivates itself if isPrompt() is true, then sends the organized inventory?). Disregard if you've already tried that and it didn't work, heh.

EDIT: Making 'inv' auto-update works, by adding the following at the end of the 'inventory_inv' alias (if you've done the auto-update before but decided to remove it, what convinced you to remove it?):
enableTrigger("gag_inv")
sendGMCP("Char.Items.Inv")
send(matches[1])
- then deleting display_inventory(matches), and adding a new trigger named "gag_inv":
pattern: ^.*$

deleteLine()

if isPrompt() then
disableTrigger("gag_inv")
display_inventory(matches)
end

User avatar
Rakon
Posts: 350
Joined: Tue Feb 16, 2010 7:41 pm
Contact:

Re: GMCP Inventory Organizer (Achaea)

Post by Rakon »

Guolin wrote:There is still one problem:
<[string "function display_inventory(match)..."]:70: bad argument #1 to 'find' (string
expected, got table)>
After looking at the code, it seems that the function it's complaining about is "if string.find(wield[num],'Bow') or string.find(wield[num],'warhammer') or ...etc...". Since wield is a 2D array, wield[num] is still an array, which the find() function doesn't seem to like. :cry:

Everything else (after commenting out that little tidbit) works perfectly! It's very nice. Two minor comments though:

1. isn't the "Get a few prompts before doing inv again please" message redundant if 'inv reset' automatically gets the regular inventory?
2. is there any way you can automatically get the regular inventory automatically when entering 'inv', then gag everything in the regular inventory (maybe every time 'inv' is entered, activate a trigger that does deleteLine() in response to ^.*$, and deactivates itself if isPrompt() is true, then sends the organized inventory?). Disregard if you've already tried that and it didn't work, heh.

EDIT: Making 'inv' auto-update works, by adding the following at the end of the 'inventory_inv' alias (if you've done the auto-update before but decided to remove it, what convinced you to remove it?):
enableTrigger("gag_inv")
sendGMCP("Char.Items.Inv")
send(matches[1])
- then deleting display_inventory(matches), and adding a new trigger named "gag_inv":
pattern: ^.*$

deleteLine()

if isPrompt() then
disableTrigger("gag_inv")
display_inventory(matches)
end
Thank you for the testing and the input. Updated the main package ... again.

To your first question, you HAVE to get a prompt from achaea after the i reset because its on the next prompt AFTER the full inv that the GMCP information is sent. So no, this message is not redundant! I'm not sure what the point of adding in a trigger group to gag the standard inv/i is... if the custom display is going to show anyway, there's no need or advantage to send the i/inv command through just to gag it all anyway. You do NOT sendGMCP for the Char.Items.Inv everytime you do i or inv; this taxes the server heavily and has brought down warnings from Cardan. This new setup should be more efficient at tracking items using the add/update/remove GMCP functions and thus have no need to request the full list on each i/inv.

Trilliana
Posts: 21
Joined: Tue Nov 24, 2009 2:47 am

Re: GMCP Inventory Organizer (Achaea)

Post by Trilliana »

I've actually found my problem, but I can't figure out how to fix it without creating more errors. When it's capturing what I've got, if it sees my shield (cavalry) in either hand, it just ignores it all and sends just

You are wielding:

then nothing. if I unwield and do i reset and send a prompt or two then check, it works fine

otherwise, if I'm not wielding anything, it works fine!

Guolin
Posts: 4
Joined: Sun Jul 29, 2012 2:07 am

Re: GMCP Inventory Organizer (Achaea)

Post by Guolin »

Trilliana wrote:I've actually found my problem, but I can't figure out how to fix it without creating more errors. When it's capturing what I've got, if it sees my shield (cavalry) in either hand, it just ignores it all and sends just

You are wielding:

then nothing. if I unwield and do i reset and send a prompt or two then check, it works fine

otherwise, if I'm not wielding anything, it works fine!
Yeah, I'm having that issue as well, but I think I found the solution this time. The problem are these lines:
if string.find(name,'Bow') or string.find(name,'warhammer') or string.find(name,'bastard') or string.find(name,'halberd') or string.find(name,'bardiche') or string.find(name,'bow' or string.find(name,'quarterstaff' )) then
cecho(string.format(" (%s) %s in both hands.\n",num,name))
else
cecho(string.format(" (%s) %s in your left hand.\n",num,name))
name is a variable that contains the table array with two indices: 'name' and 'loc', i.e. the array contains values for name['name'] and name['loc']. I believe the value you want in the string.find and string.format functions is the name of the weapon you are wielding, which is contained in name['name']. So, replacing name with name['name'] everywhere above worked flawlessly for me. An even easier option would be to go to this:
for k,v in pairs(wield) do
num = k
name = v
derp = name
end
and replacing name = v with name = v['name'], since it seems like you want the actual name of the weapon (contained under the index ' name') rather than the entire table.

As for my 2 comments about the inventory aliases, I ran some tests with outrifting herbs and dropping items:

1. I outrifted all my bloodroot, dropped a random item from my inventory, then entered 'inv reset'. The the 'get a few prompts' message showed up, automatically followed by the standard inventory. Then I typed 'inv', and the extra bloodroot showed up and the random item I dropped was removed, and I didn't need to get any extra prompts in between except for the one that popped up automatically after 'inv reset'.

2. I did the same test again - outrifted all my bloodroot, dropped a random item from my inventory. Then I entered 'inv', and they were not automatically updated, and I had to 'inv reset' to get it to update. However, my idea of sending the inventory and gagging it every time I enter 'inv' is basically just inv resetting automatically every time I 'inv'. I did the same outrifting and dropping test again, but with the auto-reset and gag. The organized inventory popped up as usual, but the bloodroot appeared and the item was removed - without me typing 'inv reset'. I don't see how it would tax the server any more, because if I had to 'inv reset' before every time I check my inventory, I would still sendGMCP ever time I check my inventory. This only makes it automatic instead of manual.

Sorry if I'm not explaining myself clearly enough. If my post is confusing, maybe we can communicate IG with OOC tells? I just want to help make your script cleaner and more efficient.

Manni
Posts: 116
Joined: Tue May 31, 2011 9:00 pm

Re: GMCP Inventory Organizer (Achaea)

Post by Manni »

I'm finding in the latest iteration of the script that there is an issue with it properly updating off of the 'add' and 'remove' events. I haven't tested on any of the others. There is also an error about a "state" table that you try using on line 45:
[ERROR:] object:<event handler function> function:<inventory_gmcp>
<[string "if not items then items = {} end..."]:45: attempt to index global 'state' (a nil value)>
Now, I'm trying to figure out these changes since I last updated, but I figured I'd drop in and let you know. Sorry for the hassle!

Manni
Posts: 116
Joined: Tue May 31, 2011 9:00 pm

Re: GMCP Inventory Organizer (Achaea)

Post by Manni »

I figured I might as well post the update since the changes to gmcp several months ago. I also corrected a few errors in the previous script so things should now work properly.
Attachments
GMCP Inventory.zip
(4.79 KiB) Downloaded 421 times

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: GMCP Inventory Organizer (Achaea)

Post by icesteruk »

Any way to make this just show 'held' items???

Post Reply