mrx
New Member
Posts: 9 Likes: 0
|
Post by mrx on Jun 14, 2022 14:11:11 GMT
function equip(item, containerId) FindItem(item, CHARID) if FINDITEM then -- Already equiped return end FindItem(item, containerId) if FINDITEM then ContextMenu(FINDITEM[1].ID, "Equip") sleep(1000) end end
function moveTo(X, Z) local time = TIME while not distanceTo(X, Z) do Move(X, CHARPOSY, Z) sleep(1000) if TIME > time + 10 then print("Stuck moving!!") Move(CHARPOSX, CHARPOSY, CHARPOSZ + 1) end end end
function distanceTo(X, Z) xmin, xmax = math.min(CHARPOSX, X), math.max(CHARPOSX, X) zmin, zmax = math.min(CHARPOSZ, Z), math.max(CHARPOSZ, Z) xtrue = xmax - xmin < 2 ztrue = zmax - zmin < 2 return xtrue and ztrue end
function cutTree(treeId, rideId) local timeOut = 15 local isTimeout = false FindPermanent(treeId) if FINDPERMANENT and FINDPERMANENT[1].TREESTATE == 0 and FINDPERMANENT[1].DISTANCE < 80 then equip("hatchet", BACKPACKID)
mountRide(rideId) moveTo(FINDPERMANENT[1].X, FINDPERMANENT[1].Z) Macro(28) WaitForTarget() TargetPermanent(treeId) sleep(1000) time = TIME while FINDPERMANENT[1].TREESTATE == 0 and isTimeout == false do FindPermanent(treeId) isTimeout = TIME > time + timeOut
sleep(1000) end if isTimeout then print(timeOut .. " seconds timeout!") end end end
function mountRide(rideId) if rideId then ContextMenu(rideId, "Mount") end end
function hasHatchet() FindItem("hatchet") if FINDITEM then return true end return false end
--[[ ######################################################################################### # # # You have to config your tree ids separated by comma in order for this script to work. # # You can add as many trees as you want, as long they are not too far away. # # Set up your rideId if you want to use a ride, otherwise leave it as it is. # # The script will stop after one of the following conditions is true: # # - All trees have been cutted # # - Reached full weight # # - Dead # # - No more hatchets available # # # ######################################################################################### --]]
local treeIds = {} local rideId
for treeId in treeIds do cutTree(treeId, rideId) if CHARWEIGHT > 300 or hasHatchet() == false or CHARGHOST then StopAllScripts() end end
|
|