Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
kellessdee

Item Crafting script[RMXP]

Recommended Posts

I know there is already a few item crafting scripts out there, but I wrote this one for Bob423 and figured I'd share it with the rest of you.

 

To use it, simply add the Script above "Main"

The way the script works is that it contains a module (at the very top of the script) in which you declare each recipe, and create an Item in the database for the recipe. The format for each recipe is as follows:

RECIPE[index] = [recipe_id, [product_type, product_id], [material_1_type, material_1_id, material_1_qty], ...]

recipe_id - this is the ID number in "items" tab of database

 

product_type - this is the "type" of item that will be created; 0 = item; 1 = weapon; 2 = armor

 

product_id - this is the ID number in corresponding "type" tab of database for finished product

 

material_1_type - first required material "type"; 0 = item; 1 = weapon; 2 = armor

 

material_1_id - this is the ID number in corresponding "type" tab of database for first material

 

material_1_qty - the quantity required of first material to create product

 

This script supports as many ingredients (or materials required) as you would like, all you have to do is add them to the end of the array following the same format EX.

RECIPE[4] = [37, [2, 32], [2, 26, 1], [2, 30, 1], [2, 29, 1], [0, 14, 1]]

the first element being the corresponding database item_id, the second element being the finished product data and each following element corresponds with the materials required to create such recipe.

 

I also included a RESIZE_MENU option in the module, when true the crafting menus will resize themselves according to fit the number of items and draw the map behind them (this would work good if you are already using a menu that displays the map as the background)

 

SCREENSHOTS

 

crafting1.png

crafting2.png

Creation Prompt

crafting3.png

Resized-Menus

 

 

 

SCRIPT WITH BUG FIX + BREWMEISTER's MODIFICATION ADDED:

 

=begin
-----------------------------------------------------------------------------
*** RECIPE CONFIGURATION ****************************************************
-----------------------------------------------------------------------------
INSTRUCTIONS:
This module contains the constant variables used for each recipe
format: 
RECIPE[index] = [recipe_id, [product_type, product_id],
                [material_1_type, material_1_id, material_1_qty], ...]
recipe_id       : this is the ID number in "items" tab of database
product_type    : this is the "type" of item that will be created
               : 0 = item; 1 = weapon; 2 = armor
product_id      : this is the ID number in corresponding "type" tab of database
               : for finished product
material_1_type : first required material "type"
               : 0 = item; 1 = weapon; 2 = armor
material_1_id   : this is the ID number in corresponding "type" tab of database
               : for first material
material_1_qty  : the quantity required of first material to create product
*NOTE:*
This Script supports any number of required materials for each recipe, simply 
write in extra materials, following the same format 
EX. RECIPE[0] = [1, [0, 25], [0, 15, 5], [0, 12, 2], [0, 5, 1]]
that recipe would be found as the first item in the database, would create
item # 25 in the item database, and requires 5 item#15, 2 item#12 and 1 item#5
=end
module Crafting
 # Menu style, true - draw map and resize windows to fit contents
 # false - draw full windows
 RESIZE_MENU = false
 # Create array to hold recipe data
 RECIPE = []
 # Create recipes below
 # High Potion
 RECIPE[0] = [33, [0, 2], [0, 1, 2], [0, 17, 1]]               
 # Full Potion
 RECIPE[1] = [34, [0, 3], [0, 2, 1], [0, 28, 1]]               
 # High Perfume
 RECIPE[2] = [35, [0, 5], [0, 4, 2], [0, 18, 1]]               
 # Iron Sword
 RECIPE[3] = [36, [1, 2], [1, 1, 1], [0, 13, 5], [0, 23, 5]] 
 # Ring of Water 
 RECIPE[4] = [37, [2, 32], [2, 26, 1], [2, 30, 1], [2, 29, 1], [0, 14, 1]]
end
#============================================================================
# ** Window_Prompt
#----------------------------------------------------------------------------
#   This window asks the user if they would like to create the item
#============================================================================
class Window_Prompt < Window_Command
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     item    : item that will be created
 #--------------------------------------------------------------------------
 def initialize
   super(200, ['Create', 'Cancel'])
   self.x += 16
   self.y += 80
   self.z += 100
 end
end
#============================================================================
# ** Window_Materials
#----------------------------------------------------------------------------
#   This window displays required materials to synthesize recipe
#============================================================================
class Window_Materials < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize(recipe)
   super(320, 64, 320, 416)
   refresh(recipe)
   self.index = -1 
   self.active = false
 end
 #--------------------------------------------------------------------------
 # * Current Item
 #--------------------------------------------------------------------------
 def item
   return @data[self.index]
 end
 #--------------------------------------------------------------------------
 # * Refresh Contents
 #--------------------------------------------------------------------------
 def refresh(recipe)
   @recipe = recipe
   if self.contents != nil
     self.contents.clear
     self.contents = nil
   end
   # If no recipes are possessed do not draw item
   @data = []
   if @recipe == nil
     self.height = 96 if Crafting::RESIZE_MENU
     self.contents = Bitmap.new(self.width - 32, self.height - 32)
     # Memorize font size
     font_size = self.contents.font.size
     # Draw Header
     self.contents.font.color = system_color
     self.contents.draw_text(4, 0, 212, 32, 'Ingredients')
     self.contents.font.size = 14
     self.contents.draw_text(204, 0, 24, 32, 'need', 2)
     self.contents.draw_text(252, 0, 24, 32, 'held', 2)
     # Restore font size
     self.contents.font.size = font_size
     self.contents.draw_text(228, 0, 16, 32, '/', 1)
     return
   end
   @qty_req = []
   # Add items required
   for i in 2...@recipe.size
     case @recipe[i][0]
     when 0 # Item
       @data.push($data_items[@recipe[i][1]])
     when 1 # Weapon
       @data.push($data_weapons[@recipe[i][1]])
     when 2 # Armor
       @data.push($data_armors[@recipe[i][1]])
     end
     @qty_req.push(@recipe[i][2])
   end
   @item_max = @data.size
   # Resize ingredients list
   if Crafting::RESIZE_MENU
     self.height = @item_max * 32 + 64
     self.height = 416 if self.height > 416
   end
   # Draw items required
   self.contents = Bitmap.new(self.width - 32, @item_max * 32 + 32)
   for i in 0...@item_max
     draw_item(i)
   end
   # Memorize font size
   font_size = self.contents.font.size
   # Draw Header
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 212, 32, 'Ingredients')
   self.contents.font.size = 14
   self.contents.draw_text(204, 0, 24, 32, 'need', 2)
   self.contents.draw_text(252, 0, 24, 32, 'held', 2)
   # Restore font size
   self.contents.font.size = font_size
   self.contents.draw_text(228, 0, 16, 32, '/', 1)
 end
 #-------------------------------------------------------------------------
 # * Draw Ingredients
 #-------------------------------------------------------------------------
 def draw_item(index)
   item = @data[index]
   x = 4
   y = index * 32 + 32
   # get number of items held
   case item
   when RPG::Item
     number = $game_party.item_number(item.id)
   when RPG::Weapon
     number = $game_party.weapon_number(item.id)
   when RPG::Armor
     number = $game_party.armor_number(item.id)
   end
   self.contents.font.color = number >= @qty_req[index] ? 
                              normal_color : disabled_color
   rect = Rect.new(x, y, self.width - 32, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon(item.icon_name)
   opacity = self.contents.font.color == normal_color ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 212, 32, item.name)
   self.contents.draw_text(x + 200, y, 24, 32, @qty_req[index].to_s, 2)
   self.contents.draw_text(x + 224, y, 16, 32, '/', 1)
   self.contents.draw_text(x + 248, y, 24, 32, number.to_s, 2)
 end
 #--------------------------------------------------------------------------
 # * Update Cursor Rectangle
 #--------------------------------------------------------------------------
 def update_cursor_rect
   # If cursor position is less than 0
   if @index < 0
     self.cursor_rect.empty
     return
   end
   # Get current row
   row = @index
   # If current row is before top row
   if row < self.top_row
     # Scroll so that current row becomes top row
     self.top_row = row
   end
   # If current row is more to back than back row
   if row > self.top_row + (self.page_row_max - 1)
     # Scroll so that current row becomes back row
     self.top_row = row - (self.page_row_max - 1)
   end
   # Calculate cursor width
   cursor_width = self.width - 32
   # Calculate cursor coordinates
   x = 0
   y = @index * 32 - self.oy + 32
   # Update cursor rectangle
   self.cursor_rect.set(x, y, cursor_width, 32)
 end
 #--------------------------------------------------------------------------
 # * Help Text Update
 #--------------------------------------------------------------------------
 def update_help
   @help_window.set_text(self.item == nil ? "" : self.item.description)
 end
end


#============================================================================
# ** Window_Recipe
#----------------------------------------------------------------------------
#   This window displays recipes currently in possesion
#============================================================================
class Window_Recipe < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 64, 320, 416)
   refresh
   self.index = 0
 end
 #--------------------------------------------------------------------------
 # * Current Recipe
 #--------------------------------------------------------------------------
 def recipe
   return @data[self.index]
 end
 #--------------------------------------------------------------------------
 # * Refresh Contents
 #--------------------------------------------------------------------------
 def refresh
   if self.contents != nil
     self.contents.clear
     self.contents = nil
   end
   @data = []
   # Add Recipes in possession
   for i in 0...Crafting::RECIPE.size
     recipe_id = Crafting::RECIPE[i][0]
     if $game_party.item_number(recipe_id) > 0
       @data.push(Crafting::RECIPE[i])
     end
   end
   @item_max = @data.size
   # Resize recipe window
   if Crafting::RESIZE_MENU
     self.height = @data[0] == nil ? 96 : @item_max * 32 + 64
     self.height = 416 if self.height > 416
   end
   # If Any recipes are possessed, draw them
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, @item_max * 32 + 32)
     for i in 0...@item_max
       draw_recipes(i)
     end
   else
     self.contents = Bitmap.new(width - 32, height - 32)
   end
   # Draw Header
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 268, 32, 'Recipes Held', 1)
 end
 #-------------------------------------------------------------------------
 # * Draw Recipes
 #-------------------------------------------------------------------------
 def draw_recipes(index)
   recipe = @data[index]
   x = 4
   y = index * 32 + 32
   # check if recipe is can be created
   self.contents.font.color = recipe_can_create?(recipe) ? 
                              normal_color : disabled_color
   rect = Rect.new(x, y, self.width - 32, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon($data_items[recipe[0]].icon_name)
   opacity = self.contents.font.color == normal_color ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 212, 32, $data_items[recipe[0]].name)
 end
 #--------------------------------------------------------------------------
 # * Can Recipe be Created
 #     recipe    : array with recipe data
 #--------------------------------------------------------------------------
 def recipe_can_create?(recipe)
   return false unless recipe
   for i in 2...recipe.size
     case recipe[i][0]
     when 0 # Item
       unless $game_party.item_number(recipe[i][1]) >= recipe[i][2]
         return false
       end
     when 1 # Weapon
       unless $game_party.weapon_number(recipe[i][1]) >= recipe[i][2]
         return false
       end
     when 2 # Armor
       unless $game_party.armor_number(recipe[i][1]) >= recipe[i][2]
         return false
       end
     end
   end
   return true
 end
 #--------------------------------------------------------------------------
 # * Update Cursor Rectangle
 #--------------------------------------------------------------------------
 def update_cursor_rect
   # If cursor position is less than 0
   if @index < 0
     self.cursor_rect.empty
     return
   end
   # Get current row
   row = @index
   # If current row is before top row
   if row < self.top_row
     # Scroll so that current row becomes top row
     self.top_row = row
   end
   # If current row is more to back than back row
   if row > self.top_row + (self.page_row_max - 1)
     # Scroll so that current row becomes back row
     self.top_row = row - (self.page_row_max - 1)
   end
   # Calculate cursor width
   cursor_width = self.width - 32
   # Calculate cursor coordinates
   x = 0
   y = @index * 32 - self.oy + 32
   # Update cursor rectangle
   self.cursor_rect.set(x, y, cursor_width, 32)
 end
 #--------------------------------------------------------------------------
 # * Help Text Update
 #--------------------------------------------------------------------------
 def update_help
   if self.recipe == nil
     item = nil
     @help_window.set_text('')
   else
     case self.recipe[1][0]
     when 0 # item
       item = $data_items[self.recipe[1][1]]
     when 1 # weapon
       item = $data_weapons[self.recipe[1][1]]
     when 2 # armor
       item = $data_armors[self.recipe[1][1]]
     end
     bitmap = RPG::Cache.icon(item.icon_name)
     @help_window.set_text('Creates       ' + item.name)
     @help_window.contents.blt(78, 4, bitmap, Rect.new(0, 0, 24, 24))
   end
 end
end
#============================================================================
# ** Scene_Crafting
#----------------------------------------------------------------------------
#    This scene handles the menu used for crafting new items
#============================================================================
class Scene_Crafting
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Draw map in background
   map = Spriteset_Map.new if Crafting::RESIZE_MENU
   # Create Windows
   @recipe_window = Window_Recipe.new
   @index = 0
   @material_index = 0
   @material_window = Window_Materials.new(@recipe_window.recipe)
   @help_window = Window_Help.new
   # Associate help window
   @material_window.help_window = @help_window
   @recipe_window.help_window = @help_window
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update Graphics
     Graphics.update
     # Update Input
     Input.update
     # Update Frame
     update
     # If scene has changed
     if $scene != self
       break
     end
   end
   # Dispose windows
   map.dispose if Crafting::RESIZE_MENU
   @recipe_window.dispose
   @material_window.dispose
   @help_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Update Frame
 #--------------------------------------------------------------------------
 def update
   # Update current window
   @help_window.update
   if @recipe_window.active
     @recipe_window.update
     @material_window.refresh(@recipe_window.recipe)
     update_recipe
     return
   else
     @material_window.update
     update_material
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Update Recipe Window
 #--------------------------------------------------------------------------
 def update_recipe
   # if B button is pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Return to main menu
     $scene = Scene_Menu.new(4)
     return
   end
   # if C button is pressed
   if Input.trigger?(Input::C)
     # Get recipe
     recipe = @recipe_window.recipe
     # check if recipe can be created
     if @recipe_window.recipe_can_create?(recipe)
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Prompt player
       create_item_prompt(recipe)
       return
     else
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
     end
     return
   end
   # if Right button is pressed
   if Input.trigger?(Input::RIGHT)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     # Switch to materials window
     @index = @recipe_window.index
     @recipe_window.index = -1
     @recipe_window.active = false
     @material_window.active = true
     @material_window.index = @material_index
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Update Material Window
 #--------------------------------------------------------------------------
 def update_material
   # if B Button is pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Return to main menu
     $scene = Scene_Menu.new
     return
   end
   # if Left button is pressed
   if Input.trigger?(Input::LEFT)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     # Switch to recipes window
     @material_index = @material_window.index
     @material_window.index = -1
     @material_window.active = false
     @recipe_window.index = @index
     @recipe_window.active = true
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Create Item Prompt
 #--------------------------------------------------------------------------
 def create_item_prompt(recipe)
   # Create item Prompt
   command = Window_Prompt.new
   # Deactivate recipe window
   @recipe_window.active = false
   # Loop until selection is made
   loop do
     # Update Graphics
     Graphics.update
     # Update input
     Input.update
     # Update commands
     command.update
     # if B button is pressed
     if Input.trigger?(Input::B)
       # Play cancel SE
       $game_system.se_play($data_system.cancel_se)
       # Return to recipe window
       break
     end
     # if C button is pressed
     if Input.trigger?(Input::C)
       case command.index
       when 0 # Create
         # Play create SE
         $game_system.se_play($data_system.equip_se)
         # Add item to inventory
         case recipe[1][0]
         when 0 # item
           $game_party.gain_item(recipe[1][1], 1)
         when 1 # weapon
           $game_party.gain_weapon(recipe[1][1], 1)
         when 2 # armor
           $game_party.gain_armor(recipe[1][1], 1)
         end
         # Remove ingredients
         for i in 2...recipe.size
           case recipe[i][0]
           when 0 # item
      # BREWMEISTER's MODIFICATION for consumable/non-consumable items
             if $data_items[recipe[i][1]].consumable   ##BREW
               $game_party.lose_item(recipe[i][1], recipe[i][2])
             end                                       ##BREW
             # END MODIFICATION
           when 1 # weapon
             $game_party.lose_weapon(recipe[i][1], recipe[i][2])
           when 2 # armor
             $game_party.lose_armor(recipe[i][1], recipe[i][2])
           end
         end
         # Refresh recipe window
         @recipe_window.refresh
         break
       when 1 # Cancel
         # Play cancel SE
         $game_system.se_play($data_system.cancel_se)
         # Return to recipe window
         break
       end
     end
   end
   command.dispose
   @recipe_window.active = true
 end
end

 

 

 

DOWNLOAD DEMO:

https://rapidshare.com/#!download|2l33|454000410|Crafting_System.rar|182

 

The demo includes the main menu with the "Craft" option added to it. This system SHOULD work with any menu, however there will probably need to be some modifying necessary to get it to work. If you need help getting it to work with a Custom Menu system, let me know and I will help you get it set up.

 

EDIT: Well apparently I forgot how to use the forums and nearly, COMPLETELY destroyed my own topic xD, FIXED IT :D

 

REAL EDIT: SCRIPT WITH BUG FIX + BREWMEISTER's MODIFICATION ADDED

Share this post


Link to post
Share on other sites

Kell, nice job. :clap: I like this script. It's well documented, and well scripted. I glanced through the script once & understood how it worked.

What's the reason for allowing L/R switch between recipe & material window?? Just to see the descriptions of the ingredients?

 

One thing I've noticed many of the crafting scripts don't do is account for non-consumable items. (tools: Hammer, Pot, Anvil, Needle, etc...)

 

So I made this massive enhancement to allow your script to use non-consumable items.

 

              if $data_items[recipe[i][1]].consumable   ##BREW
               $game_party.lose_item(recipe[i][1], recipe[i][2])
             end                                       ##BREW

 

Now if an item is set to "Consumable:No", it won't be subtracted.

 

Be Well

Share this post


Link to post
Share on other sites

Wow. nice and easy to understand. Thanks for making this. Im sure lots of people will love it, me in included.

Share this post


Link to post
Share on other sites

:) Thanks guys, I am very glad you find this useful! I'm just trying to brush up on my ruby skills before I REALLY get into my current projects, so I will probably be releasing more scripts (as I come up with more ideas) and hopefully they will be just as useful.

I like to heavily document ALL code I write, I find it helpful for me so I can just read a comment and know what's happening where rather than having to search and reread the code closely (very useful for trying to iron out glitches in long scripts)

And every programming class I have taken in school, the teachers have drilled commenting/documentation into my brain :/ you lose marks if you don't. Now it's second nature to document everything, which now I see why they do that haha.

 

And that's awesome brewmeister, I totally never even thought about making recipes that require a non-consumable item that like hammer or anvil! It makes a lot of sense now that I think about it. And, I made L/R buttons cycle between windows because it is set up so the user can add as many ingredients to the recipe as they would like, which means (although probably highly unlikely) it is possible to have more ingredients than would fit in the materials window, which in that case the player would have to scroll down to see all necessary materials. It was more a catchall if you will, just in case the user would like recipes that include 10+ materials.

 

Of course, let me know if you run into any issues with script, or if anyone needs help modifying it (say you don't like the layout or wanted it to work slightly differently) definitely let me know! at this point any changes should be simple.

Share this post


Link to post
Share on other sites

I have to say this is a really nice script ^^

Probably the best of this sort that I have seen so far. I couldn't find any bugs with it as well, so good job on your part =)

The only thing missing would be to add recipes as the game progresses, say the player finds a new one in a book for example. But it still is a nice script =D

Share this post


Link to post
Share on other sites

I kinda need help with this pinch.gif

I'm using Rune's CMS(at least I think)

but I'm not exactly sure how to incorporate this into the CMS.. I fail at ruby tomato2.gif

Share this post


Link to post
Share on other sites
Guest

Thanks kellesdee! this is extremely usefull for my game :D

I've seen other crafting scripts but this is really the best!

Thanks alot :D :D :D

Share this post


Link to post
Share on other sites

I tried adding a recipe for an egg. (You should craft an egg->a switch turns on). But when i want to insert the egg with the folowing recipe:

RECIPE = []

# Create recipes below

# Egg bulbasaur

RECIPE[0] = [49, [0, 47], [0, 34, 1], [0, 48, 1]]

 

end

It doesn't show up in the window. 49 is an item called Mossyegg (with treasure chest icon), 47 is the actual egg with an egg icon, 34 is an item and 48 another item. What am I doing wrong? Also when I use enter on the empty space it tells me the following error: line 282- No Method occured Undefined method size for nil: NilClass.

 

The recepis inserted by you do work (Ofcourse there are no treasure chest symbols but the icons of the items on my n°33,34,...)

The egg and other stuff is not consumable! But I don't really udnerstand how to use brewmeisters code.

 

 

Please help I'm a noob at scripting but I'm reading your lessons right now!

 

Thx anyway,

Me

PS:You need to walk like 2000 tiles before the egg hatches, I made a common event for this parrallel with a switch. How do I activate the switch the moment you create the egg?

Edited by Souldustwolf

Share this post


Link to post
Share on other sites

Sorry for the late response... School's been hectic...

 

FIRSTLY, as an FYI to everyone(if anyone cares xD), I *am* really really close to finishing version 2.0 (which will be much better...IMO) (and Kare, I *AM* almost finished your request as well, sorry it's been so long)

 

*ahem* anyways,

@souldustwolf:

You are in luck, these are some easy fixes!

1. You actually got the configuration perfectly...however, Since this is a recipe based system, recipes will only show up in the window IF the party is currently holding that recipe. Have you put the recipe in the party's inventory?

 

2. Good bug catch, *ahem* lemme fix that... (this is a really old script xD, there might be more bugs hiding in there)

 

3. ahhh, ok, I'll add that in for you

 

4. Oh yay, another reader :D I hope the tutorials help...Ask me if you need any help.

(Which reminds me....I'm REALLY behind on those tutorials :( Hopefully over my break I'll be able to get some done)

 

 

 

 

Share this post


Link to post
Share on other sites

Sorry, for some reason my post was getting cut off :(

 

IN THE MEANTIME....

 

SCRIPT WITH BUG FIX + BREWMEISTER's MODIFICATION ADDED:

 

 

=begin
-----------------------------------------------------------------------------
*** RECIPE CONFIGURATION ****************************************************
-----------------------------------------------------------------------------
INSTRUCTIONS:
This module contains the constant variables used for each recipe
format: 
RECIPE[index] = [recipe_id, [product_type, product_id],
                [material_1_type, material_1_id, material_1_qty], ...]
recipe_id       : this is the ID number in "items" tab of database
product_type    : this is the "type" of item that will be created
               : 0 = item; 1 = weapon; 2 = armor
product_id      : this is the ID number in corresponding "type" tab of database
               : for finished product
material_1_type : first required material "type"
               : 0 = item; 1 = weapon; 2 = armor
material_1_id   : this is the ID number in corresponding "type" tab of database
               : for first material
material_1_qty  : the quantity required of first material to create product
*NOTE:*
This Script supports any number of required materials for each recipe, simply 
write in extra materials, following the same format 
EX. RECIPE[0] = [1, [0, 25], [0, 15, 5], [0, 12, 2], [0, 5, 1]]
that recipe would be found as the first item in the database, would create
item # 25 in the item database, and requires 5 item#15, 2 item#12 and 1 item#5
=end
module Crafting
 # Menu style, true - draw map and resize windows to fit contents
 # false - draw full windows
 RESIZE_MENU = false
 # Create array to hold recipe data
 RECIPE = []
 # Create recipes below
 # High Potion
 RECIPE[0] = [33, [0, 2], [0, 1, 2], [0, 17, 1]]               
 # Full Potion
 RECIPE[1] = [34, [0, 3], [0, 2, 1], [0, 28, 1]]               
 # High Perfume
 RECIPE[2] = [35, [0, 5], [0, 4, 2], [0, 18, 1]]               
 # Iron Sword
 RECIPE[3] = [36, [1, 2], [1, 1, 1], [0, 13, 5], [0, 23, 5]] 
 # Ring of Water 
 RECIPE[4] = [37, [2, 32], [2, 26, 1], [2, 30, 1], [2, 29, 1], [0, 14, 1]]
end
#============================================================================
# ** Window_Prompt
#----------------------------------------------------------------------------
#   This window asks the user if they would like to create the item
#============================================================================
class Window_Prompt < Window_Command
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     item    : item that will be created
 #--------------------------------------------------------------------------
 def initialize
   super(200, ['Create', 'Cancel'])
   self.x += 16
   self.y += 80
   self.z += 100
 end
end
#============================================================================
# ** Window_Materials
#----------------------------------------------------------------------------
#   This window displays required materials to synthesize recipe
#============================================================================
class Window_Materials < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize(recipe)
   super(320, 64, 320, 416)
   refresh(recipe)
   self.index = -1 
   self.active = false
 end
 #--------------------------------------------------------------------------
 # * Current Item
 #--------------------------------------------------------------------------
 def item
   return @data[self.index]
 end
 #--------------------------------------------------------------------------
 # * Refresh Contents
 #--------------------------------------------------------------------------
 def refresh(recipe)
   @recipe = recipe
   if self.contents != nil
     self.contents.clear
     self.contents = nil
   end
   # If no recipes are possessed do not draw item
   @data = []
   if @recipe == nil
     self.height = 96 if Crafting::RESIZE_MENU
     self.contents = Bitmap.new(self.width - 32, self.height - 32)
     # Memorize font size
     font_size = self.contents.font.size
     # Draw Header
     self.contents.font.color = system_color
     self.contents.draw_text(4, 0, 212, 32, 'Ingredients')
     self.contents.font.size = 14
     self.contents.draw_text(204, 0, 24, 32, 'need', 2)
     self.contents.draw_text(252, 0, 24, 32, 'held', 2)
     # Restore font size
     self.contents.font.size = font_size
     self.contents.draw_text(228, 0, 16, 32, '/', 1)
     return
   end
   @qty_req = []
   # Add items required
   for i in 2...@recipe.size
     case @recipe[i][0]
     when 0 # Item
       @data.push($data_items[@recipe[i][1]])
     when 1 # Weapon
       @data.push($data_weapons[@recipe[i][1]])
     when 2 # Armor
       @data.push($data_armors[@recipe[i][1]])
     end
     @qty_req.push(@recipe[i][2])
   end
   @item_max = @data.size
   # Resize ingredients list
   if Crafting::RESIZE_MENU
     self.height = @item_max * 32 + 64
     self.height = 416 if self.height > 416
   end
   # Draw items required
   self.contents = Bitmap.new(self.width - 32, @item_max * 32 + 32)
   for i in 0...@item_max
     draw_item(i)
   end
   # Memorize font size
   font_size = self.contents.font.size
   # Draw Header
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 212, 32, 'Ingredients')
   self.contents.font.size = 14
   self.contents.draw_text(204, 0, 24, 32, 'need', 2)
   self.contents.draw_text(252, 0, 24, 32, 'held', 2)
   # Restore font size
   self.contents.font.size = font_size
   self.contents.draw_text(228, 0, 16, 32, '/', 1)
 end
 #-------------------------------------------------------------------------
 # * Draw Ingredients
 #-------------------------------------------------------------------------
 def draw_item(index)
   item = @data[index]
   x = 4
   y = index * 32 + 32
   # get number of items held
   case item
   when RPG::Item
     number = $game_party.item_number(item.id)
   when RPG::Weapon
     number = $game_party.weapon_number(item.id)
   when RPG::Armor
     number = $game_party.armor_number(item.id)
   end
   self.contents.font.color = number >= @qty_req[index] ? 
                              normal_color : disabled_color
   rect = Rect.new(x, y, self.width - 32, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon(item.icon_name)
   opacity = self.contents.font.color == normal_color ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 212, 32, item.name)
   self.contents.draw_text(x + 200, y, 24, 32, @qty_req[index].to_s, 2)
   self.contents.draw_text(x + 224, y, 16, 32, '/', 1)
   self.contents.draw_text(x + 248, y, 24, 32, number.to_s, 2)
 end
 #--------------------------------------------------------------------------
 # * Update Cursor Rectangle
 #--------------------------------------------------------------------------
 def update_cursor_rect
   # If cursor position is less than 0
   if @index < 0
     self.cursor_rect.empty
     return
   end
   # Get current row
   row = @index
   # If current row is before top row
   if row < self.top_row
     # Scroll so that current row becomes top row
     self.top_row = row
   end
   # If current row is more to back than back row
   if row > self.top_row + (self.page_row_max - 1)
     # Scroll so that current row becomes back row
     self.top_row = row - (self.page_row_max - 1)
   end
   # Calculate cursor width
   cursor_width = self.width - 32
   # Calculate cursor coordinates
   x = 0
   y = @index * 32 - self.oy + 32
   # Update cursor rectangle
   self.cursor_rect.set(x, y, cursor_width, 32)
 end
 #--------------------------------------------------------------------------
 # * Help Text Update
 #--------------------------------------------------------------------------
 def update_help
   @help_window.set_text(self.item == nil ? "" : self.item.description)
 end
end


#============================================================================
# ** Window_Recipe
#----------------------------------------------------------------------------
#   This window displays recipes currently in possesion
#============================================================================
class Window_Recipe < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(0, 64, 320, 416)
   refresh
   self.index = 0
 end
 #--------------------------------------------------------------------------
 # * Current Recipe
 #--------------------------------------------------------------------------
 def recipe
   return @data[self.index]
 end
 #--------------------------------------------------------------------------
 # * Refresh Contents
 #--------------------------------------------------------------------------
 def refresh
   if self.contents != nil
     self.contents.clear
     self.contents = nil
   end
   @data = []
   # Add Recipes in possession
   for i in 0...Crafting::RECIPE.size
     recipe_id = Crafting::RECIPE[i][0]
     if $game_party.item_number(recipe_id) > 0
       @data.push(Crafting::RECIPE[i])
     end
   end
   @item_max = @data.size
   # Resize recipe window
   if Crafting::RESIZE_MENU
     self.height = @data[0] == nil ? 96 : @item_max * 32 + 64
     self.height = 416 if self.height > 416
   end
   # If Any recipes are possessed, draw them
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, @item_max * 32 + 32)
     for i in 0...@item_max
       draw_recipes(i)
     end
   else
     self.contents = Bitmap.new(width - 32, height - 32)
   end
   # Draw Header
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 268, 32, 'Recipes Held', 1)
 end
 #-------------------------------------------------------------------------
 # * Draw Recipes
 #-------------------------------------------------------------------------
 def draw_recipes(index)
   recipe = @data[index]
   x = 4
   y = index * 32 + 32
   # check if recipe is can be created
   self.contents.font.color = recipe_can_create?(recipe) ? 
                              normal_color : disabled_color
   rect = Rect.new(x, y, self.width - 32, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   bitmap = RPG::Cache.icon($data_items[recipe[0]].icon_name)
   opacity = self.contents.font.color == normal_color ? 255 : 128
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
   self.contents.draw_text(x + 28, y, 212, 32, $data_items[recipe[0]].name)
 end
 #--------------------------------------------------------------------------
 # * Can Recipe be Created
 #     recipe    : array with recipe data
 #--------------------------------------------------------------------------
 def recipe_can_create?(recipe)
   return false unless recipe
   for i in 2...recipe.size
     case recipe[i][0]
     when 0 # Item
       unless $game_party.item_number(recipe[i][1]) >= recipe[i][2]
         return false
       end
     when 1 # Weapon
       unless $game_party.weapon_number(recipe[i][1]) >= recipe[i][2]
         return false
       end
     when 2 # Armor
       unless $game_party.armor_number(recipe[i][1]) >= recipe[i][2]
         return false
       end
     end
   end
   return true
 end
 #--------------------------------------------------------------------------
 # * Update Cursor Rectangle
 #--------------------------------------------------------------------------
 def update_cursor_rect
   # If cursor position is less than 0
   if @index < 0
     self.cursor_rect.empty
     return
   end
   # Get current row
   row = @index
   # If current row is before top row
   if row < self.top_row
     # Scroll so that current row becomes top row
     self.top_row = row
   end
   # If current row is more to back than back row
   if row > self.top_row + (self.page_row_max - 1)
     # Scroll so that current row becomes back row
     self.top_row = row - (self.page_row_max - 1)
   end
   # Calculate cursor width
   cursor_width = self.width - 32
   # Calculate cursor coordinates
   x = 0
   y = @index * 32 - self.oy + 32
   # Update cursor rectangle
   self.cursor_rect.set(x, y, cursor_width, 32)
 end
 #--------------------------------------------------------------------------
 # * Help Text Update
 #--------------------------------------------------------------------------
 def update_help
   if self.recipe == nil
     item = nil
     @help_window.set_text('')
   else
     case self.recipe[1][0]
     when 0 # item
       item = $data_items[self.recipe[1][1]]
     when 1 # weapon
       item = $data_weapons[self.recipe[1][1]]
     when 2 # armor
       item = $data_armors[self.recipe[1][1]]
     end
     bitmap = RPG::Cache.icon(item.icon_name)
     @help_window.set_text('Creates       ' + item.name)
     @help_window.contents.blt(78, 4, bitmap, Rect.new(0, 0, 24, 24))
   end
 end
end
#============================================================================
# ** Scene_Crafting
#----------------------------------------------------------------------------
#    This scene handles the menu used for crafting new items
#============================================================================
class Scene_Crafting
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   # Draw map in background
   map = Spriteset_Map.new if Crafting::RESIZE_MENU
   # Create Windows
   @recipe_window = Window_Recipe.new
   @index = 0
   @material_index = 0
   @material_window = Window_Materials.new(@recipe_window.recipe)
   @help_window = Window_Help.new
   # Associate help window
   @material_window.help_window = @help_window
   @recipe_window.help_window = @help_window
   # Execute transition
   Graphics.transition
   # Main loop
   loop do
     # Update Graphics
     Graphics.update
     # Update Input
     Input.update
     # Update Frame
     update
     # If scene has changed
     if $scene != self
       break
     end
   end
   # Dispose windows
   map.dispose if Crafting::RESIZE_MENU
   @recipe_window.dispose
   @material_window.dispose
   @help_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Update Frame
 #--------------------------------------------------------------------------
 def update
   # Update current window
   @help_window.update
   if @recipe_window.active
     @recipe_window.update
     @material_window.refresh(@recipe_window.recipe)
     update_recipe
     return
   else
     @material_window.update
     update_material
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Update Recipe Window
 #--------------------------------------------------------------------------
 def update_recipe
   # if B button is pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Return to main menu
     $scene = Scene_Menu.new(4)
     return
   end
   # if C button is pressed
   if Input.trigger?(Input::C)
     # Get recipe
     recipe = @recipe_window.recipe
     # check if recipe can be created
     if @recipe_window.recipe_can_create?(recipe)
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Prompt player
       create_item_prompt(recipe)
       return
     else
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
     end
     return
   end
   # if Right button is pressed
   if Input.trigger?(Input::RIGHT)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     # Switch to materials window
     @index = @recipe_window.index
     @recipe_window.index = -1
     @recipe_window.active = false
     @material_window.active = true
     @material_window.index = @material_index
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Update Material Window
 #--------------------------------------------------------------------------
 def update_material
   # if B Button is pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Return to main menu
     $scene = Scene_Menu.new
     return
   end
   # if Left button is pressed
   if Input.trigger?(Input::LEFT)
     # Play cursor SE
     $game_system.se_play($data_system.cursor_se)
     # Switch to recipes window
     @material_index = @material_window.index
     @material_window.index = -1
     @material_window.active = false
     @recipe_window.index = @index
     @recipe_window.active = true
     return
   end
 end
 #--------------------------------------------------------------------------
 # * Create Item Prompt
 #--------------------------------------------------------------------------
 def create_item_prompt(recipe)
   # Create item Prompt
   command = Window_Prompt.new
   # Deactivate recipe window
   @recipe_window.active = false
   # Loop until selection is made
   loop do
     # Update Graphics
     Graphics.update
     # Update input
     Input.update
     # Update commands
     command.update
     # if B button is pressed
     if Input.trigger?(Input::B)
       # Play cancel SE
       $game_system.se_play($data_system.cancel_se)
       # Return to recipe window
       break
     end
     # if C button is pressed
     if Input.trigger?(Input::C)
       case command.index
       when 0 # Create
         # Play create SE
         $game_system.se_play($data_system.equip_se)
         # Add item to inventory
         case recipe[1][0]
         when 0 # item
           $game_party.gain_item(recipe[1][1], 1)
         when 1 # weapon
           $game_party.gain_weapon(recipe[1][1], 1)
         when 2 # armor
           $game_party.gain_armor(recipe[1][1], 1)
         end
         # Remove ingredients
         for i in 2...recipe.size
           case recipe[i][0]
           when 0 # item
      # BREWMEISTER's MODIFICATION for consumable/non-consumable items
             if $data_items[recipe[i][1]].consumable   ##BREW
               $game_party.lose_item(recipe[i][1], recipe[i][2])
             end                                       ##BREW
             # END MODIFICATION
           when 1 # weapon
             $game_party.lose_weapon(recipe[i][1], recipe[i][2])
           when 2 # armor
             $game_party.lose_armor(recipe[i][1], recipe[i][2])
           end
         end
         # Refresh recipe window
         @recipe_window.refresh
         break
       when 1 # Cancel
         # Play cancel SE
         $game_system.se_play($data_system.cancel_se)
         # Return to recipe window
         break
       end
     end
   end
   command.dispose
   @recipe_window.active = true
 end
end

 

 

Share this post


Link to post
Share on other sites

Don't be sorry :3

 

Open the script database, and scroll to the bottom (in the left box).

There will be a Script titled "Main" at the very bottom, right click that script and click "Insert"

A new, empty script will appear above Main. Then, select that empty script and paste my script into the script window (in the right box).

 

Then, if you want to call script from an item:

->Open the database

->Make a new common event

->Add a "Call Script" event command

->Type

$scene = Scene_Crafting.new

into the Call Script box

->Make a new item

->Set Scope to "None"

->Set Occasion to "Only from Menu"

->Set Common Event to the common event you just created

 

Then when the player uses the item, the common event will be called; which will execute the call to the crafting scene.

 

Share this post


Link to post
Share on other sites

Thank you kellessdee! Now everything is just fine! Just one more thing: After the creation of a specific item a switch must be activated to link to a commen event. (the event that let's an egg hatch after 2000 steps). Any tips on where to insert such a switch?

#Would the code look like this?
class Condition
attr_accessor :switch1_valid
attr_accessor :switch1_id
def initialize
@switch1_valid true
@switch1_id = 19 #the commen event switch
end

Edited by Souldustwolf

Share this post


Link to post
Share on other sites

Hey, i'm having trouble using this with my CMS. Here's the script for it. Forget where i found it.

 

 

#===================================================

# ¦ Ring Menu - Show Player Location - Release #1 (Enhanced By Dubealex)

#===================================================

# For more infos and update, visit:

# asylum.dubealex.com

#

# Original Ring Menu by: ?? (From XRXS)

# Original Edit and Fix by: Maki

# Show Player Location Version by: Dubealex

#

# You can customize this script at line #35 - Have fun !!

# If you want to show more stuff, its easy to do, you can try to ask in the forum.

#

# alex@dubealex.com

#===================================================

 

 

#===================================================

# ? CLASS Scene_Menu Begins

#===================================================

 

class Scene_Menu

#--------------------------------------------------------------------------

# ?? ?I?u?W?F?N?g??????

# menu_index : ?R?}???h??J?[?\????????u

#--------------------------------------------------------------------------

def initialize(menu_index = 0)

@menu_index = menu_index

$location_text=[]

$window_size=[]

$ring_menu_text=[]

$chara_select=[]

@window_opacity=[]

@chara_select=[]

@window_position=[]

 

#--------------------------------------------------------------------------------------------------

# ¦ Ring Menu Customization Section: (By Dubealex)

#--------------------------------------------------------------------------------------------------

# Those variables defines how the script will act.

# Simply change the value by those you want.

# Remember that changing the font size has its limitation due to text space allocation.

#

# ? TEXT SETTINGS FOR SHOW PLAYER LOCATION WINDOW:

$location_text[0]="Tahoma" # Font Type

$location_text[1]=22 # Font Size

$location_text[2]=6 # Location Title Color

$location_text[4]=0 # Map Name Color

$location_text[3]="Location:" # Customize the "Location" Title Text

 

# ? SHOW LOCATION WINDOW SETTINS:

@show_location_window=true #Set to false to not use it !

@window_opacity[0]=255 # Border Opacity

@window_opacity[1]=130 # Background Opacity

$window_location_skin="001-Blue01" # Window Skin

@window_position[0]=20 # X Axis Position

@window_position[1]=20 # Y Axis Position

$window_size[0]=160 # Lengh

$window_size[1]=96 # Heigh

 

# ? TEXT SETTINGS FOR INSIDE THE RING MENU:

$ring_menu_text[0]="Tahoma" # Font Type

$ring_menu_text[7]=0 # Font Color

$ring_menu_text[8]=22 # Font Size

$ring_menu_text[1]="Items" # Items Menu Text

$ring_menu_text[2]="Skills" # Skills Menu Text

$ring_menu_text[3]="Equip" # Equip Menu Text

$ring_menu_text[4]="Stats" # Stats Menu Text

$ring_menu_text[5]="Save" # Save Menu Text

$ring_menu_text[6]="Quit" # Quit Menu Text

 

# ? CHARACTER SELECTION WINDOW SETTINGS :

@chara_select[0]=400 # X Axis Position

@chara_select[1]=0 # Y Axis Position

$chara_select[0]="Tahoma" # Font Type

$chara_select[1]=0 # Font Color

$chara_select[5]=22 # Font Size

$chara_select[2]=255 # Window Border Opacity

$chara_select[3]=130 # Window Background Opacity

$chara_select[4]="001-Blue01" # Window Skin to use

#--------------------------------------------------------------------------------------------------

 

end

#--------------------------------------------------------------------------

# ?? ???C?????

#--------------------------------------------------------------------------

def main

 

# Show Player Location Feature:

if @show_location_window==true

@window_location = Window_Location.new

@window_location.x = @window_position[0]

@window_location.y = @window_position[1]

@window_location.opacity = @window_opacity[0]

@window_location.back_opacity = @window_opacity[1]

end

#End of Show Player Location

 

# ?X?v???C?g?Z?b?g???? ?

@spriteset = Spriteset_Map.new

# ?R?}???h?E?B???h?E???? ?

px = $game_player.screen_x - 15

py = $game_player.screen_y - 24

@command_window = Window_RingMenu.new(px,py)

@command_window.index = @menu_index

# ?p?[?e?B l ??? 0 l??????

if $game_party.actors.size == 0

# ?A?C?e???A?X?L???A?????A?X?e?[?^?X????????

@command_window.disable_item(0)

@command_window.disable_item(1)

@command_window.disable_item(2)

@command_window.disable_item(3)

end

@command_window.z = 100

# ?Z?[?u??~??????

if $game_system.save_disabled

# ?Z?[?u???????????

@command_window.disable_item(4)

end

# ?X?e?[?^?X?E?B???h?E???? ?

@status_window = Window_RingMenuStatus.new

@status_window.x = @chara_select[0]

@status_window.y = @chara_select[1]

@status_window.z = 200

@status_window.opacity=$chara_select[2]

@status_window.back_opacity=$chara_select[3]

@status_window.visible = false

# ?g?????W?V???????s

Graphics.transition

# ???C?????[?v

loop do

# ?Q?[????????X V

Graphics.update

# ???????????X V

Input.update

# ?t???[???X V

update

# ????? ????????????[?v?????f

if $scene != self

break

end

end

# ?g?????W?V????????

Graphics.freeze

# ?X?v???C?g?Z?b?g??????

@spriteset.dispose

# ?E?B???h?E??????

if @show_location_window==true

@window_location.dispose

end

@command_window.dispose

@status_window.dispose

end

#--------------------------------------------------------------------------

# ?? ?t???[???X V

#--------------------------------------------------------------------------

def update

# ?E?B???h?E???X V

if @show_location_window==true

@window_location.update

end

@command_window.update

@status_window.update

# ?R?}???h?E?B???h?E???A?N?e?B?u??????: update_command ?????

if @command_window.active

update_command

return

end

# ?X?e?[?^?X?E?B???h?E???A?N?e?B?u??????: update_status ?????

if @status_window.active

update_status

return

end

end

#--------------------------------------------------------------------------

# ?? ?t???[???X V (?R?}???h?E?B???h?E???A?N?e?B?u??????)

#--------------------------------------------------------------------------

def update_command

# B ?{?^??????????????

if Input.trigger?(Input::B)

# ?L?????Z?? SE ?????t

$game_system.se_play($data_system.cancel_se)

# ?}?b?v????? ?????

$scene = Scene_Map.new

return

end

# C ?{?^??????????????

if Input.trigger?(Input::C)

# ?p?[?e?B l ??? 0 l???A?Z?[?u?A?Q?[???I????O??R?}???h??????

if $game_party.actors.size == 0 and @command_window.index < 4

# ?u?U?[ SE ?????t

$game_system.se_play($data_system.buzzer_se)

return

end

# ?R?}???h?E?B???h?E??J?[?\????u?????

case @command_window.index

when 0 # ?A?C?e??

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?A?C?e??????? ?????

$scene = Scene_Item.new

when 1 # ?X?L??

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?X?e?[?^?X?E?B???h?E???A?N?e?B?u?????

@command_window.active = false

@status_window.active = true

@status_window.visible = true

@status_window.index = 0

when 2 # ????

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?X?e?[?^?X?E?B???h?E???A?N?e?B?u?????

@command_window.active = false

@status_window.active = true

@status_window.visible = true

@status_window.index = 0

when 3 # ?X?e?[?^?X

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?X?e?[?^?X?E?B???h?E???A?N?e?B?u?????

@command_window.active = false

@status_window.active = true

@status_window.visible = true

@status_window.index = 0

when 4 # ?Z?[?u

# ?Z?[?u??~??????

if $game_system.save_disabled

# ?u?U?[ SE ?????t

$game_system.se_play($data_system.buzzer_se)

return

end

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?Z?[?u????? ?????

$scene = Scene_Save.new

when 5 # ?Q?[???I??

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?Q?[???I??????? ?????

$scene = Scene_End.new

end

return

end

# ?A?j???[?V??????????J?[?\??????? ???s?????

return if @command_window.animation?

# ??or?? ?{?^??????????????

if Input.press?(Input::UP) or Input.press?(Input::LEFT)

$game_system.se_play($data_system.cursor_se)

@command_window.setup_move_move(Window_RingMenu::MODE_MOVEL)

return

end

# ??or?? ?{?^??????????????

if Input.press?(Input::DOWN) or Input.press?(Input::RIGHT)

$game_system.se_play($data_system.cursor_se)

@command_window.setup_move_move(Window_RingMenu::MODE_MOVER)

return

end

end

#--------------------------------------------------------------------------

# ?? ?t???[???X V (?X?e?[?^?X?E?B???h?E???A?N?e?B?u??????)

#--------------------------------------------------------------------------

def update_status

# B ?{?^??????????????

if Input.trigger?(Input::B)

# ?L?????Z?? SE ?????t

$game_system.se_play($data_system.cancel_se)

# ?R?}???h?E?B???h?E???A?N?e?B?u?????

@command_window.active = true

@status_window.active = false

@status_window.visible = false

@status_window.index = -1

return

end

# C ?{?^??????????????

if Input.trigger?(Input::C)

# ?R?}???h?E?B???h?E??J?[?\????u?????

case @command_window.index

when 1 # ?X?L??

# ????A?N?^?[???s?? ????? 2 ??????????

if $game_party.actors[@status_window.index].restriction >= 2

# ?u?U?[ SE ?????t

$game_system.se_play($data_system.buzzer_se)

return

end

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?X?L??????? ?????

$scene = Scene_Skill.new(@status_window.index)

when 2 # ????

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ????????? ?????

$scene = Scene_Equip.new(@status_window.index)

when 3 # ?X?e?[?^?X

# ???? SE ?????t

$game_system.se_play($data_system.decision_se)

# ?X?e?[?^?X????? ?????

$scene = Scene_Status.new(@status_window.index)

end

return

end

end

end

 

#===================================================

# ? CLASS Scene_Menu Ends

#===================================================

 

 

#===================================================

# ? CLASS Window_RingMenu Begins

#===================================================

class Window_RingMenu < Window_Base

#--------------------------------------------------------------------------

# ?? ?N???X?? ?

#--------------------------------------------------------------------------

STARTUP_FRAMES = 20

MOVING_FRAMES = 5

RING_R = 64

ICON_ITEM = RPG::Cache.icon("034-Item03")

ICON_SKILL = RPG::Cache.icon("044-Skill01")

ICON_EQUIP = RPG::Cache.icon("001-Weapon01")

ICON_STATUS = RPG::Cache.icon("050-Skill07")

ICON_SAVE = RPG::Cache.icon("038-Item07")

ICON_EXIT = RPG::Cache.icon("046-Skill03")

ICON_DISABLE= RPG::Cache.icon("")

SE_STARTUP = "056-Right02"

MODE_START = 1

MODE_WAIT = 2

MODE_MOVER = 3

MODE_MOVEL = 4

#--------------------------------------------------------------------------

# ?? ?A?N?Z?T

#--------------------------------------------------------------------------

attr_accessor :index

#--------------------------------------------------------------------------

# ?? ?I?u?W?F?N?g??????

#--------------------------------------------------------------------------

def initialize( center_x, center_y )

super(0, 0, 640, 480)

self.contents = Bitmap.new(width-32, height-32)

self.contents.font.name = $ring_menu_text[0]

self.contents.font.color = text_color($ring_menu_text[7])

self.contents.font.size = $ring_menu_text[8]

self.opacity = 0

self.back_opacity = 0

s1 = $ring_menu_text[1]

s2 = $ring_menu_text[2]

s3 = $ring_menu_text[3]

s4 = $ring_menu_text[4]

s5 = $ring_menu_text[5]

s6 = $ring_menu_text[6]

@commands = [ s1, s2, s3, s4, s5, s6 ]

@item_max = 6

@index = 0

@items = [ ICON_ITEM, ICON_SKILL, ICON_EQUIP, ICON_STATUS, ICON_SAVE, ICON_EXIT ]

@disabled = [ false, false, false, false, false, false ]

@cx = center_x - 16

@cy = center_y - 16

setup_move_start

refresh

end

#--------------------------------------------------------------------------

# ?? ?t???[???X V

#--------------------------------------------------------------------------

def update

super

refresh

end

#--------------------------------------------------------------------------

# ?? ??????`??

#--------------------------------------------------------------------------

def refresh

self.contents.clear

# ?A?C?R?????`??

case @mode

when MODE_START

refresh_start

when MODE_WAIT

refresh_wait

when MODE_MOVER

refresh_move(1)

when MODE_MOVEL

refresh_move(0)

end

# ?A?N?e?B?u??R?}???h???\??

rect = Rect.new(@cx - 272, @cy + 24, self.contents.width-32, 32)

self.contents.draw_text(rect, @commands[@index],1)

end

#--------------------------------------------------------------------------

# ?? ??????`??(????????)

#--------------------------------------------------------------------------

def refresh_start

d1 = 2.0 * Math::PI / @item_max

d2 = 1.0 * Math::PI / STARTUP_FRAMES

r = RING_R - 1.0 * RING_R * @steps / STARTUP_FRAMES

for i in 0...@item_max

j = i - @index

d = d1 * j + d2 * @steps

x = @cx + ( r * Math.sin( d ) ).to_i

y = @cy - ( r * Math.cos( d ) ).to_i

draw_item(x, y, i)

end

@steps -= 1

if @steps < 1

@mode = MODE_WAIT

end

end

#--------------------------------------------------------------------------

# ?? ??????`??(??@??)

#--------------------------------------------------------------------------

def refresh_wait

d = 2.0 * Math::PI / @item_max

for i in 0...@item_max

j = i - @index

x = @cx + ( RING_R * Math.sin( d * j ) ).to_i

y = @cy - ( RING_R * Math.cos( d * j ) ).to_i

draw_item(x, y, i)

end

end

#--------------------------------------------------------------------------

# ?? ??????`??(???]??)

# mode : 0=?????v???? 1=???v????

#--------------------------------------------------------------------------

def refresh_move( mode )

d1 = 2.0 * Math::PI / @item_max

d2 = d1 / MOVING_FRAMES

d2 *= -1 if mode != 0

for i in 0...@item_max

j = i - @index

d = d1 * j + d2 * @steps

x = @cx + ( RING_R * Math.sin( d ) ).to_i

y = @cy - ( RING_R * Math.cos( d ) ).to_i

draw_item(x, y, i)

end

@steps -= 1

if @steps < 1

@mode = MODE_WAIT

end

end

#--------------------------------------------------------------------------

# ?? ?????`??

# x :

# y :

# i : ???????

#--------------------------------------------------------------------------

def draw_item(x, y, i)

#p "x=" + x.to_s + " y=" + y.to_s + " i=" + @items.to_s

rect = Rect.new(0, 0, @items.width, @items.height)

if @index == i

self.contents.blt( x, y, @items, rect )

if @disabled[@index]

self.contents.blt( x, y, ICON_DISABLE, rect )

end

else

self.contents.blt( x, y, @items, rect, 128 )

if @disabled[@index]

self.contents.blt( x, y, ICON_DISABLE, rect, 128 )

end

end

end

#--------------------------------------------------------------------------

# ?? ??????????????

# index : ???????

#--------------------------------------------------------------------------

def disable_item(index)

@disabled[index] = true

end

#--------------------------------------------------------------------------

# ?? ???????A?j???[?V??????????

#--------------------------------------------------------------------------

def setup_move_start

@mode = MODE_START

@steps = STARTUP_FRAMES

if SE_STARTUP != nil and SE_STARTUP != ""

Audio.se_play("Audio/SE/" + SE_STARTUP, 80, 100)

end

end

#--------------------------------------------------------------------------

# ?? ???]?A?j???[?V??????????

#--------------------------------------------------------------------------

def setup_move_move(mode)

if mode == MODE_MOVER

@index -= 1

@index = @items.size - 1 if @index < 0

elsif mode == MODE_MOVEL

@index += 1

@index = 0 if @index >= @items.size

else

return

end

@mode = mode

@steps = MOVING_FRAMES

end

#--------------------------------------------------------------------------

# ?? ?A?j???[?V?????????????

#--------------------------------------------------------------------------

def animation?

return @mode != MODE_WAIT

end

end

 

#===================================================

# ? CLASS Window_RingMenu Ends

#===================================================

 

 

#===================================================

# ? CLASS Window_RingMenuStatus Begins

#===================================================

 

class Window_RingMenuStatus < Window_Selectable

#--------------------------------------------------------------------------

# ?? ?I?u?W?F?N?g??????

#--------------------------------------------------------------------------

def initialize

super(204, 64, 232, 352)

self.contents = Bitmap.new(width - 32, height - 32)

self.contents.font.size = $chara_select[5]

refresh

self.active = false

self.index = -1

end

#--------------------------------------------------------------------------

# ?? ???t???b?V??

#--------------------------------------------------------------------------

def refresh

self.contents.clear

self.windowskin = RPG::Cache.windowskin($chara_select[4])

self.contents.font.name = $chara_select[0]

self.contents.font.color = text_color($chara_select[1])

@item_max = $game_party.actors.size

for i in 0...$game_party.actors.size

x = 80

y = 80 * i

actor = $game_party.actors

draw_actor_graphic(actor, x - 40, y + 80)

draw_actor_name(actor, x, y + 24)

end

end

#--------------------------------------------------------------------------

# ?? ?J?[?\??????`?X V

#--------------------------------------------------------------------------

def update_cursor_rect

if @index < 0

self.cursor_rect.empty

else

self.cursor_rect.set(0, @index * 80, self.width - 32, 80)

end

end

end

#===================================================

# ? CLASS Window_RingMenuStatus Ends

#===================================================

 

 

#===================================================

# ? CLASS Game_Map Additional Code Begins

#===================================================

class Game_Map

 

#Dubealex Addition (from XRXS) to show Map Name on screen

def name

$map_infos[@map_id]

end

end

 

#===================================================

# ? CLASS Game_Map Additional Code Ends

#===================================================

 

 

#===================================================

# ? CLASS Scene_Title Additional Code Begins

#===================================================

class Scene_Title

 

#Dubealex Addition (from XRXS) to show Map Name on screen

$map_infos = load_data("Data/MapInfos.rxdata")

for key in $map_infos.keys

$map_infos[key] = $map_infos[key].name

end

end

 

#===================================================

# ? CLASS Scene_Title Additional Code Ends

#===================================================

 

 

#===================================================

# ? CLASS Window_Location Begins

#===================================================

 

class Window_Location < Window_Base

 

def initialize

super(0, 0, $window_size[0], $window_size[1])

self.contents = Bitmap.new(width - 32, height - 32)

self.contents.font.name = $location_text[0]

self.contents.font.size = $location_text[1]

refresh

end

 

def refresh

self.contents.clear

self.windowskin = RPG::Cache.windowskin($window_location_skin)

self.contents.font.color = text_color($location_text[2])

self.contents.draw_text(4, 0, 120, 32, $location_text[3])

self.contents.font.color = text_color($location_text[4])

self.contents.draw_text(4, 32, 120, 32, $game_map.name, 2)

end

end

#===================================================

# ? CLASS Window_Location Ends

#===================================================

 

#===================================================

# ? Ring Menu - Show Player Location R1 - Ends

#===================================================

 

Share this post


Link to post
Share on other sites

I Looked at the script so many times... but is it possible to create more than 1 item out of like single materiel...

Like I wish I can Make 5 riceball from 1 bag of rice but there is no choice for changing the amount of product.

It would be awesome if # of product can be controlled too... If that is possible that would be the best, but i'm

Loving this script right now pinch.gif

 

Oh one other thing... is there any way for this to work with sdk?

Edited by pkmaster99

Share this post


Link to post
Share on other sites

i was wondering if i could get a link to the demo for this script. since rapidshare doesnt have the file anymore. i mostly would like the demo for the fact that its already got the crafting option from the pause menu. ive only managed to make a skill that has to be accessed via the skills menu. alternatively im also kinda confused as to how to script since im still kinda new to this... any help and advice to some good tuts would be greatly appreciated. happy.png

Share this post


Link to post
Share on other sites

Here's the demo: https://rapidshare.c...82/Crafting.zip

I have a quick question about the script, what is "# Create array to hold recipe data" All about?

Also, I'm creating around 100 recipes for my game and that clutters the parties inventory. I was wondering if there was a way to put them all together into one item, like a recipe book. Is that possible?

Edited by Rajaat99

Share this post


Link to post
Share on other sites

Unfortunately i didn't find a way to disable recipes without cutting into his code. Thats why I am only giving you a temporary solution, until he handles the problem himself, or allows me to do what needs to be done.

For simplicity's sake I am giving you an addon script, just put it in a new script under his, but keep in mind that you should delete my script if you want to use any future versions of his script.

 

@recipe_Mode=true
class Window_Recipe < Window_Selectable
 def refresh
   if self.contents != nil
  self.contents.clear
  self.contents = nil
   end
   if @recipe_Mode
  @data = []
  # Add Recipes in possession
  for i in 0...Crafting::RECIPE.size
    recipe_id = Crafting::RECIPE[i][0]
    if $game_party.item_number(recipe_id) > 0
	  @data.push(Crafting::RECIPE[i])
    end
  end
   else
  @data=Crafting::RECIPE
   end
   @item_max = @data.size
   # Resize recipe window
   if Crafting::RESIZE_MENU
  self.height = @data[0] == nil ? 96 : @item_max * 32 + 64
  self.height = 416 if self.height > 416
   end
   # If Any recipes are possessed, draw them
   if @item_max > 0
  self.contents = Bitmap.new(width - 32, @item_max * 32 + 32)
  for i in 0...@item_max
    draw_recipes(i)
  end
   else
  self.contents = Bitmap.new(width - 32, height - 32)
   end
   # Draw Header
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 268, 32, 'Recipes Held', 1)
 end
end

 

All this does is enable/disable recipe items. To disable recipes set @recipe_mode = false, and back to true to enable them again.

I could make an actual recipe book if you really want, but I'd rather talk to him before doing something so dependant on his script.

Share this post


Link to post
Share on other sites

Not exactly what I'm looking for, but thank you for responding. My problem is that the recipes take up too much room in the characters inventory. Each recipe has a specific item to go along with it and I made 115 recipes, so it takes up a lot of room. I was hoping to have it be one item instead.

Thanks again though.

Edited by Rajaat99

Share this post


Link to post
Share on other sites

This was the most disgusting script I have ever seen. Theres no description to whatever call the event of item creation. The fool who made this topic forgot to say how to call that useless creation system, and to help, posted in that trash dump of rapidshare. This was a waste of my life.

Share this post


Link to post
Share on other sites

Former moderator and super awesome guy kellessdee did make the mistake of uploading to rapidshare, however this is damn old topic (before the scripts section which provides local uploads, I may mention), but he's not a fool. Please do not spam + necropost. Seriously, that didn't need to be said. This is an old forum with a lot of old topics. I would have loved to move all of these to the scripts section, http://www.gdunlimited.net/scripts but I don't have the time, and XP is dying anyway.

 

Topic locked.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...