Created: 7 days ago on 05/17/2025, 11:18:49 PMUpdated: 7 days ago on 05/17/2025, 11:20:07 PM
FileType: LUA
Size: 5480
Category: No category provided
Skills: Lumberjacking
Hotkey: No hotkey provided
Tags: crafter,lj,farming,hatchet,logs,boards
Description: Thank you to the diligent work from @Hopper to figure out the board processing for me! I have been working on this for 2 days with AI (yea im no coder) but all you have to do is make sure you have a hatchet in your hand, have some in your pack and do as follows:
Start script,
Select tree,
Move to next tree and select after current one empty.,
This script will process your logs into boards automatically once you are overweight and continue chopping. It will also re-equip automatically if you break a hatchet.
The only thing you need to do is move boards from your backpack into your pack horse/llama or bank/home.
I may try and make more improvements to it but its in a really good spot and HAD to share. Thanks again to Hopper!
-- Configuration
local MAX_WEIGHT_DIFF = 10
local MAX_WEIGHT = 390
local ITEM_ID_WOODEN_LOGS = 0x1BDD -- For log identification
function GetHatchet()
local axe = nil
for _, layer in ipairs({1, 2}) do
local checkAxe = Items.FindByLayer(layer)
if checkAxe and string.find(string.lower(checkAxe.Name or ""), "hatchet") then
axe = checkAxe
break
end
end
if not axe then
local equipaxe = Items.FindByName('Hatchet')
if equipaxe then
Player.Equip(equipaxe.Serial)
Pause(1000)
for _, layer in ipairs({1, 2}) do
local checkAxe = Items.FindByLayer(layer)
if checkAxe and string.find(string.lower(checkAxe.Name or ""), "hatchet") then
axe = checkAxe
break
end
end
end
end
if not axe then
Player.Say("No hatchet found.")
return nil
end
return axe
end
function GetLogs()
local itemList = Items.FindByFilter({})
for _, item in ipairs(itemList) do
if item and item.RootContainer == Player.Serial and item.Graphic == ITEM_ID_WOODEN_LOGS then
return item
end
end
return nil
end
function CreateBoards(hatchet)
local log = GetLogs()
if hatchet and log then
Player.Say("Chopping boards!")
Player.UseObject(hatchet.Serial)
if Targeting.WaitForTarget(1000) then
Targeting.Target(log.Serial)
Pause(1000)
else
Player.Say("Failed to target log for boards.")
end
elseif not hatchet then
Player.Say("No hatchet to make boards.")
elseif not log then
Player.Say("No logs to make boards.")
end
end
function CheckTreeStatus()
local noWoodMessages = {
"There is no wood here to chop.",
"You cannot see that.",
"That is too far away.",
"You can't use an axe on that.",
"You cannot reach that.",
"You have worn out your tool!",
"There's not enough wood here to harvest."
}
for _, msg in ipairs(noWoodMessages) do
if Journal.Contains(msg) then
Journal.Clear()
return true
end
end
return false
end
function ChopTree(hatchetSerial)
Player.Say("Chopping tree...")
local treeIsEmpty = false
while not treeIsEmpty and Player.Weight <= Player.MaxWeight - MAX_WEIGHT_DIFF do
Player.UseObject(hatchetSerial)
Pause(1500)
Targeting.TargetLast()
Pause(2000)
treeIsEmpty = CheckTreeStatus()
end
if Player.Weight > Player.MaxWeight - MAX_WEIGHT_DIFF then
Player.Say("Overweight!")
return true
end
return false
end
function Main()
Journal.Clear()
local needNewTree = true
while true do
local hatchet = GetHatchet() -- Get hatchet at the beginning of each loop
if not hatchet then
Player.Say("Could not find/equip a hatchet. Stopping.")
return
end
if Player.Weight > MAX_WEIGHT - MAX_WEIGHT_DIFF then
Player.Say("This shit is getting heavy...")
CreateBoards(hatchet)
if Player.Weight > MAX_WEIGHT - MAX_WEIGHT_DIFF then
Player.Say("Still too heavy, stopping.")
return
end
needNewTree = true
end
Player.UseObject(hatchet.Serial)
if Targeting.WaitForTarget(1000) then
if needNewTree then
Player.Say("Select a tree")
needNewTree = false
Pause(2000)
else
Targeting.TargetLast()
end
else
Player.Say("Targeting failed, trying again...")
Pause(1000)
goto continue_loop
end
Pause(2000)
if CheckTreeStatus() then
Player.Say("Need a new tree!")
needNewTree = true
Journal.Clear()
end
::continue_loop::
Pause(500)
end
end
Main()