Page 1 of 1
move to itemshop bag
Posted: Wed Jan 23, 2013 4:54 pm
by lolita
why this sometime's work sometime's don't
Code: Select all
function moveitemshop()
for i, item in pairs(inventory.BagSlot) do
for k, v in ipairs(item_shop_bag) do
if v == item.Name then
printf("Moving to Item Shop bag: "..item.Name.."\n");
item:moveTo("itemshop")
yrest(500)
end
end
end
end
item_shop_bag = {
"Purified Fusion Stone",
"Master's Simple Repair Hammer",
"Grand Golden Repair Hammer"
}
can someone help, or is there simple way to move items in tabe to item shop bag
Re: move to itemshop bag
Posted: Wed Jan 23, 2013 7:15 pm
by lisa
It looks like it should be ok, when does it not work?
Exactly what happens.
If anything I would suguest using ID's instead of names but it should still work with the names.
Re: move to itemshop bag
Posted: Wed Jan 23, 2013 9:19 pm
by lolita
that function is in my userfunctions_file, and when i call it from waypoint it move items only first time, but when next time function is called i dosen't do anything.
And it try to move items that are already in item shop, should i put something like this
Code: Select all
function moveitemshop()
for i, item in pairs(inventory.BagSlot) do
if item.SlotNumber >= 61 then
for k, v in ipairs(item_shop_bag) do
if v == item.Name then
printf("Moving to Item Shop bag: "..item.Name.."\n");
item:moveTo("itemshop")
yrest(500)
end
end
end
end
end
Or is there simple way to move items to item shop bag, i need only to move 3 difrent items can i do sometihng like this
Code: Select all
if inventory:itemTotalCount("Purified Fusion Stone") > 0 then
item:moveTo("itemshop")
end
Re: move to itemshop bag
Posted: Wed Jan 23, 2013 10:21 pm
by lisa
From the sounds of it you might need to do an inventory:update() at the start of the function.
In the second code you posted you would still need to define "item"
Code: Select all
local item = inventory:findItem("Purified Fusion Stone")
if item then
item:moveTo("itemshop")
end
I would still use the table but also use find item.
Code: Select all
local item_shop_bag = {
"Purified Fusion Stone",
"Master's Simple Repair Hammer",
"Grand Golden Repair Hammer"
}
for k,v in pairs(item_shop_bag) do
repeat
local item = inventory:findItem(v)
if item then
item:moveTo("itemshop")
end
until not item
end
Re: move to itemshop bag
Posted: Wed Jan 23, 2013 11:43 pm
by rock5
Yeah, I'd do it Lisas way because if a move fails, for whatever reason, it will try to move it again. But you don't need inventory:update() because inventory:findItem does an update already.
Re: move to itemshop bag
Posted: Wed Jan 23, 2013 11:51 pm
by lisa
rock5 wrote:Yeah, I'd do it Lisas way because if a move fails, for whatever reason, it will try to move it again. But you don't need inventory:update() because inventory:findItem does an update already.
k removed the update, wasn't sure about it so added it in just in case lol
the repeat loop might need a check for space in itemshop bag though, if it gets full then the moveto will fail and stay in the loop forever.
the inventory:itemTotalCount() doesn't include item shop when calculating free space, so you would need to add in your own code to check free space of item shop.
Something like this
Code: Select all
local item_shop_bag = {
"Purified Fusion Stone",
"Master's Simple Repair Hammer",
"Grand Golden Repair Hammer"
}
for k,v in pairs(item_shop_bag) do
repeat
local count = 0
for slot = 1, 50 do
local item = inventory.BagSlot[slot]
item:update()
if item.Empty then
count = count + 1
end
end
if count == 0 then print("No space in item shop bag") break end
local item = inventory:findItem(v)
if item then
item:moveTo("itemshop")
end
until not item
end
count would be the number of available spots you can put items in, so count == 0 means you have no space to put the item.
Re: move to itemshop bag
Posted: Thu Jan 24, 2013 1:40 am
by rock5
lisa wrote:the inventory:itemTotalCount() doesn't include item shop when calculating free space, so you would need to add in your own code to check free space of item shop.
Code: Select all
inventory:itemTotalCount(0,"itemshop")
Re: move to itemshop bag
Posted: Thu Jan 24, 2013 1:59 am
by lisa
ahh you are right, I missunderstaood the code.
Code: Select all
if first == nil then
-- Default values - 1-240 for items, 61-240 for empties.
if itemNameOrId == "<EMPTY>" or itemNameOrId == 0 then
first = 61
else
first = 1
end
last = 240 -- default, search only bags
end
I glanced at that and went, yup it defaults to just check actual bags, but first isn't nil if you specify the "itemshop" as second arg.
Code: Select all
local item_shop_bag = {
"Purified Fusion Stone",
"Master's Simple Repair Hammer",
"Grand Golden Repair Hammer"
}
for k,v in pairs(item_shop_bag) do
repeat
local item = inventory:findItem(v)
if item then
item:moveTo("itemshop")
end
until not item or inventory:itemTotalCount(0,"itemshop") == 0
end
Re: move to itemshop bag
Posted: Thu Jan 24, 2013 9:18 am
by lolita
did you tested it lisa, cose it still dont work for me

i just added "print" to your code
Code: Select all
function jbg()
local item = inventory:findItem("Purified Fusion Stone")
if item then
printf("Moving to Item Shop bag\n");
item:moveTo("itemshop")
end
end
just print "Moving to Item Shop bag" and nothing happen
Code: Select all
local item_shop_bag = {
"Purified Fusion Stone",
"Master's Simple Repair Hammer",
"Grand Golden Repair Hammer"
}
for k,v in pairs(item_shop_bag) do
repeat
local item = inventory:findItem(v)
if item then
printf("Moving to Item Shop bag\n");
item:moveTo("itemshop")
end
until not item or inventory:itemTotalCount(0,"itemshop") == 0
end
keep picking up item and printing
Code: Select all
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
Moving to Item Shop bag
and again not moving items.
btw im useing RC3 version and 5.0.6 game version
Re: move to itemshop bag
Posted: Thu Jan 24, 2013 9:27 am
by rock5
inventory:findItem finds from the whole inventory, which includes itemshop and magicbox. You need to limit the search to just "bags".
Code: Select all
local item_shop_bag = {
"Purified Fusion Stone",
"Master's Simple Repair Hammer",
"Grand Golden Repair Hammer"
}
for k,v in pairs(item_shop_bag) do
repeat
local item = inventory:findItem(v,"bags")
if item then
printf("Moving to Item Shop bag\n");
item:moveTo("itemshop")
end
until not item or inventory:itemTotalCount(0,"itemshop") == 0
end
Try that.
Re: move to itemshop bag
Posted: Thu Jan 24, 2013 9:48 am
by lolita
it's funny, it's same code lisa posted, and it work now, i dont know why wasn't working first time i tested it.
Anyway it work now,

ty again Rock5 and lisa
**EDIT
it's almost same, you added "bags" in this line
Code: Select all
local item = inventory:findItem(v,"bags")
Re: move to itemshop bag
Posted: Sun Jul 07, 2013 8:56 am
by cokebot
is it possible to move every itemshopitem into the item shop bag?
like is item a itemshopitem then move to.
Re: move to itemshop bag
Posted: Sun Jul 07, 2013 10:20 am
by rock5
Yes but you would have to loop through all the items. There are no functions for it.
Code: Select all
local item
for slot = 61, 240 do
item = inventory.BagSlot[slot]
item:update()
if item.Available and (not item.InUse) and item.ItemShopItem == true then
item:moveTo("itemshop")
end;
end;
I think that should work.
Re: move to itemshop bag
Posted: Mon Jul 08, 2013 8:19 am
by cokebot
works perfect Rock5, needs less then a second.
Great thanks a lot.