Mouthpiece of horn user
DescriptionUsing mouthpieces of horn at crude bone of horn.
ConfigurationPut backpacks with horns and mouthpieces to 1 depot box. You need to have some space in your main backpack.Code
init start
-- Script_Version 1.0.0
local hornBp = "grey backpack" -- Backpack with not used horns
local mouthpieceBp = "yellow backpack" -- Backpack with mouthpieces
local dbLocation = 10 -- Location of backpacks
-- Do not edit
local mouthId = 20057
local hornId = 20055
local usedHorn = 20056
local counter = 0
local function findContainer(index)
local info = {found = false, id = 0}
local cont = getcontainer(index)
for i = 0, cont.itemcount do
if iteminfo(cont.item[i].id).iscontainer then
info.found, info.id = true, cont.item[i].id
end
end
return info
end
init end
closewindows()
while windowcount() == 0 do
openitem($back.id, "back") waitping(2, 3)
resizewindows(0, "0")
end
local mainBp = getcontainer(0).name
opendepot(dbLocation)
if itemcount(hornBp, 1) == 0 then
printerror("There is no horn bp in depot box ".. dbLocation ..". Persistant stopped.")
return false
end
if itemcount(mouthpieceBp, 1) == 0 then
printerror("There is no mouthpiece bp in depot box ".. dbLocation ..". Persistant stopped.")
return false
end
local hornIndex, mouthIndex = 2,1
while windowcount(hornBp) == 0 do
openitem(hornBp, 1, true) waitping(2,3)
end
resizewindows(100, "2")
while windowcount(mouthpieceBp) == 0 do
openitem(mouthpieceBp, 1, false) waitping(2,3)
end
resizewindows(100, "1")
while (true) do
if itemcount(mouthId, mouthIndex) == 0 then
local bp = findContainer(mouthIndex)
if bp.found then
openitem(bp.id, mouthIndex, false) waitping(2,3)
else
if itemcount(mouthId, mouthIndex) == 0 then
printerror("There is no more mouthpieces of horn. It have made ".. counter .. " horns. Persistant stopped.")
break
end
end
end
if itemcount(hornId, hornIndex) == 0 then
local bp = findContainer(hornIndex)
if bp.found then
openitem(bp.id, hornIndex, false) waitping(2,3)
else
if itemcount(hornId, hornIndex) == 0 then
printerror("There is no more cruds horn of bone. It have made ".. counter .. " horns. Persistant stopped.")
break
end
end
end
while itemcount(hornId, hornIndex) > 0 and itemcount(mouthId, mouthIndex) > 0 do
useitemon(hornId, mouthId) waitping(2,3)
while itemcount(usedHorn, mainBp) > 0 and getcontainer(hornIndex).emptycount > 0 do
moveitems(usedHorn, hornIndex, mainBp, 1) waitping(2,3)
counter = counter + 1
end
end
end