Change Rydan to the character on which you want to use mana potions.
Open the main backpack of your "mana-using" character and then the backpack that is on the ground which contains the mana potions.
Be sure that the backpack containing the mana potions is stacked (1 in 1) and the next backpack is always at the last spot.
Then start the script.
It should always take 100 manas from the backpack > use them until empty > drop flasks > take 100 manas > ...
lua code:PLAYERNAME = "Rydan"
--DO NOT EDIT BELOW
mainContainer = Container.New(0)
manaContainer = Container.New(1)
usePlayer = Creature.New(PLAYERNAME)
Module.New("Use Mana", function()
if (Self.ItemCount("mana potion", mainContainer:Index()) >= 1) then
for containerSpot = 0, mainContainer:ItemCount()-1 do
if (mainContainer:GetItemData(containerSpot).id == Item.GetID("mana potion")) then
repeat
mainContainer:UseItemWithCreature(containerSpot, usePlayer:ID())
wait(1000, 1050)
until
mainContainer:GetItemData(containerSpot).id ~= Item.GetID("mana potion")
break
end
end
else
if (Self.ItemCount(285, mainContainer:Index()) >= 1) then
for containerSpot = 0, mainContainer:ItemCount()-1 do
if (mainContainer:GetItemData(containerSpot).id == 285) then
mainContainer:MoveItemToGround(containerSpot, Self.Position().x, Self.Position().y, Self.Position().z, 100)
local waitTries = 0
repeat
wait(100)
waitTries = waitTries+1
until
waitTries >= 20 or Self.ItemCount(285, mainContainer:Index()) == 0
break
end
end
elseif (Self.ItemCount(285, mainContainer:Index()) == 0) then
if (Self.ItemCount("mana potion", manaContainer:Index()) >= 100) then
for containerSpot = 0, manaContainer:ItemCount()-1 do
if (manaContainer:GetItemData(containerSpot).id == Item.GetID("mana potion")) then
manaContainer:MoveItemToContainer(containerSpot, mainContainer:Index(), mainContainer:ItemCapacity()-1, 100)
local waitTries = 0
repeat
wait(100)
waitTries = waitTries+1
until
waitTries >= 20 or Self.ItemCount("mana potion", mainContainer:Index()) >= 1
break
end
end
else
manaContainer:UseItem(manaContainer:ItemCount()-1, true)
wait(250)
end
end
end
end)