[EasyUO] Auto Lumberjacking an area.

If you make a Client-side script you can publish it here for other players to use
Blade Slinger
Apprentice Scribe
Posts: 17
Joined: Tue Mar 23, 2010 6:11 pm

[EasyUO] Auto Lumberjacking an area.

Post by Blade Slinger »

Ever wish you could run up amongst a bunch of trees and click play and harvest the trees in the area? That's what this script does. You have to keep an eye on it because you will get AFK checked while it's running. You will need woodworkers keys to keep your pack cleaned out and not get overweight. You also will need a high use hatchet from either your exex box or the tool house. Just put the axe in your hand run up amongst some trees and click play. It will show you what tree of the count in the area it's on. Once it gets back to tree number 1 then stop the script (not pause) and move to a new area and start it again.

Please let me know if you have trouble.

Code: Select all

set %currentTree 0
set %treeCount 0
set %currentX 0
set %currentY 0

gosub getwoodkeys

sub scanTiles
	set #LPC 1000
	set %range 15
	tile init noOverrides
	set %minX #charPosX - %range
	set %maxX #charPosX + %range
	set %minY #charPosY - %range
	set %maxY #charPosY + %range
	for %x %minX %maxX
	{
		for %y %minY %maxY
		{
			tile cnt %x %y
			for %i 1 #tileCnt
			{
				tile get %x %y %i
				if TREE in #tileName
				{
					set % , tx , %spot %x
					set % , ty , %spot %y
					set % , tz , %spot #tileZ
					set % , tt , %spot #tileType
					
					set %spot %spot + 1
					set %treeX . %treeCount %x
					set %treeY . %treeCount %y
					set %treeZ . %treeCount #tileZ
					set %treeCount ( %treeCount + 1 )
				}
			}
		}
  }
  gosub walkToTree
return

sub walkToTree
    set #LPC 10
		set %msgTree %currentTree + 1
    event ExMsg #charID 3 0 Tree %msgTree of %treeCount $
    set %currentX ( %treeX . %currentTree )
    set %currentY ( %treeY . %currentTree )
		set %currentZ ( %treeZ . %currentTree )
    if %currentTree = %treeCount - 1
    			set %currentTree -1
		move %currentX %currentY 0 5s   
    gosub lumber
return

sub lumber
	finditem FSF 
	set #lObjectId #findID
	set #lTargetX %currentX
	set #lTargetY %currentY
	set #lTargetZ %currentZ 
	set #lTargetKind 3
	
	Tile cnt %currentX %currentY 
	Tile Get %currentX %currentY #tileCnt 
	set #lTargetTile #tileType
		
	repeat
	{
		event macro 17 0 ; last object
		 target 5s
		event macro 22 0 ; last target
		set %jStart #jindex
		set %timeexpire #time + 5 ; wait for 5 sec for a server response
		set %nextTreeNow 0
		while #jindex = %jStart ; wait for response from server.
		{
			if #time > %timeexpire
			{
				set %nextTreeNow 1
				break
			}
		}

		set %jEnd #jIndex
		for %i %jStart %jEnd
		{
			scanjournal %i
			if not_enough_wood in #journal
			{
				set %nextTreeNow 1      	  
			}
			if use_an_axe_on in #journal
			{
				set %nextTreeNow 1				  
				wait 1s
				set %currentTree ( %currentTree + 1 )
				gosub walkToTree
			}
			if too_far_away in #journal
			{
				set %nextTreeNow 1
				set %currentTree ( %currentTree + 1 )
				wait 1s
				gosub walkToTree
			}
			if you_hack_at in #journal
			{
				 set %nextTreeNow 1
			}
		}
	}
	until %nextTreeNow = 1
	wait 5
	; add logs and items to wood keys
	;event ExMsg #charID 3 0 Chopping Logs
	gosub chopLogs
	wait 5
	;event ExMsg #charID 3 0 Adding to Keys
	gosub woodKeys
	set %currentTree ( %currentTree + 1 )
	gosub walkToTree
return


gosub scanTiles


sub chopLogs

     ; chop all logs in pack
    finditem FSF 
    set #lObjectId #findID
    set %HATCHET #findID
    set %Log ZLK
    finditem %Log C_, #BackpackID      
    while #findkind <> -1
    {      
       set #lObjectId %HATCHET
       event macro 17 0 ; last object
       target 5s
       wait 4        
       set #lTargetId #findId
       set #lTargetKind 1
       event macro 22 0 ; last target
       wait 4
       finditem %Log C_, #BackpackID
       
    }       
return




sub getwoodkeys
_findwoodkeys:

  findItem NUI C_ , #backpackID
  if #findkind = -1
     return
  event property #findID
  if Wood in #property
  {
     set %keys #true
     set %keysid #findid
     set #lObjectID %keysid
     event macro 17 0 ; last object
     return

  }
  
  if %keys <> #true
  {
   ignoreitem #findID
   goto _findwoodkeys
  }
  
return

;;;;; Wood ;;;;;
sub woodKeys
set #lObjectID %keysid
event macro 17 0
gosub keyMenuWait

set %clickX #contPosX + 290
set %clickY #contPosY + 360
click %clickX %clickY
target 3s
wait 3
set %lTargetKind #lTargetKind
set #lTargetKind 1

woodAddLoop:
finditem TLK C_ , #backpackID
if #findKind = -1
{
   goto barkAddLoop
}
set #lTargetID #findID
set #lTargetKind 1
event macro 22 0  ; last target
target 3s
goto woodAddLoop


barkAddLoop:
  finditem NWS C_ , #backpackID
  if #findKind = -1
  {
     goto switchAddLoop
  }
  set #lTargetID #findID
  set #lTargetKind 1
  event macro 22 0  ; last target
  target 3s
goto barkAddLoop


switchAddLoop:
  finditem BWR C_ , #backpackID
  if #findKind = -1
  {
     goto fungiAddLoop
  }

  set #lTargetID #findID
  set #lTargetKind 1
  event macro 22 0  ; last target
  target 3s
goto switchAddLoop

fungiAddLoop:
  finditem XWS C_ , #backpackID
  if #findKind = -1
  {
     goto parasiticAddLoop
  }

  set #lTargetID #findID
  set #lTargetKind 1
  ; wait 3s
  event macro 22 0  ; last target

  target 3s
goto fungiAddLoop


parasiticAddLoop:
  finditem YWS C_ , #backpackID
  if #findKind = -1
  {
     key ESC
     wait 1s
     click %clickX %clickY r
     set #lTargetKind %lTargetKind
     return
  }

  set #lTargetID #findID
  set #lTargetKind 1
  event macro 22 0  ; last target

  target 3s
goto parasiticAddLoop


return


sub keyMenuWait
set %timePass = #sCnt + 5
keyLoop:
if #sCnt > %timePass
{
	event macro 17 0
	set %timePass = #sCnt + 5
}
wait 1
if #contSize <> 505_395 
   goto keyLoop
return

User avatar
Matrix
Legendary Scribe
Posts: 271
Joined: Sun Mar 08, 2020 5:57 pm

Re: [EasyUO] Auto Lumberjacking an area.

Post by Matrix »

Woow masterwork. Thanks.
Please reply to me:
in-game: [pm Matrix
discord id: Matrixre
(Only checking the forums monthly)
(All prices can be change, ED to Gold to ED)
Wild Retic
Grandmaster Scribe
Posts: 71
Joined: Sat Jun 05, 2021 9:18 pm

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wild Retic »

All its doing for me is telling me i have to waite to use another skill. Not even one log :-(
not to mention it seems to be running wayyy tooo fast
Blade Slinger
Apprentice Scribe
Posts: 17
Joined: Tue Mar 23, 2010 6:11 pm

Re: [EasyUO] Auto Lumberjacking an area.

Post by Blade Slinger »

Wild Retic wrote:
Wed Jan 05, 2022 10:11 pm
All its doing for me is telling me i have to waite to use another skill. Not even one log :-(
not to mention it seems to be running wayyy tooo fast
That's strange because this script doesn't directly use any skills. However, it does use the arrow keys to move around. If you have a macro setup on your arrow keys it may be trying to use that macro. I have macros on my arrow keys in uosteam and I setup the F1 button to toggle disable macros off and on so I turn off the uosteam macros when I run this script. I haven't noticed it running too fast. Seems to be running rather smooth for me.
Wild Retic
Grandmaster Scribe
Posts: 71
Joined: Sat Jun 05, 2021 9:18 pm

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wild Retic »

Yes, i have things set on my arrow keys, disco, peace, provoke. Thanks, ill let you know what happens.
Reskal
Elder Scribe
Posts: 108
Joined: Fri Aug 29, 2008 10:54 am

Re: [EasyUO] Auto Lumberjacking an area.

Post by Reskal »

Trying it out actually, a pretty good macro it is, unfortunately it just stops working after the first tree. It moves to 2nd tree if the first one is not doable because it's the bush-type tree that gives no logs, then after getting logs it works them to boards and then he just sits there, nothing happens further.
Someone an idea what could be wrong ?

Edit 2 mins later: lol i just opened the Wood Worker's Keys and it added the boards and went to the next tree !

Now i found the problem, the key is closed after the script added the boards, so i have to open it again after every tree.
Well, not a problem for me, because it still helps very much and this way i avoid forgetting it and getting trouble because of AFK-macroing :lookingout:
User avatar
Wil
Legendary Scribe
Posts: 1128
Joined: Mon Dec 30, 2013 1:19 pm
Location: Seattle, WA, USA
Contact:

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wil »

Here's an OpenEUO logging script if you want it. It will log in a straight line north or south depending on what you set the variable to at the top of lumberjacking.lua. It has some ability to navigate around obstacles in the path to the next tree.

You will need either a bag of resources or a bag of holding containing a normal bag you've engraved with the name "Logging Bag". It does not saw the logs to boards or add them to your keys.

Among other diagnostic messages, it will output lines suitable for inclusion in a UOAM map file showing which color logs were found at which tree.
Attachments
waitlib.lua
(3.57 KiB) Downloaded 71 times
lumberjacklib.lua
(8.35 KiB) Downloaded 66 times
lumberjacking.lua
(990 Bytes) Downloaded 77 times
User avatar
Wil
Legendary Scribe
Posts: 1128
Joined: Mon Dec 30, 2013 1:19 pm
Location: Seattle, WA, USA
Contact:

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wil »

And here's are the additional scripts needed to turn the above into a recall lumberjack which uses runebooks containing tree locations. Edit the following line in macrojacking.lua to set the name substring for which runebooks to use:

local runebooks = runesearchcontainer ({[8901]=true},"i"..UO.BackpackID,containers,items,"Redwood",nil)

You may also need to adjust the UO.Weight in "if UO.Weight > 510 then" based on what your character can carry.
Attachments
macrojacking.lua
(1.09 KiB) Downloaded 70 times
runebooklib.lua
(7.02 KiB) Downloaded 83 times
User avatar
Wil
Legendary Scribe
Posts: 1128
Joined: Mon Dec 30, 2013 1:19 pm
Location: Seattle, WA, USA
Contact:

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wil »

Also you have to be directly "above" each tree, i.e. northwest.
Reskal
Elder Scribe
Posts: 108
Joined: Fri Aug 29, 2008 10:54 am

Re: [EasyUO] Auto Lumberjacking an area.

Post by Reskal »

Wil wrote:
Thu Dec 01, 2022 12:51 pm
Here's an OpenEUO logging script if you want it. It will log in a straight line north or south depending on what you set the variable to at the top of lumberjacking.lua. It has some ability to navigate around obstacles in the path to the next tree.

You will need either a bag of resources or a bag of holding containing a normal bag you've engraved with the name "Logging Bag". It does not saw the logs to boards or add them to your keys.

Among other diagnostic messages, it will output lines suitable for inclusion in a UOAM map file showing which color logs were found at which tree.
Thanks for the scripts, i will try to get it running, but what is a bag of resources ? I did not find it by googling. But buying a large bag of holding seems the dream for getting resources of all sorts.

Edit: got a large bag of holding actually. :D
But you posted 3 macros, how can i use them all together in OpenEUO ?

I tried to open the lumberjacking.lua but got the error: $new1:8: could not open file

Can you tell me please exactly how to handle these 3 files to get the macro running ?
User avatar
Wil
Legendary Scribe
Posts: 1128
Joined: Mon Dec 30, 2013 1:19 pm
Location: Seattle, WA, USA
Contact:

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wil »

Put all three files in the OpenEUO directory. Open lumberjacking.lua in OpenEUO. Run it.

A Bag of Resources is a BOD reward. It has a fixed weight of 100 stone and holds resource stacks (such as logs) for no additional weight. If you check vendors.uoex.net, 10 folks have them listed for sale right now.
Reskal
Elder Scribe
Posts: 108
Joined: Fri Aug 29, 2008 10:54 am

Re: [EasyUO] Auto Lumberjacking an area.

Post by Reskal »

@Wil: thanks for the info and the explanation of the bag of resources.
I did not manage to get the macro running, i did as you said, or at least i hope. Here is a picture linked with the OpenEUO-directory with the files inside, is it right that way ?

https://imgur.com/dDU9eX5

And this is what openEUO prints out, when i try to start the macro:

"...kus\desktop\good old games\openeuo\lumberjacklib.lua:289: bag of resources not found"

I don't have such a bag yet, but a large bag of holding, what lines do i have to changes that the macro works ?
And what do i have to enter then, just "large bag of holding" ?
User avatar
Wil
Legendary Scribe
Posts: 1128
Joined: Mon Dec 30, 2013 1:19 pm
Location: Seattle, WA, USA
Contact:

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wil »

You will need either a bag of resources or a bag of holding containing a normal bag you've engraved with the name "Logging Bag".

So, engrave a normal bag with the words "Logging Bag" and then put the bag in your bag of holding.

See line 250 of lumberjacklib.lua if you want to change the code instead.
Reskal
Elder Scribe
Posts: 108
Joined: Fri Aug 29, 2008 10:54 am

Re: [EasyUO] Auto Lumberjacking an area.

Post by Reskal »

I engraved a bag with the name "Logging Bag" and put it into the large bag of holding.
I went to line 250 of lumberjacklib.lua and changed "Bag of Resources" to "Large Bag of Holding"

I started lumberjacking.lua but nothing happened, it seems it even did not start as i hit the play-key, then i changed line 250 back to "Bag of Resources" and tried starting lumberjacking.lua again, same result.
Using OpenEUO version 0.91 here.

Can it be that only "Bag of Resources" works ?


Edit: bought a bag of resources actually, but openEUO still prints out: \desktop\good old games\openeuo\lumberjacklib.lua:289: bag of resources not found

Edit2: the problem was , in the lumberjacklib.lua it was written "Bag of Resources", while the bag has a big O in the "of"
so the macro started this time, but the char keeps running north, spamming coordinates and messages like "failed to reach" and "no tree" and after a while the macro ends with the message: did not reach location.
User avatar
Wil
Legendary Scribe
Posts: 1128
Joined: Mon Dec 30, 2013 1:19 pm
Location: Seattle, WA, USA
Contact:

Re: [EasyUO] Auto Lumberjacking an area.

Post by Wil »

Reskal wrote:
Tue Dec 13, 2022 2:35 am
Edit2: the problem was , in the lumberjacklib.lua it was written "Bag of Resources", while the bag has a big O in the "of"
so the macro started this time, but the char keeps running north, spamming coordinates and messages like "failed to reach" and "no tree" and after a while the macro ends with the message: did not reach location.
Wil wrote:
Thu Dec 01, 2022 6:54 pm
Also you have to be directly "above" each tree, i.e. northwest.
That's directly UP on your screen, not up and to the left. As close to the tree as you can get, UP from it.

Also, you pasted lower-case "of" back to your copy of the file. The original had the big O.
Post Reply