inventory:itemTotalCount() question

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

inventory:itemTotalCount() question

#1 Post by noobbotter »

I have all 6 inventory bags unlocked/available but in one of my functions, I want to get the available space of only the first 4 bags. Would this work?

Code: Select all

slotsavailable = inventory:itemTotalCount(0,{"bag1","bag2","bag3","bag4"})
if not, then maybe I should do something like:

Code: Select all

slotsavailable = inventory:itemTotalCount(0,"bag1")
slotsavailable = slotsavailable + inventory:itemTotalCount(0,"bag2")
slotsavailable = slotsavailable + inventory:itemTotalCount(0,"bag3")
slotsavailable = slotsavailable + inventory:itemTotalCount(0,"bag4")
and then my other choice would be to do

Code: Select all

slotsavailable = 0
for slot = 61, 180 do
		local item = inventory.BagSlot[slot]
		if item.ID == 0 then
			slotsavailable = slotsavailable + 1
		end
	end
So what would be the best option for me? Thanks.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: inventory:itemTotalCount() question

#2 Post by rock5 »

The first option I would say doesn't work. The second and third look like they would. I think the second would be simpler and it also updates the slot info. Whereas the third does not, although you could add an "item:update()" if you wanted to.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: inventory:itemTotalCount() question

#3 Post by noobbotter »

Thanks for the feedback. After looking at how I was going to implement it, I decided to make a separate variable for how many slots I would use so I could easily change it so I'm going to be doing this:

Code: Select all

bagstouse = 4 	<!-- We will use this many bags for this script. I.e., with default of 4, it will use bags 1 thru 4 (slots 61 thru 180. -->)
	endslot = 0 -- establish the variable

	function setBagSlots()
		if bagstouse == nil then
			bagstouse = 4
		end
		
		if bagstouse == 1 then
			endslot = 90
		elseif bagstouse == 2 then
			endslot = 120
		elseif bagstouse == 3 then
			endslot = 150
		elseif bagstouse == 4 then
			endslot = 180
		elseif bagstouse == 5 then
			endslot = 210
		elseif bagstouse == 6 then
			endslot = 240
		end
	end

	setBagSlots()
   inventory:update()
	for slot = 61, endslot do
	   if item.ID == 0 then
			slotsavailable = slotsavailable + 1
		end
   end
-- of course I have a lot more code than this that executes within the functions and in the for statement. I just shortened it down for the applicable part that I had a question about. Doing it this way, I can use the endslot variable for my mailing functions as well. so everything I do within this waypoint will apply only to the bags I want to use, so that I can be safe that I won't accidentally send any good items I might have in bag 5 or 6. I'm updating my belt and fusion stone buying and sending script so it will look at how many equipment I currently have, look at my empty slots, look at how many characters I have to send to, and calculate a number of items to buy, then buy and send those proper amounts. In addition to that, It will start with a menu where I choose which group I want to send to, or I select the last option which is "All Groups" in which case it will go through the whole process for each group I have (currently I have 3 groups - 1 with 11 characters, and 2 groups with 16 each.) I've almost got the whole thing working. Hopefully tonight will be the magic night where it'll run through without errors.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: inventory:itemTotalCount() question

#4 Post by rock5 »

Maybe

Code: Select all

endslot = 60 + 30 * bagstouse
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: inventory:itemTotalCount() question

#5 Post by noobbotter »

Don't know how I didn't see that. Thanks again.
Post Reply