ScriptUO

Scripting Resources & Utilities => Orion UO Client => Orion UO Scripts => Topic started by: altiric on May 20, 2022, 11:36:30 AM

Title: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 11:36:30 AM
Altiric's Amazing Arborist v0.1 (Works in Ter Mur)

A simple Lumberjack script that lets you harvest wood from your house. All you need is a secure container and an axe!

Load this one into your Scripts Tab, run Autostart, and you're up and running.

Finally been getting around to releasing my lumberjack script. Since there are a lot of people trying to learn more about scripting for Orion, I will be releasing this one in stages. Not to say my way is the best way, but it works lol. The first stage was just a matter of getting the bones together. Once i was able to find, walk to, and chop trees; I added support for the pack animal, then secure drop. I added a few messages to show where the script was in its operation, then sat back and let it run. Once i got the kinks worked out, i removed any extra bits i had and tossed a v0.1 on it!

Revisions:
 * v0.2
 *  -Added GUI
 *  -Moved action messages to gump
 *  -Updated chopping to make sure axe is held
 *  -Added counter for all items listed in harvestTypes(stored in registry)
 *  -Added gump display for harvestTypes
 * v0.1
 *  -Added ability to find trees, walk up to the closest one, and chop it
 *  -Added logs2boards
 *  -Added pack animal support
 *  -Added secure drop
 *  -Added action messages

v0.2 - I plan on adding a GUI and Counter system. ** in progress **
v0.3 - Will have rune book capability
v0.4 - Looking for suggestions :)
Title: Re: Building a Lumberjacking Script
Post by: Bulldog on May 20, 2022, 12:37:51 PM
Nice work again bud. I think in terms of suggestions you could easily adapt the same core principals to mining for example.
Title: Re: Building a Lumberjacking Script
Post by: The Ghost on May 20, 2022, 12:51:44 PM
MwInc have a simple lumber and Minijg script that was easy to set up.   Did the leg work :)    This can be a good base of compassion.
12X have a nice mining as well,  have not used it as much.

If not already include,  can you ensure that you cut log into board plx.:) this way you can carry more.    thx in advance

Orion:  I notice that you can scan an area and get 50 tree load up and just walk to all of them .

 

Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 12:53:14 PM
The mining script is a big part of why i did this. Ive been working on a full blown mining script, on and off... for about 4 months. Its still not done because i kept trying to throw in everything at once and it gets over complicated, then the bugs move in. This method gets you a working script right off the bat, then you can make it as pretty as you want bit by bit.

Post Merge: May 20, 2022, 12:58:32 PM
MwInc have a simple lumber and Minijg script that was easy to set up.   Did the leg work :)    This can be a good base of compassion.
12X have a nice mining as well,  have not used it as much.

If not already include,  can you ensure that you cut log into board plx.:) this way you can carry more.    thx in advance

Orion:  I notice that you can scan an area and get 50 tree load up and just walk to all of them .

12X has the best mining script out there as far as im concerned. Ive used his structure in several of my own scripts, its just got a nice flow to it and is well designed.

Logs2Boards is in there.

That's how this one works! after getting the array full of trees, it uses some lovely JavaScript array manipulation to compare with the choppedTrees array and move the trees around in the array so you always walk to the closest one too you.
Title: Re: Building a Lumberjacking Script
Post by: The Ghost on May 20, 2022, 01:00:59 PM
I try that one , include evething on my list and nothing was working.  so now I build the basic, run  some good test run and add sub as needed.    I do have a good collection of version, something up to 26  heheood look on the mining
Title: Version 0.2 - Gumps and Counters!
Post by: altiric on May 20, 2022, 03:16:03 PM
Coming along quickly :)
Title: Re: Building a Lumberjacking Script
Post by: Crisis on May 20, 2022, 05:05:21 PM
I like it so far, can't wait for runebook usage. Currently I it has a difficult time removing boards. I get a lot of have to wait messages and if there is more than one kind of board in the pack, it won't remove the plain ones. I have checked to make sure the ids and stuff are the same. It also gets stuck on a tree when it says you cannot use an axe on that.

I added this in to try and change the can't use an axe but no avail
Code: [Select]
// Language, Adjust these to suit your clients language
    var msg1 = "There's not enough wood";
    var msg2 = "You cannot see";
    var msg3 = "That is too far";
    var msg4 = "You chop some";
    var msg5 = "you can't use an";
Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 05:47:18 PM
I like it so far, can't wait for runebook usage. Currently I it has a difficult time removing boards. I get a lot of have to wait messages and if there is more than one kind of board in the pack, it won't remove the plain ones. I have checked to make sure the ids and stuff are the same. It also gets stuck on a tree when it says you cannot use an axe on that.

I added this in to try and change the can't use an axe but no avail
Code: [Select]
// Language, Adjust these to suit your clients language
    var msg1 = "There's not enough wood";
    var msg2 = "You cannot see";
    var msg3 = "That is too far";
    var msg4 = "You chop some";
    var msg5 = "you can't use an";

Woohoo! Feedback, thank you!
The script uses the delay settings from OrionAssitant->Main Tab->Options 1, Sounds like you need to increase your moveitemdelay/useitemdelay to fix those messages. No idea how it managed targeting something outside of a tree for the can't use that message but i'll pop that in there for v0.3! As for the not moving plain boards, that'll take some looking.

**I had to change my waitdelays from the default 600 to 1200 to smooth things out
Title: Re: Building a Lumberjacking Script
Post by: The Ghost on May 20, 2022, 05:59:52 PM
He  Crisis,  nice to see back.  How you been

here what I have mine setup in option1.   I still see the Msg you must wait, but I swing that axe fast.   sure look fast :)

Testing ver 0.2   
I set for bank,  I change my mind and want to do house,  I stop and restard build, now Im not getting the option to set bag or packhorse.   
Must be C18 code,  :) 

and I just crash trying to manually unload

update:
The crash since to have fix my issue.  I was able to reset my drop bag.
 

Post Merge: May 20, 2022, 06:09:55 PM
Same as Crisis 
 it wont unload my regular board and now I'm overweight.

on a good note:
It cool,  Start at my house, run out chop tree, go back in the house to unload and go back out. 

 Update 3:
 it will unload the regualr board.  it just take alot of time.  I keopt receiving msg : THAT IS TOO FAR.   After a while, like 27 time items get unload ( 90% of the time)
Use ites dealy @ 1200 and Move itemdelays delays @1200
 
Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 06:16:24 PM
Use item Delay adds a delay after using an object. If its trying to swing too fast, this needs to be increased.
Move Item Delay adds a delay after moving an item, before continuing to the next action. The way it's worked into the loops, If you get pickup message errors, this will need to be increased.

I can see how this is becoming an issue but i wanted to keep the delays consistent with the general setup of the OrionAssistant, which also cuts down on the editing required within the script itself. I'll see if i can work something in with the built in CheckLag function to compensate.

Using a bank as a secure would take a little fiddling with the Setup, I'll be adding that feature with with the runebooks in the next update.
I'll also be adding an options menu to the gump to reset secure/pack animal. Right now they are stored in your Lists->Objects Tab and can be edited/deleted from there. (Currently, If the script cannot find the set secure container, or pack animal upon start, it will ask for new targets to be selected).
Title: Re: Building a Lumberjacking Script
Post by: The Ghost on May 20, 2022, 06:26:05 PM
Can you post a pic of your option 1, so I have a base line.  plx,   the more I change number, the worse  it get.     Now my frame skipping :)   before you ask, ping at 29ms.   nice now can't move  heheheh   
stop script and now I can move.  I need a beer.

Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 06:33:04 PM
I'll work on a quick OrionUO Setup guide this evening, ive run into several people having issues getting it running like it can.
This is a copy of my Options 1 Tab setup, It sounds like you're having framerate issues though. Although the client can handle larger fps, they are completely wasted on UO and soak up extra resources it does not need to.
Title: Re: Building a Lumberjacking Script
Post by: The Ghost on May 20, 2022, 06:45:34 PM
Thx for the pic,  I'm close to your.  Now I know what nodebug do.  want to get that text out for day :)     after 15min of running script,  game slow down it like I'm frozen.  I stop  the script, now I can move.   Crisis  do you have the same issue. 
Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 06:51:59 PM
Ive run into this issue with a few Gump's now. Just ran into the same issue of bogging down after about 45 minutes each time, v0.1 ran for over 3 hours without a hiccup. Figured it was too short of a delay in one of the while statements, but kept adding to the time and it did not resolve it. I did notice i had it Updating the gump twice on every axe stroke, once to get the updated counts, once to update the Action status. 20 minutes into a fresh run and have not seen any issues starting yet.
Title: Re: Building a Lumberjacking Script
Post by: Crisis on May 20, 2022, 07:34:34 PM
Increasing the use item delay helped but it still gets stuck trying to chop a tree saying "you can't chop that with an axe" and when it unloaded all of the lumber and stuff, it also unloaded my runebooks lol.

Don't get me wrong, this is awesome and I cannot wait till the bugs are worked out. I really need to read up on javascript so I can get better. Thank you for sharing and working on this!

@The Ghost I am doing ok. Still dealing with health issues which takes away from gaming but I am hanging in there!
Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 07:40:06 PM
Increasing the use item delay helped but it still gets stuck trying to chop a tree saying "you can't chop that with an axe" and when it unloaded all of the lumber and stuff, it also unloaded my runebooks lol.

Don't get me wrong, this is awesome and I cannot wait till the bugs are worked out. I really need to read up on javascript so I can get better. Thank you for sharing and working on this!

Ive really gotta figure out how to reproduce some of these lol, The only items it should know how to move are those listed in harvetTypes array. I'll try getting onto a free shard to test some of this out, might help just mixing things up so i can get a better sample size.
Title: Re: Building a Lumberjacking Script
Post by: The Ghost on May 20, 2022, 07:48:00 PM
I tested on OSI, 
Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 07:50:46 PM
I could be wrong, but i believe you two are having different issues (aside from the timing delays). Regardless, i think a different shard will give me more data to work with, more data, better ability to crunch other related bugs :)
Title: Re: Building a Lumberjacking Script
Post by: Crisis on May 20, 2022, 08:04:54 PM
The tree that cannot be chopped shows as a pear tree. Orion sees it as a tree but the game does not let you use an axe on it. It doesn't seem to ignore that when the journal shows "you can't use an axe on that" I am on UO Heritage which uses TRUEUO, OSI copy. Most things including the item numbers are the same.

Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 08:08:49 PM
Well... had not considered that one. Just adding the error message to the journal should be enough to get those out of the way after the first chop though. They'll automatically go into the chopped array after an attempt. But they will be tried again after it resets the trees. I'll have to keep that one in mind.
Title: Re: Building a Lumberjacking Script
Post by: Crisis on May 20, 2022, 09:54:06 PM
I have it moving on from the pear tree now

I added msg5 and changed the lowercase y to an uppercase:
Code: [Select]
// Language, Adjust these to suit your clients language
    var msg1 = "There's not enough wood";
    var msg2 = "You cannot see";
    var msg3 = "That is too far";
    var msg4 = "You chop some";
    var msg5 = "You can't use an axe";

and then added msg4 and msg5 here since it stopped at msg3:
Code: [Select]
while(!Orion.InJournal(msg1+'|'+msg2+'|'+msg3+'|'+msg4+'|'+msg5)){
I also added 0x3199 to this line since it wasn't putting this into the secure container:
Code: [Select]
harvest : '0x3191|0x2F5F|0x318F|0x3190|0x5738|0x3199' // fungi, switch, bark, plant, shards 
It is still slowly emptying all of my runebooks from my backpack a couple at a time each time it unloads. It also got stuck with the pack completely empty. It was trying to use the axe on something but as you can see in the picture, backpack is empty. This was immediately after unloading everything.

Post Merge: May 20, 2022, 10:09:46 PM
After updating the line with 0x3199 it didn't seem to put runebooks and BOD books into the secure container but it still get stuck trying to use the axe on something after emptying the lumber and stuff from the backpack.
Title: Re: Building a Lumberjacking Script
Post by: altiric on May 20, 2022, 10:11:50 PM
That's how i would have added it in!
I knew about this glitch, did not realize it could be an issue like this. After it unloads the pack, it goes back to trying to chop the last targeted tree as if it were still standing beside it. Typically, when it fails it should look for the next tree. Im thinking another journal scan..

var msg5 = 'cannot be seen'; added to the journal check
This should make the script pull the next tree out of the array and continue as normal. *hopefully*
I'll make sure all this gets ironed out in v0.3, appreciate the help finding these things!

I also realized why it may be emptying your pack... Are you using a pack animal? In the secureDrop function
Code: [Select]
    if(animal){
        Orion.RequestContextMenu(animal.Serial());
        Orion.WaitContextMenuID(animal.Serial(), 508);
        Orion.WaitForContainerGump();
        Orion.Wait('useitemdelay');
        Orion.FindTypeEx(any, any, lastcontainer).forEach(function(item){
            Orion.MoveItem(item.Serial(), 0, secure.serial);
            Orion.Wait('moveitemdelay');
        });
    }

Orion.FindTypeEx(any, any, lastcontainer)
should be
Orion.FindTypeEx(any, any, animal.Serial())

im thinking lastcontainer is somehow changing to your packpack insteal of the animals pack, this should be the fix.

**Edit: Never mind, pack animals pack Serial is different than the animals, i'll get back to you by morrning, i know there is a command for this in Orion lol, i cheated and skipped this step by using lastcontainer...
Title: Re: Building a Lumberjacking Script
Post by: Crisis on May 21, 2022, 05:27:05 AM
I am not using any pack animals, just my character. Once I made the adjustments to the line with Harvest, my pack no longer gets emptied. I ran 10 minutes before I hit the issue where it kept saying "target cannot be seen". I am liking it though, keep up the awesome job!

Post Merge: May 21, 2022, 07:40:57 AM
I think I have found out what is causing it to stall at "target cannot be seen". It seems like that is happening when my character was chopping wood more than 50 steps from my secure. Like it could not find the tree to go back to it.
Title: Re: Building a Lumberjacking Script
Post by: Crisis on May 29, 2022, 12:32:24 PM
Any updates or is this on the back burner for the time being? No worries if it is, was just curious.  :D
Title: Re: Building a Lumberjacking Script
Post by: altiric on May 29, 2022, 12:54:40 PM
Its very close to making it on my priority list! Just got a couple things to finish off, should be able to focus on this one beginning next week. Already have most of the issues you and Gaderain were able to find solved.
Title: Re: Building a Lumberjacking Script
Post by: Gaderian on May 29, 2022, 04:06:53 PM
Its very close to making it on my priority list! Just got a couple things to finish off, should be able to focus on this one beginning next week. Already have most of the issues you and Gaderain were able to find solved.

While I have been keeping up on reading these Orion posts, not sure I have added much to any discussions. ;)

Gaderian
Title: Re: Building a Lumberjacking Script
Post by: rex on June 13, 2022, 10:42:38 PM
Спасибо, за работу, ты крутой
Title: Re: Building a Lumberjacking Script
Post by: nyre74 on July 05, 2022, 12:23:41 PM
Thank You for sharing   I can not wait till you update it more   

Post Merge: July 06, 2022, 08:11:34 AM
MwInc have a simple lumber and Minijg script that was easy to set up.   Did the leg work :)    This can be a good base of compassion.
12X have a nice mining as well,  have not used it as much.

If not already include,  can you ensure that you cut log into board plx.:) this way you can carry more.    thx in advance

Orion:  I notice that you can scan an area and get 50 tree load up and just walk to all of them .

Where can I find this Mining script by Mw1nc 

Thank You
Title: Re: Building a Lumberjacking Script
Post by: dinodan1001 on September 08, 2022, 04:19:17 PM
Been trying to figure out how to script for a while now. Thanks for putting this together!
Title: Re: Building a Lumberjacking Script
Post by: Soughat on May 26, 2023, 01:49:33 AM
I am testing
Title: Re: Building a Lumberjacking Script
Post by: Crisis on May 26, 2023, 02:08:50 PM
I am testing

If you actually want to test it, you may want to post a good introduction in the new member section so you can actually see and download the script.
Title: Re: Building a Lumberjacking Script
Post by: gruntman on November 05, 2023, 07:08:12 AM
Its very close to making it on my priority list! Just got a couple things to finish off, should be able to focus on this one beginning next week. Already have most of the issues you and Gaderain were able to find solved.

Howdy Howdy - I seem to constantly fins those trees you cannot chop. Has this script made its way closer to being adjusted? I have tried but fail everytime lol
Title: Re: Building a Lumberjacking Script
Post by: Figga on November 05, 2023, 01:11:30 PM
I am not smart enough to figure out how to access the scripts on this site so I resorted to name calling.