Author Topic: Pearls' Crafting Assistant  (Read 2995 times)

0 Members and 2 Guests are viewing this topic.

Offline PearlsTopic starter

  • Hero Member
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Pearls' Crafting Assistant
« on: July 13, 2014, 10:04:05 AM »
0
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?

Code: [Select]
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

There are 3 attachment(s) in this post. You must register and post an acceptable introduction to download
Pearls' Crafting Assistant - Alpha v1.0.txt
Pearls' Crafting Assistant - Alpha v1.1.txt
Pearls' Crafting Assistant - Beta v1.0.txt
« Last Edit: July 18, 2014, 08:03:23 AM by Pearls »
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "

Offline Grandewd

  • Full Member
  • ***
  • Posts: 239
  • Activity:
    0%
  • Reputation Power: 3
  • Grandewd has no influence.
  • Respect: +24
  • Referrals: 0
    • View Profile
Re: Pearls' Crafting Assistant
« Reply #1 on: July 14, 2014, 11:29:26 PM »
0
Actually I think I'm going to be crafting some specific Woodland armor in the near future, and look forward to checking this out...
 ;)

Offline PearlsTopic starter

  • Hero Member
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Re: Pearls' Crafting Assistant
« Reply #2 on: July 15, 2014, 08:18:05 AM »
0
Ok it seems there is indeed something wrong with the recursive part :) I wrote a little test:

Code: [Select]
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'.

Code: [Select]
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.

Code: [Select]
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
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "

Offline PearlsTopic starter

  • Hero Member
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Re: Pearls' Crafting Assistant
« Reply #3 on: July 17, 2014, 07:58:24 AM »
0
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
« Last Edit: July 17, 2014, 08:13:35 AM by Pearls »
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "

Offline PearlsTopic starter

  • Hero Member
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Re: Pearls' Crafting Assistant
« Reply #4 on: July 18, 2014, 08:12:37 AM »
0
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:

Code: [Select]
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?
« Last Edit: July 18, 2014, 08:14:22 AM by Pearls »
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "

Offline PearlsTopic starter

  • Hero Member
  • *
  • Posts: 557
  • Activity:
    0%
  • Reputation Power: 13
  • Pearls barely matters.Pearls barely matters.
  • Respect: +65
  • Referrals: 1
    • View Profile
Re: Pearls' Crafting Assistant
« Reply #5 on: July 20, 2014, 12:19:43 AM »
0
Ok i have burned 30k bark fragments with this and it seems to be working very well :) Submitting the script.
XII : "My happiness as a married man is directly related to the amount of sex I have which, in turn, requires that I pretend I like these movies every now and then and that it really doesn't bother me when she tells me about her problems but doesn't want me to give her a solution ;) "

Tags: