Re: GMCP Inventory Organizer (Achaea)
Posted: Sun Jul 29, 2012 4:25 am
Would you mind uploading that on here?
User Help and Development Forum
https://forums.mudlet.org/
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.<[string "function display_inventory(match)..."]:70: bad argument #1 to 'find' (string
expected, got table)>
- then deleting display_inventory(matches), and adding a new trigger named "gag_inv":enableTrigger("gag_inv")
sendGMCP("Char.Items.Inv")
send(matches[1])
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.Guolin wrote:There is still one problem:
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.<[string "function display_inventory(match)..."]:70: bad argument #1 to 'find' (string
expected, got table)>
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?):
- then deleting display_inventory(matches), and adding a new trigger named "gag_inv":enableTrigger("gag_inv")
sendGMCP("Char.Items.Inv")
send(matches[1])pattern: ^.*$
deleteLine()
if isPrompt() then
disableTrigger("gag_inv")
display_inventory(matches)
end
Yeah, I'm having that issue as well, but I think I found the solution this time. The problem are these lines: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!
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: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))
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.for k,v in pairs(wield) do
num = k
name = v
derp = name
end
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![ERROR:] object:<event handler function> function:<inventory_gmcp>
<[string "if not items then items = {} end..."]:45: attempt to index global 'state' (a nil value)>