ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Pearls on July 13, 2014, 10:04:05 AM
-
This past few weeks i have been learning to script a bit.
I'm working on a script that will craft woodland armor with user defined resists. In the long run i hope to convert this into a more allround armor/weapon crafter that evaluates user defined stats and decides to keep or trash the item. Preferably making use of TM's claw :)
But because i am a beginner i have obligated myself to not overcomplicate things, although i probably have been, and to make a simple version first. I already created a menu for this, but decided to skip it untill i got a more basic version working :) We'll pimp it out later haha :D
The version i'm posting is very very ALPHA or pre-alpha. There's already a lot of things i'd like to improve, but first i just want to get it working. So please bear that in mind with your feedback :D
At the moment i'm struggling a bit with sub PEARLS_setup_tool.
As you will see there is recursion happening in there whenever we need to craft tinker tools.
But if i put a display right after the recursion, then it will say that !item_type is N/A.
So i must be using the scope of namespaces wrong. Is it possible what i'm trying to do?
if !item_type notin !tool_types_tinkering && #FINDCNT < 3
{
set !tinkering_tools_needed 3 - #FINDCNT
gosub PEARLS_setup_tool tinkering JTL !tool_types_tinkering !tinkering_tools_needed 2 !resource_container 1 4
display !item_type
halt
}
I'm tired so i might come back & clean this post a bit :D
-
Actually I think I'm going to be crafting some specific Woodland armor in the near future, and look forward to checking this out...
;)
-
Ok it seems there is indeed something wrong with the recursive part :) I wrote a little test:
gosub testing tinkering
halt
sub testing
namespace push
namespace local testing
set !craft %1
if !craft = tinkering
{
gosub testing carpentry
display !craft
}
namespace clear
namespace pop
return
This will indeed display 'N/A'.
gosub testing tinkering
halt
sub testing
namespace push
namespace local testing
set !craft %1
if !craft = tinkering
{
gosub testing carpentry
display !craft
}
namespace pop
return
Now we've removed namespace clear from the sub and now we get display 'carpentry'. So it's overwriting the variable.
gosub testing tinkering
halt
sub testing
namespace push
namespace local testing , #sysTime , #random
set !craft %1
if !craft = tinkering
{
gosub testing carpentry
display !craft
}
namespace clear
namespace pop
return
Then i read something in a post about multidimensional arrays and came across the above solution: namespace local testing , #sysTime , #random
Now i get display 'tinkering' :) Success! Raise anchor! Forward! Euh... oh, that's different script... :P
-
Ok i've put up version alpha 1.1 just so i have a working backup stored here :)
If you want to try it just for giggles, the script currently does the following:
- makes sure it has 5 carpentry tools, if needed it will make sure it has 3 tinker tools too
- calculates weight and based on the item you are going to craft, the amount of resources it will need
- restocks resources in backpack if resource found is less then needed to craft 1 item, will restock to the max
- craft woodland gauntlets
- ton of other *bleep* behind the scenes :D
Todo before beta release:
- modify sub PEARLS_craft to use vars from sub PEARLS_craft_vars
- item evaluation
- keep/trash logic
-
I've been working hard at it and i can finally say "Boom here's Beta v1.0"!
I added a header to the script with an explanation on how to set everything up.
With this version you should be able to craft woodland armor pieces with specific resists and/or specific ranges of resist.
Would like to say thanks to whomever it was on test center that kindly donated 20k bark to me :)
I've used 6k in testing and have come up with 2 reasonably hard to get pieces.
Please test it out and give me some feedback on wether or not it's working for ya.
Once i get some positive feedback i'll submit this script for approval. Thanks :)
Question for the scripting gods of this forum:
gosub PEARLS_craft %carpentry_active_item
set %crafted_item_id #RESULT
if %crafted_item_id <> FALSE
Even if the crafting of the item was a failure, it will still go into this if statement and use the axe to chop.
What am i doing wrong here?
-
Ok i have burned 30k bark fragments with this and it seems to be working very well :) Submitting the script.