Post by evra on Feb 14, 2021 1:25:43 GMT
The script will find all nearby rocks - equip pick, mine ore, move to next rock. It will also defend with fireballs and pet attack and move ore to pets bag. Some bugs but works 90% of the time.
--[[
Fully automated harvesting script. Needs to be customized for your uses.
MoveEx() - gets you to a spot reliably.
dropoff() - casts Gate to get you to your dropoff spot and back and NOT mess up the current "rail" of harvesting
defend() - if attacked, it'll move away, make pets attack, and spam fireball. Once done, it'll move back and equip hatchet again. Customize how you need it.
doTree() - harvests tree, uses prospect tool, and watches for mobs. Will move on after backpack weight stops increasing.
X, Y and Z decimal separator must be a comma and values must be sent as strings e.g. doTree("420,0", "420,1", "420,2")
]]--
gateToHouseKey = 10 -- key to cast gate to dropoff location
(REMOVED)
FindItem("bandage")
--- PUT bandage in your packhorse/beetles bag so we can find the dropoff bag.
dropoffBoxId = FINDITEM[1].CNTID
attackSpellKey = 2
RockCount = 1
function Equip(item) -- stole this from utils.lua
FindItem (item)
if FINDITEM == nil then
print(item .. " not found!")
return
end
local tool_id = FINDITEM[1].ID
local cont_id = FINDITEM[1].CNTID
if cont_id == CHARID then
print(item .. " already equipped!")
return
end
print("Equipping " .. item)
ContextMenu(tool_id, "Equip")
end
function MoveEx(x,y,z) -- starts you moving towards coordinates and waits until you're there before continuing
count = 0
repeat
count = count + 1
Move(x,y,z)
sleep(300)
until (CHARPOSX == x and CHARPOSZ == z) or count > 30
end
function dropoff()
print('dropping off...')
-- repeat
-- Macro(gateToHouseKey) -- this is casting gate from a hotkey to my house
-- sleep(4000)
-- FindPanel("Moongate")
-- if FINDPANEL == nil then
-- panelId = nil
-- else
-- panelId = FINDPANEL[1].ID
-- end
--until string.match(panelId, "ConfirmMoongate")
--ClickButton(FINDPANEL[1].ID, "0") -- "0" is the confirmation to travel button
--sleep(3000)
FindItem("Iron Ore",BACKPACKID) -- finds all logs in my backpack
for k, v in pairs(FINDITEM) do
Drag(v.ID)
Dropc(dropoffBoxId) -- and drops them in a chest at my house
sleep(500)
end
--FindItem("Portal") -- and travels back through the moongate
--UseSelected(FINDITEM[1].ID)
--sleep(1000)
--FindPanel("Moongate")
--ClickButton(FINDPANEL[1].ID, "0")
--sleep(3000)
--Equip("Hatchet") -- don't forget to re-equip your hatchet!
end
function defend()
while MONSTERSNEARBY == 'True' do -- if a monster is within maybe 5 units,
local x = CHARPOSX
local y = CHARPOSY
local z = CHARPOSZ
mId_s = NEARBYMONSTERS[1].ID
mId = mId_s
Move(x-5,y,z) -- run away a bit
sleep(1000)
Say('all follow me') -- get your pets with you
sleep(1000)
Say('all kill')
TargetDynamic(mId) -- make the pets attack mob (stupid boglings!)
for i=1,10 do
Macro(attackSpellKey) -- fireball on my hotbar
TargetDynamic(mId)
end
print('mob dead')
findOre(false)
end
end
function mineOre(x,y,z)
end
function checkRock()
if FINDPERMANENT[1].STONESTATE == 0 then
return true;
else
return false
end
end
function findOre(skip)
if skip == false then
Equip("Pickaxe")
MoveEx(x,y,z)
end
FindPermanent("Rock")
for rock in FINDPERMANENT do
if rock.STONESTATE == 0 or rock == 2 then
print('moving to rock')
Move(rock.ID)
sleep(1000)
local startTime = os.time(os.date("!*t"))
repeat
if skip == false then
Equip("Pickaxe")
end
defend()
Macro(28)
print('mining stuff')
WaitForTarget()
TargetPermanent(rock.ID)
FindPermanent(rock.ID)
sleep(1000)
until os.time(os.date("!*t")) > startTime + 10 or rock.STONESTATE == 1
end
if rock.STONESTATE == 1 then
repeat
defend() -- checks for nearby monsters and defends
startWeight = CHARWEIGHT
print("startWeight" .. startWeight)
endWeight = CHARWEIGHT
print("endWeight" .. endWeight)
print('start/end weight: ' .. startWeight .. ','..endWeight)
until startWeight == endWeight -- will move to next tree if, within 4 seconds-ish, weight didn't change (as in the tree is gone)
if endWeight > 300 then -- getting full, dropoff time!
dropoff()
end
end
end
end
while true do
findOre(false) -- add your own tree coordinates
end