how to cycle backpack slots

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

how to cycle backpack slots

#1 Post by Rickster »

i read about this way to cycle all inventory slots

Code: Select all

for slot, item in pairs(inventory.BagSlot) do
this cycles through all your item shop, transmutor and backpack slots.

i am looking for loop that only cycles through existing backpack slots. so if someone only has backpack slot one and two, it shall only cycle these.

someone has an idea, how to do that?

thanx
ric
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: how to cycle backpack slots

#2 Post by rock5 »

Well the bags are slot 61 to 240. There is nowhere stored which bags are available but the slots themself are marked available. Usually I would do it like this (assuming your not looking for empty slots)

Code: Select all

for slot = 61, 240 do
    if (not slot.Empty) and slot.Available then
  • 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
Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

Re: how to cycle backpack slots

#3 Post by Rickster »

i would like to get an object to work with, for example
itemName = item.Name

so how do i get "item" as an object in the loop?

[edit]
got it :)

Code: Select all

		for slot = 61, 240 do
			if (not inventory.BagSlot[slot].Empty) and inventory.BagSlot[slot].Available then
				item = inventory.BagSlot[slot]
				printf("%s. %s\n", slot, item.Name);
			end;
		end;
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: how to cycle backpack slots

#4 Post by rock5 »

Sorry, I did it wrong. I meant to say I would do it like this.

Code: Select all

local item
for slot = 61, 240 do
    item = inventory.BagSlot[slot]
    if (not item.Empty) and item.Available then
So a better way of doing what you said would be

Code: Select all

		local item
		for slot = 61, 240 do
			item = inventory.BagSlot[slot]
			if (not item.Empty) and item.Available then
				printf("%s. %s\n", slot, item.Name);
			end;
		end;
  • 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
Post Reply