[Orion] Lumberjacking with multiple points and so on

If you make a Client-side script you can publish it here for other players to use
Post Reply
Meliofaro
Novice Scribe
Posts: 6
Joined: Fri Aug 16, 2019 12:43 pm

[Orion] Lumberjacking with multiple points and so on

Post by Meliofaro »

So there is script for Lumberjacking, it's using keys to pack wood. You have to change your keys ID in config array (use _info), and coords of spots where you want to make some chop-chop =)

Code: Select all

var config = {
	"maxWeight"  		: 390, 			//Max Weight to cut wood 
	"weightToPack"      : 300, 			//Weight to use Woodworker's Keys 
	"axe"    			: "0x0F43", 	//Axe type
	"logs"				: "0x1BDD",		//Log type
	"board" 			: "0x1BD7", 	//Boards type	
	"keys"              : "0x40779367",	//Woodworkers keys ID !!!!!!! EDIT !!!!!!!!!!
	"addBoardButton"    : 60023, 		//Last button ID in keys gump
	"treesSearchOffset" : 10,			//Radius of tree search
	"toKeys"            : [0x318F,0x2F5F,0x3190,0x3191]
};

var points = { // !!! EDIT !!!
	1 : {"x" : 1773, "y" : 2809, "z" : 0},
	2 : {"x" : 1746, "y" : 2808, "z" : 0},
	//You can add more ^_^
}; //Trinsic

function start()
{	
	while(!Player.Dead())
	{
		for(point in points)
		{
			Orion.WalkTo(points[point]['x'],points[point]['y'],points[point]['z'],0);			
			var splited = getTreeTiles(config['treesSearchOffset']);				
			if(splited)
			{
				var cnt=0;
		    	for(var i = 0; i<=splited.length-3; i+=3)
		    	{        
		    		cnt++;
			        var x = splited[i];
			        var y = splited[i+1];
			        var z = splited[i+2];
						
					Orion.Print('0x0035','Point #'+point+' Tree #'+cnt+'/'+splited.length/3);		
					Orion.Print('0x0099','X = '+x+' Y = '+y+' Z = '+z);
					Orion.WalkTo(x,y,z,1);			
					chop(x,y,z);			
				}
			}
		}
		
	}
}


function chop(x,y,z)
{
	//Orion.Print("[i] Chopping at  X+"+x+" Y+"+y);
	while(!Player.Dead())
	{
    	if(Player.Weight() >= config['maxWeight'] )
    	{
    		cut();
    	}

    	if(Orion.ValidateTargetTile('tree', x, y))
    	{    		
    		if(Orion.HaveTarget())
    			Orion.CancelWaitTarget();
    		
    		Orion.UseType(config['axe']);	    		
			Orion.WaitTargetTile('tree', x, y, z);	    			    		
    		var result = Orion.WaitJournal("You hack at|You put|not enough|is too far|no line of|seen", Orion.Now(), (Orion.Now() + 7000), 'me|sys');	    	
    		if(result && result.FindTextID()==2)
    		{
    			Orion.Print("[i] Tile depleted");
    			Orion.Wait(300);
    			break;
    		}	    		
    	}
	}//Main Loop
}

function cut()
{
	var logs = Orion.FindType(config['logs'],-1, 'backpack');
	if(logs && logs.length > 0)	
	{
		logs.forEach(function(log){
			Orion.Wait('moveitemdelay');
			Orion.UseType(config['axe']);
			Orion.WaitTargetObject(log);
			Orion.Wait('moveitemdelay');
		});
		
		if(Player.Weight() >= config['weightToPack'])		
		{
			Orion.Wait('moveitemdelay');
			PackWood();
		}
	}
	
}

function PackWood()
{
	var _ingHook = Orion.CreateGumpHook(config['addBoardButton']);
	var _keys = Orion.FindObject(config['keys']);
	if(_keys)
	{
		Orion.UseObject(config['keys']);
		if(Orion.WaitForGump(1000))
		{								
			var _ingotGump = Orion.GetLastGump();
			_ingotGump.Select(_ingHook);						
			var _orePack = Orion.FindType(config['board'],-1,'backpack');
			if(_orePack && _orePack.length > 0)
			{
				config['toKeys'].forEach(function(item){					
					var misc = Orion.FindType(item);
					if(misc && misc.length>0)
					{
						Orion.Wait(500);										
						Orion.CancelWaitTarget();					
						Orion.Wait(100);
						Orion.TargetObject(misc[0]);
						Orion.Wait(500);					
					}
				});

				_orePack.forEach(function(serial){
					Orion.Wait(500);										
					Orion.CancelWaitTarget();					
					Orion.Wait(100);
					Orion.TargetObject(serial);
					Orion.Wait(500);				
				});				
				Orion.Wait(500);
			}									
		}
		Orion.Wait(1000);
		Orion.UseObject(config['keys']);
		Orion.WaitForGump(1000);
		var _ingotGumpClose = Orion.GetLastGump();
			_ingotGumpClose.Select(Orion.CreateGumpHook(0));				
		Orion.Wait(1000);

		if (Orion.HaveTarget())				
		    Orion.CancelTarget();				
	}
}


function getTreeTiles(offset)
{
    var validTiles=[];
    var cntValid = 0;
    for (var x = -offset; x <= offset; x++)
    {
        for (var y = -offset; y <= offset; y++)
        {
            if(Orion.ValidateTargetTileRelative('tree',x,y))
            {
                //Orion.Print("Valid tile! X="+x+" Y="+y);
                validTiles.push(Player.X()+x,Player.Y()+y,0);
                cntValid++;
            }
        }
    }

	    

    Orion.Print("[getTreeTiles]Trees found = "+cntValid);
    if(cntValid>0)
        return validTiles;
    else
        return false;    
    
}

Matico
Passer by
Posts: 1
Joined: Sun Mar 14, 2021 11:25 am

Re: [Orion] Lumberjacking with multiple points and so on

Post by Matico »

Hello!

Thanks! That is an amazing scritpt!


How do I equip a new axe after it breaks?
davethemage
Grandmaster Scribe
Posts: 89
Joined: Sun Aug 09, 2020 2:13 pm

Re: [Orion] Lumberjacking with multiple points and so on

Post by davethemage »

Awesome script! been looking for something like this.

Addendum: been using this now for a bit and loving it!! great and nicely handles weight issues other scripts i've used couldn't handle. Easily beats any steam/easyuo script i've used in the past. Thanks a bunch for posting!!

As for axes I make a bunch of hachets and either throw them in exex and pull them out (1 hatchet with thousands of uses) or if you have a tool house you can dump them in there.. same effect.
Last edited by davethemage on Sat Mar 27, 2021 11:45 am, edited 2 times in total.
User avatar
Wil
Legendary Scribe
Posts: 1128
Joined: Mon Dec 30, 2013 1:19 pm
Location: Seattle, WA, USA
Contact:

Re: [Orion] Lumberjacking with multiple points and so on

Post by Wil »

Pro tip: If you dump all the trash looted axes into the tool house they become hatchet uses.
dropdeadfred
Passer by
Posts: 3
Joined: Sat Nov 13, 2010 1:19 pm

Re: [Orion] Lumberjacking with multiple points and so on

Post by dropdeadfred »

I started using this script today, great script but I have one minor problem that I can not figure out. The gump for my wood working keys will not close after packing, how can I fix this?
davethemage
Grandmaster Scribe
Posts: 89
Joined: Sun Aug 09, 2020 2:13 pm

Re: [Orion] Lumberjacking with multiple points and so on

Post by davethemage »

dropdeadfred wrote:
Sat Dec 04, 2021 10:25 pm
I started using this script today, great script but I have one minor problem that I can not figure out. The gump for my wood working keys will not close after packing, how can I fix this?
Just seen your post, but something like this "should" close your keys:

var gump1 = Orion.GetGump('last');
gump1.Select(Orion.CreateGumpHook(0));
Orion.Wait(100);


creategumphook(0) is the same as closing.
IGN: Edwin Roach
Zanzi
Elder Scribe
Posts: 139
Joined: Mon Mar 08, 2021 12:20 am

Re: [Orion] Lumberjacking with multiple points and so on

Post by Zanzi »

davethemage wrote:
Sun Mar 13, 2022 1:57 pm
dropdeadfred wrote:
Sat Dec 04, 2021 10:25 pm

Just seen your post, but something like this "should" close your keys:

var gump1 = Orion.GetGump('last');
gump1.Select(Orion.CreateGumpHook(0));
Orion.Wait(100);


creategumphook(0) is the same as closing.

where do i put that in the script for it to work?
davethemage
Grandmaster Scribe
Posts: 89
Joined: Sun Aug 09, 2020 2:13 pm

Re: [Orion] Lumberjacking with multiple points and so on

Post by davethemage »

Zanzi wrote:
Tue Mar 15, 2022 5:25 pm
davethemage wrote:
Sun Mar 13, 2022 1:57 pm
dropdeadfred wrote:
Sat Dec 04, 2021 10:25 pm

Just seen your post, but something like this "should" close your keys:

var gump1 = Orion.GetGump('last');
gump1.Select(Orion.CreateGumpHook(0));
Orion.Wait(100);


creategumphook(0) is the same as closing.

where do i put that in the script for it to work?
replace this in the PackWood function:

Orion.UseObject(config['keys']);
Orion.WaitForGump(1000);
var _ingotGumpClose = Orion.GetLastGump();
_ingotGumpClose.Select(Orion.CreateGumpHook(0));

with that. It's basically the same thing except you are creating a new variable. (i've found sometimes that Orion has problems keeping track of them, hence why it's good to make a new one when you want to do something different ) of course the only caveat is if you get or have another gump pop up (like a pm or something) it will switch to that (get last gump)and close it on you.
I personally just use the program as it's written . Just make sure that config[keys] is set to your current wood key.
IGN: Edwin Roach
Post Reply