Page 1 of 1
item.ItemCount
Posted: Mon Feb 20, 2012 11:48 am
by Romplayer
How do i use this to get the # of items? I keep getting a nil when i update "item:update(id)"
Re: item.ItemCount
Posted: Mon Feb 20, 2012 11:56 am
by rock5
To get an item count use
Code: Select all
inventory:itemTotalCount(id or name)
No updates required.
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:10 pm
by Romplayer
i use that but i find it too slow when collecting quest items.. It doesn't update when the message pops up with example 9/10 to 10/10 items and i'll keep collecting to like past 10. so in my bag i'll have 11/10 quest items. or sometimes it'll error when collecting and freeze the bot with the cast bar stuck at full. the only way to remedy this is to call a mount to clear the cast bar. then the bot unfreezes
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:17 pm
by Romplayer
i use 14 >= inventory:itemtotalcount in a loop but i still collect 16
could i use item.ItemCount == 15 then break?
if so how do i define item and where ?
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:23 pm
by rock5
Maybe you are not using it properly. How are you using it and where are you putting it?
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:26 pm
by Romplayer
Code: Select all
while 14 > inventory:itemTotalCount(240627) do
-- yrest(500)
player:target_Object("Thief's Treasure Chest", 500, true, false);
--item:update(240627)
yrest(300)
end
as i was typing this it looted 16 and got stuck trying to loot still i had to ctrl L and reload the waypoint.
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:42 pm
by rock5
Using 'true' as the third argument in 'target_Object' will make it continue collecting all in range until there are none left. If you want it to check the number after each collection, try changing it to false so it only does one at a time.
As to it getting stuck, that is a different issue. Probably just a bug in the game.
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:46 pm
by Romplayer
i think i tried it at nil.. it would red out the casting bar so i use this and it collects smooth and fast
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:56 pm
by rock5
Maybe "smooth and fast" but you can't stop it when you have the right number.
I don't know why it would red the bar. I would suggest adding a pause but you already have one. I can't think of any more advice at the moment except try to increase the 500 to the actual time it takes to collet, or maybe a bit more.
Re: item.ItemCount
Posted: Mon Feb 20, 2012 12:58 pm
by Romplayer
would this work?
Code: Select all
while 14 > inventory:itemTotalCount(240627) do
-- yrest(500)
player:target_Object("Thief's Treasure Chest", 500, true, false);
--item:update(240627)
if item.ItemCount == 15 then
break
end
yrest(300)
end
Re: item.ItemCount
Posted: Mon Feb 20, 2012 1:01 pm
by rock5
No. This function wont finish until it has collected all nearby.
Code: Select all
player:target_Object("Thief's Treasure Chest", 500, true, false);
The only way to count them after each collection is to collect one at a time so the third argument must be false.
Re: item.ItemCount
Posted: Mon Feb 20, 2012 2:28 pm
by Romplayer
ok it works great
another thing i've been wondering is inventory:findItem(id) doesn't seem to work. I just get a table with no values i think.
Re: item.ItemCount
Posted: Mon Feb 20, 2012 8:52 pm
by lisa
a table with no values?
I am guessing you print the table like this
or something similar, that will only print the table number.
Code: Select all
table.print(inventory:findItem(id))
is what you want.
Re: item.ItemCount
Posted: Mon Feb 20, 2012 11:11 pm
by Romplayer
Code: Select all
local stuff = inventory:findItem(id)
for k in pairs(stuff) do
printf(k)
end
would this work?
Re: item.ItemCount
Posted: Tue Feb 21, 2012 1:08 am
by lisa
Romplayer wrote:would this work?
kind of
Code: Select all
local stuff = inventory:findItem(id)
for k,v in pairs(stuff) do
printf(v)
end
would be better, the k would just be numbers for the spot the info is in table.
easier/better to do what I posted tho
Code: Select all
local stuff = inventory:findItem(id)
table.print(stuff)
Re: item.ItemCount
Posted: Tue Feb 21, 2012 1:24 am
by rock5
lisa wrote:
Code: Select all
local stuff = inventory:findItem(id)
for k,v in pairs(stuff) do
printf(v)
end
Well.... 'v' by it self wouldn't be very informative and printf with no "\n" will cause it to put everything on one line. I'd use