Crafting Script v3.8 - Updated 2/26/2015

@sixth: separate crafting shop (fixed bug that Dungeonmind found) - https://www.dropbox.com/s/bwvg1arn2kdy5js/no%20shop%20crafters.txt

The normal crafting shop fixes: https://www.dropbox.com/s/5vic3mihvb4i06h/Crafting%20Shop%20Craft%20%26%20Decompile.txt

both have the sorting turned off after the window first starts.. will update the demo project shortly.

Will update the demo when I have more of the minor requests finished. Till then, here's the change to the List window in the main script to make it work turning the sort list off.

Spoiler
change the Recipe_List_Window's ini method to include the @sort_list = true

#---------------------------------------------------------------------------- # ● upgraded method: initialize #---------------------------------------------------------------------------- def initialize(x, y) super(x, y) self.opacity = Venka::Crafting::Window_Opacity self.back_opacity = Venka::Crafting::Window_BGOpacity @craft_type = nil @recipes = $craft.known_recipes @sort_list = true endand then change the make_command_list method to look like so:
Code:
  #----------------------------------------------------------------------------  # ● upgraded method: make_command_list  #----------------------------------------------------------------------------  def make_command_list    if @recipes      @items = []      # Prep to sort the list by required crafting level      @recipes.each do |recipe_id|        next unless $recipe[recipe_id].recipe_type == @craft_type        item = $recipe[recipe_id]        @items << item        # Determine if sorted by level or alphabet and then sort the list        if Venka::Crafting::Sort_Type == :level && @sort_list          @items.sort!{|a, b| a.req_level <=> b.req_level}        elsif Venka::Crafting::Sort_Type == :alphabet  && @sort_list          @items.sort!{|a, b| a.crafted_item.name <=> b.crafted_item.name}        end      end      @sort_list = false      @items.each do |item|        add_command(item.crafted_item, item.recipe_id.to_s.to_sym, enabled?(item))      end    end  end
Thanks a lot for the standalone craft shop!
The sorting thing did not work, however.

In the shop, we can not gain XP, so the sorting thing issue I described won't happen there anyway.

But on the main crafting scene it now turns off the sorting completely (the recipes will show up in their ID's order) after we do the first item. Note that it happens only after we make the first item.

If we have our sorting on the alphabet method, when we level up after this, the same thing happens, just like what I described in my fist post detailing this little issue.

Ok, removed that last "bug" I found. Sometimes I amaze myself with the lack of reading things properly, sorry.
no worries.. I tried getting some script done today.. spent about 4 hours on this crafting script.. and got nothing done. Apparently my brain is on vacation. I'll try to fix more tomorrow. I did get the display names working for you Weedopia.
no worries.. I tried getting some script done today.. spent about 4 hours on this crafting script.. and got nothing done. Apparently my brain is on vacation. I'll try to fix more tomorrow. I did get the display names working for you Weedopia.
That's awesome I can't wait to use the (Name) thing to foward my game dev 😀  
Erm this could be very very stupid of me, but I seem to have problems using the Shop Keep addon, I have:

recipes = 1
shop_recipes("Weapon Smithing", recipes)

as a script in the event, but it doesn't work.

EDIT:

Mmm I think I get how it works now, but is there a way to keep them from crafting inside the shop and only able to decompile? 

Uhm I'm getting this error now:

746390.png


I'm doing:

recipes = 1

shop_recipes("Weapon Smithing", recipes)

Shop Processing: Item

EDIT:

Eh I missed the [ and ] around the 1.

However doing that I got another error.

7aab39.png


I also must mention that I am using Sixth's edits for Vlues random equipment
Venka, I'm quite new to following this thread, and I managed to read the first half-dozen pages, so I don't know if anyone else suggested this, but....


Am I able to make a recipe for an item that would take one or more of the player's stats as a component? Such as using HP/MP/TP/whatever? I'd like a way to tie certain craftable items to an amount of, say, MP; some might be at a fixed amount per recipe, some might be at a percentage of maximum. This would in some way limit how many items are craftable within a time-frame (a "day"), without using potions or sleeping for a night.

Spoiler
In the one game idea I have, something of an "anti-rpg" occuring in two or three villages; the party will be made of the local craftsmen, and the adventure is in traveling, trading, and learning crafting (minor monster encounters, but no boss battles), so that the townies can find resources and replenish their stores of products. So with the adventuring party being "classes" like baker, barkeep, innkeeper, tailor, woodsman, whatever else fits, my idea is to have the townies crafting equipment in competition with the "big town" in the story.
It is also partly about the townies being the "real" heroes, where the more "traditional" adventurers come traipsing through town, buying up the new merchandise, selling their used armor and weapons, et cetera.... So the decompiling items into component parts is of interest.


Of course, if linking to player's stats and parameters (as a consumable component of a recipe) isn't so easy, I can manually Event-code an NPC who is able to extract character HP and MP into new items "HP pots" and "MP pots" for an alternate way, to a minimum of one of each stat. (Although that's one middle-man step I'd like to remove from the process.)


I'm hoping that using character HP and MP could be a neat way to "tweak" or "improve" the crafting of items, to possibly create enchanted and/or rare versions of the equipment, if possible. If not, just tell me so, and I'll try for a different story idea.
@Onomotopoeia: the script doesn't currently support the use of stats to craft, but that is a neat concept 😉 I'll see if I can get something going for it, but it'll be down the road a bit as I'm trying to get the newest bugs worked out from the last update.

@Bloodmorphed: I never thought of leaving the recipes blank and only using the decomp option. I'll patch that up so you can do only one or the other (or both).
EDIT:

Eh I missed the [ and ] around the 1.

However doing that I got another error.

7aab39.png


I also must mention that I am using Sixth's edits for Vlues random equipment
I am unable to get that error. What is your recipe setup for that recipe you are trying for the craft shop?

And what is line 471 in your script? 

I modified quite a lot in that addon too, so that line is not the same for me. I think I know what that line says, but I want to make sure.

You are calling the shop with the shop event command, so you are using the shop version, not the "no-shop" version like me. But I will try to track that down, if you tell me the above mentioned details.

You did all 3 edits I mentioned in that post of mine, right? Just to be sure. 
Every single one of your edits above. Uhm, I'll give you more details later as I have just got home and nothing is opened.

Also venka, that would be helpful. Thank you

Recipe:

Spoiler
Recipes[1] = {     # Loaf of Bread    :recipe_type  => 2,          # Cooking Recipe    :auto_learn   => true,       # Auto-learn this recipe when level is reached    :req_level    => 1,          # Level required to use this recipe    :shop_fee     => 20,         # Fee charged if crafted at a shop    :craft_time   => 200,        # Time it takes to make the item    :earned_exp   => 3,          # Exp gained on success    :crafted_item => [:w1, 1],  # Makes 2x Loaf of Bread    :failed_item  => [:w1, 1],  # 1x Piece of Charcoal if failed attempt    😛re_failed   => [:w1, 1],  # Failed item if crafted before timer    :ingredients  => [ # 2x Eggs,  1x Flour,   1x Fresh Milk, 5 Gold                     [:i2, 1], [:i11, 1], [:g1],    ]} # <- DO NOT REMOVE
Line:

@required += (@required * @inflation).round unless ingredient.toolI feel like I have to mention: I'm using 27 other scripts. I don't think they are interfering with it, as I don't think any of them edit shop stuff. I have the Questing script, and then a lot of Yanfly's engine in there. I can send you a copy of my Script file... would that work?
Managed to reproduce the bug.

It comes from adding gold as an ingredient to recipes.

It will only result in an error if you are calling that recipe in a craft shop scene.

Apparently, it can not identify if gold is a tool or not, because it is not an actual item and can not check notetags on it, obviously.

I believe this is Venka's table. I am fairly good in windows/scene modifications, some compatibility solving, but not in this.

There should be an "exclude gold as a tool" thingy somewhere in 'determine_required_ingredients(ingredient, i)' definition.

But I have no idea how to translate that to ruby code, unfortunately. Venka might be able to fix it, though.

For a workaround, just drop the gold requirement from your recipe, and the error goes away. There is a crafting fee in the craft shop anyway.
Eh, I'll just wait until he patches the shop script. I only want the decompiling part anyways not the craft-in-shop.
yeah I found that issue yesterday while trying to fix some bugs.. it's already fixed and will have the update posted within a few hours.. Got a lot of stuff fixed and some of the requests done today.

There's one known bug I haven't been able to get fixed.. it's minor and doesn't break anything.. just more of an annoyance. I had the list sorting working the night I wrote it and some how broke it and have spent another like 8 hours trying to get it to work again. I finally decided that's a feature I'll come back to another time.

Working on the adding of recipes learned to the result window and then I think I'm caught up on most bugs/requests. The only one left in my to do list is adding button presses while craft (press shift x seconds into craft, press enter, y seconds into crafting.. etc).
Do you think the request I made would be hard? I hope it's not tooo hard for you. It seems like a simple feature though, But I'm no scripter yet so IDK 😛
with the shop ignoring crafting if the crafting part of it is left empty? already scripted in =)
Awesome! Yeah I only wanted decompiling because I wanted more control over how they crafted.
Ok.. *braces for the next issues* but the new patch is up with all the little bug fixes and some of the requests that were made and weren't too hard to code.

I still need to work on the button pressing while crafting add on and the use of stats to craft items (cost mana/hp/tp etc).
Uhm, do I  redownload the demo or??? I'm confused on how I get this. I only want to compilier edit.

EDIT:

Nevermind, I'm and idiot lol.

I'm getting this at start up:

f1abac.png
Ok you should be able to keep the customize section without changing anything, but you'll need to add this to the Result window pop up section

Learn_Text = "Learned:" # Learned prefixshould be around like 192.

There was a change to the recipe set up as well to change the display name, but you don't have to do anything.. it's one of the options that you can omit and everything still works. So only worry about updating the recipe parts if you want a display name that's different from the crafted item's name.

You will need to update the main script and any add on that you are currently using. If you download the demo, they will all have date stamps. If you have a bad internet connection I can upload a text version of the main script if you'd like.

Once you have the main script updated, you shouldn't get the error message any more.. however I left a debug script in the new demo project from hime works. If you are still getting the error it'll create a text file in the game's directory with very detailed info that I can use to track it down. The debugging script will also work with any script error you get.. not just the crafting script.

Edit: Also you will need to start a new game because some of the saved information has changed and won't exist in a save file made before this update
I have crappy internet, would you mind doing a text version?

EDIT: Also I only started using this script like 3 days ago, maybe only 2. Have you updated all thescripts or just two?

I'm also using Sixth's edits for Vlue's random equipment.
https://www.dropbox.com/s/8bygs84mbq9o69u/craft%20script.txt

Most of them were touched for one reason or another.. the Menu script add on wasn't touched. The actor specific one had these two lines added to it

$imported ||= {}$imported[:Venka_Actor_Crafting] = trueYou can put that anywhere you want in the script.. I usually put it some where about the customizing section but below the instructions.. but it'd work at the bottom of the script as well.

The shop add on (so you can buy recipes) wasn't touched..

Ok so I updated fewer add ons then I thought 😉

The npc crafter/decon was edited a lot because it had the most bugs and requests. Most of the main script's edits were in the Result Window and the List Window.

I like what sixth does with vlue's script and this one, but I honestly haven't had time to look at it put together yet. I did look at the result window he edited. I believe the updates I did to it today should work for his edits as well without him needed to alter the script, but I'll wait till he takes a look at it before putting a stamp on it 😉
Hehe, you broke Sixth's Dynamic Window-Pop up, the rewards, lol.

You can take a crack at fixing it:

Spoiler
################################################################################# Dynamic Results Popup Window by Sixth################################################################################# Instructions:# Copy and paste this into it's own place in the script editor after all of the# Crafting scripts to make it work.# Read the extra instructions below to avoid error messages popping up.## Fixed everything I wanted, added a new way of displaying Exp earned.# Now everything scales dynamically, everything that should center itself is# centered.# Also cleaned up the code a bit, removed my useless blabbering too. ## However, this is now NOT a plug-and-play snippet.# Some extra settings are needed to make everything work as I intended it to work.# The following things should be inserted into the "Crafting Customize Section"# of the script:## At the - Results Pop-up Window Settings - insert the following lines at the end:#   Arrow_x_Item   =  -8       # The horizontal offset for the arrow displayed#                              # after the 'Result_Msg' text#  Arrow_x_Exp    =  -2        # The horizontal offset for the arrow displayed#                              # after the 'Exp_Earned' text## At the - Font Settings - insert the following line at the end:#     :arrows      => [["Monotype Corsiva", "Verdana", "Calibri"], 24, true, 13],## This is all that you should do before you use my snippet.# If some arrows are not centered for you, edit the Arrow's offset settings to fix it.# I made that, because different font types behave differently (different sizes,# different properties, etc.), so in order to make it possible to center them# regardless of the font type someone uses, this was necessary.# I made the arrow font settings to make sure that if someone wants to display the arrow# without actually changing the other font settings, he/she could do it.# The "Monotype Corsiva" font type can display the arrows, so you don't even# have to search for a suitable font type.## I think this will be it for now. I am not planning to change anything anymore,# but if someone wants help to change some things, my PM box is open for anyone.################################################################################==============================================================================# ■ Crafting_Results_Window#==============================================================================class Crafting_Results_Window < Window_Message  #----------------------------------------------------------------------------  # ♦ Public Instance Variables  #----------------------------------------------------------------------------  attr_reader   :detail_window  #----------------------------------------------------------------------------  # ● upgraded method: initialize  #----------------------------------------------------------------------------  def initialize    super    self.x = (Graphics.width - window_width) * 0.5    self.y = (Graphics.height - window_height) * 0.5    self.opacity = Venka::Crafting::Result_Opacity    self.back_opacity = Venka::Crafting::Result_BGOpacity    @item = nil    @amount = @exp = 0    @message = ""    @leveled = false    self.openness = 0  end  #----------------------------------------------------------------------------  # ● window settings  #----------------------------------------------------------------------------  def window_width;        Graphics.width * 0.8;      end  def window_height;       fitting_height(4);         end  #----------------------------------------------------------------------------  # ○ new method: craft  #----------------------------------------------------------------------------  def craft=(craft)    return if @craft_type == craft    @craft_type = craft  end  #----------------------------------------------------------------------------  # ○ new method: detail_window  #----------------------------------------------------------------------------  def detail_window=(detail_window)    @detail_window = detail_window  end  #----------------------------------------------------------------------------  # ○ new method: update_info  #----------------------------------------------------------------------------  def update_info    @item    = @detail_window.result_item    @amount  = @detail_window.result_amount    @exp     = @detail_window.result_exp    @message = @detail_window.result_message    @leveled = @detail_window.result_level    refresh    open    wait_to_dispose  end  #----------------------------------------------------------------------------  # ● upgraded method: refresh  #----------------------------------------------------------------------------  def refresh    contents.clear    set_font🙂other_text)    draw_items_received(line_height, contents.width)    draw_header    draw_exp_received(line_height*2)   if @exp > 0    draw_level_up(line_height*3)       if @leveled  end  #----------------------------------------------------------------------------  # ○ new method: draw_items_received  #----------------------------------------------------------------------------  def draw_items_received(y, width)    contents.clear    case @message    when Venka::Crafting::Result_Msg     width22 = text_size(@message).width + text_size(@item.name).width + text_size("x#{@amount}").width + 140    self.width = width22    self.x = Graphics.width/2 - width22/2     create_contents     set_font🙂other_text)      draw_text(0, y, contents.width, line_height, @message)      w = text_size(@message).width + 5      draw_text(w, y, contents.width - w, line_height, "x#{@amount}", 2)      w += text_size("x#{@amount}").width + 5      if $imported[:MAIcon_Hue]        draw_icon_with_hue(@item.icon_index, @item.icon_hue, w, y)      else        draw_icon(@item.icon_index, contents.width - text_size(@item.name).width - 30 - text_size("x#{@amount}").width - 6, y)      end       change_color(@item.color)        draw_text(w + 25, y, contents.width - w - 25 - text_size("x#{@amount}").width - 6, line_height, @item.name, 2)      set_font🙂arrows)       draw_text(text_size(@message).width + Venka::Crafting::Arrow_x_Item, y, 76, line_height, "→", 1)     set_font🙂other_text)        when Venka::Crafting::Failed_Msg      contents.clear      width22 = text_size(@message).width + 140      self.width = width22      self.x = Graphics.width/2 - width22/2      create_contents      draw_text(0, y, contents.width, line_height, @message, 1)    end  end  #----------------------------------------------------------------------------  # ○ new method: draw_exp_received  #----------------------------------------------------------------------------    def draw_exp_received(y)      set_font🙂other_text)      draw_text(0 - text_size("→").width / 2 - 6, y, contents.width / 2, line_height, Venka::Crafting::Exp_Earned, 2)      w = text_size(Venka::Crafting::Exp_Earned).width + 9      text = $craft[@craft_type].max_level? ? Venka::Crafting::Max_Exp : @exp.to_s      draw_text(contents.width / 2 + text_size("→").width / 2 + 6, y, contents.width / 2, line_height, text + " Exp", 0)         set_font🙂arrows)      draw_text(contents.width / 2 - text_size("→").width / 2 + Venka::Crafting::Arrow_x_Exp, y, text_size("→").width, line_height, "→", 1)      set_font🙂other_text)    end  #----------------------------------------------------------------------------  # ○ new method: draw_header  #----------------------------------------------------------------------------  def draw_header    set_font🙂recipe_name)    draw_text(0, 0, contents.width, line_height, Venka::Crafting::Results_Text, 1)    color = normal_color    contents.fill_rect(0, line_height - 2, contents_width, 1, color)    color.alpha = 90    contents.fill_rect(0, line_height - 1, contents_width, 1, color)  end  #----------------------------------------------------------------------------  # ○ new method: draw_level_up  #----------------------------------------------------------------------------  def draw_level_up(y)    set_font🙂button_text)    draw_text(0, y, contents.width, line_height, Venka::Crafting::Lv_Gain, 1)  end  #----------------------------------------------------------------------------  # ○ new method: wait_to_dispose  #----------------------------------------------------------------------------  def wait_to_dispose    loop do      Graphics.update      Input.update      update      break if Input.trigger?(Input::C)    end    self.close  endend
da874c.png

Original thread: https://forums.rpgmakerweb.com/threads/crafting-script-v3-8-updated-2-26-2015.17560/