Quick Syntax question

Sadge

Sexy Shoeless God of War
Joined
Nov 2, 2007
Messages
567
Reaction score
0
Points
16
Location
Washington, DC area
Can I find if an item is stackable without having it in my inventory?

I know:
Code:
${FindItem[${Distillate of Divine Healing X}].Stackable}

works, but only if I have the item (hence the FindItem). I'm sure I probably know the answer but I'm fried atm and can't think of it if anyone could offer a quick help.

Thanks!
 
To my knowledge, having the item in your inventory/bank or on your cursor is the only way that MQ2 has access to the info about it.
 
unless you pull the info from linkDB you wont be able to get it without the item.. Not even sure you can access the info from the LinkDB, but that would be the direction I would look. Access the link so you can have it read the info to find if its stackable.
 
Then I'm going to have to come up with some very ghetto code...

Thanks for the quick reply guys. That's what I needed to know.
 
what are you trying to do? Maybe can rework the logic
 
I'm working on my autoaccepttrade plugin. What I'm doing atm isn't as important to the plugin but I thought it'd be a nice feature.

What I'm working on atm is to have the plugin do an inventory check to make sure you have inventory room to accept the trade. I have it about 75% working -- the problem I ran into in testing is that when you trade with someone you can have items in trade slot 9 & 15 without having anything in 10, 11, etc...

That of course was a simple fix, but the problem I was running into was later in the code where I'm trying to check even if your inventory is full if there are stackable items that you can still accept (using the FreeStack code). I have an array that contains the name of the items being traded, but I didn't have the information as to what trade slot they were in or how many items in the stack. What I was trying to do was to run a quick check to see if the items were stackable without going back and finding them in the trade window. What I'm starting to realize is that it might not make a difference anyway because if you can't find the item in your inventory and your inventory is full it doesn't matter if it's stackable or not -- you still won't be able to fit it into your inventory.

I thought it'd be cool though for boxing if the character accepting the trade would be able to report something along the lines of: "You're giving me 8 items and I only have room for 4, but I can also take 10 of the <insert stackable item here> that you're trying to give me." (in this example there would be 7 items+a stack of <something>). When I'm boxing I usually use 1 main character as a master looter and over time his inventory can fill up so I like to "dump off" on some of my other characters. But I hate trying to keep track of stacks of stuff when their inventory starts to fill up too.

I think I can handle the code, but it just takes me a little longer because I don't have the knowledge or quick brain that you all seem to have here. :p I'm more like a bull in the china shop -- I'll plow my way through and it may not be pretty. The end result is usually I'll have 500 lines of code and then after I post it, I'll realize I could have done the same thing with 10 lines. Oh well.

Thanks for the feedback guys.
 
Well, if you're trying to see if the person's inventory is full, but they have room for stackables, you're already going the item in there.

One thing you could do to ignore stackables is count how many slots are full in the trade wnd, and compare to how many slots are full in the inventory. Then you could do a check like this:

if (findItem[itemname].stackable && (finditem[itemname].StackSize > ((finditemcount[itemname] % finditem[itemname].StackSize) + number of that item coming in))

then it doesn't take up any inventory slots to accept that item. Otherwise, it takes up ((number coming in - finditem[itemname].StackSize) / finditem[itemname].StackSize) + 1 number of slots.
 
I'm going to have to take another look at that code thez because my knowledge isn't that great and I'm having problems completely understanding your code (I think I understand it, but bear with me as I break it down). A lot of times it just helps me to write out what exactly is going on:

Code:
if (findItem[itemname].stackable

ok no problem -- this will scheck to see if you have the item and if it's stackable

Code:
&& (finditem[itemname].StackSize

this will return the max stack size, correct? In other words, usually 20 or 100

Code:
> ((finditemcount[itemname]

this will return how many of the stack we currently have (and the > will make sure it's less than max stack)

Code:
% finditem[itemname].StackSize) + number of that item coming in))

ok here's where I'm really stupid (at least I admit it). I have no idea what % does in this case. I feel like an idiot because normally I would research this and figure it out myself to save some face, but I don't have my links on the new computer and I have about a billion other things to do first. I don't get what the difference is between finditemcount[itemname] and finditem[itemname].StackSize ... does that handle multiple stacks? In other words, if the item count is 39 (for an item that's only stackable to 20), does that reutrn 19 or 1?

EDIT: ok so I looked it up and I found that % will return remainder, correct? In other words, in my expample it will return 1 correct? [/EDIT]

Here's what I have so far (in quasi-code). Once the plugin makes it through the trade checks and decides it's time to do the trade, it then:
Code:
for tradeslotloop = 9 to 18
{read each slot
if item received place in itemsreceived array
totalitems received++
}

At which point, I know how many items are coming in (I'll have to change this in the future to read the number of the stacked items). Then:
Code:
Check Inventory (find out how much inv space I have)
If Inventory < itemsreceived then do stackable items check (this is the part I'm working on atm)
else do trade (since we have the inventory room

What I'm thinking for the stackable items check is:
Code:
for loop = 1 to items received {
check to see which items are stackable
compare stackable items to FreeStack
if stackableitems received <= FreeStack then totalitemsreceived - 1}

At whcih point, I should be able to run Inventory check again and if Inventory => items reveiced then we can do the trade. Of course somewhere in there I'd have to spit out the report (if I could) to say how many of which items I can receive. The only problem I have with that is the fact that since this plugin refreshes every time MQ2 pulses that the report would come back multiple times. I think I'll figure it out though.

Sorry for the long post, but like i said sometimes it helps me to just psuedocode it like this to figure out what the hell I'm thinking. :rolleyes:
 
Last edited: