ScriptUO
Official ScriptUO EasyUO Scripts => Script Snippets => Topic started by: Paulonius on May 26, 2011, 08:36:27 AM
-
I have a series of crafting scripts that have a history of making the wrong item on occasion, derailing the script. I think this is a product of trying to optimize speed. This also caused issues clearing items out of the backpack since the items that were getting made were pretty random. For several months I have been trying to come up with a solution that will allow me to maintain speed and efficiency, but detect the random items to tell me when to reset the process. A secondary concern is getting the random stuff out of the backpack.
I finally came up with a solution today that involves taking an inventory of IDs of the items in the backpack at the start of the script and capturing them in a variable. I am using it as a check against items I make to confirm correct make, and to keep from throwing things away. It's pretty simple, but I figured I would share since it took me so long to figure it out.
Finditem * C_ , #BackpackID
Set %BackpackItemString BackpackContents:
For #Findindex 1 #FindCnt
{
Set %BackpackItemString %BackpackItemString , #FindID
Set %BackpackItemString %BackpackItemString , _
}
The second line inserts an underscore between IDs to avoid the extremely unlikely occurrence of an ID getting duplicated with parts of other IDs.
-
nice.
-
nice job
-
Cool idea, so simple yet so effective :)
You could also just do this to simplify three line further:
Finditem * C_ , #BackpackID
Set %BackpackItemString BackpackContents:
For #Findindex 1 #FindCnt
Set %BackpackItemString %BackpackItemString , #FindID , _
X
-
Thanks 12X, I was not sure how many additional phases your could append to it, so I did it with an extra line.
-
I did this exact same thing in my BOD filling script in order to clean the backpack out after each book is filled. I haven't released that version yet, as it only trashes the extra items right now and I want to make it unravel or smelt some of them first. This was the only option I could think of as well, although I also had to set a variable of item types that might be new and not want to be trashed (tongs, tinker tools, sewing kits, etc), as I add the IDs of these items to the initial inventory string so that I don't remove them from the backpack when I know they will be needed later.