Jump to content

Announcing our new website

To find out the latest about our new website, visit Game Dev Unlimited

* * * * * 1 votes

Item Crafting script[RMXP]


  • You cannot reply to this topic
17 replies to this topic

#1 kellessdee

    mrrow ~!

  • Moderator
  • 899 posts

Posted 23 March 2011 - 04:04 PM

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
Spoiler

SCRIPT WITH BUG FIX + BREWMEISTER's MODIFICATION ADDED:
Spoiler

DOWNLOAD DEMO:
https://rapidshare.c..._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

#2 brewmeister

    Member

  • Member
  • 29 posts

Posted 25 March 2011 - 12:30 AM

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

#3 Polraudio

    Master of the Mind

  • Moderator
  • 3,479 posts

Posted 25 March 2011 - 12:59 AM

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

#4 kellessdee

    mrrow ~!

  • Moderator
  • 899 posts

Posted 25 March 2011 - 05:34 AM

:) 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.

#5 yamina-chan

    Newbie

  • Member
  • 2 posts

Posted 15 November 2011 - 12:29 AM

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

#6 kare3

    Loyal Member

  • Member
  • 100 posts

Posted 11 January 2012 - 09:25 PM

I kinda need help with this Posted Image
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 Posted Image

#7 mxmmix

    Newbie

  • Member
  • 17 posts

Posted 31 January 2012 - 09:49 AM

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

#8 Calvinchun

    Calvinchun

  • Member
  • 152 posts

Posted 01 February 2012 - 02:10 AM

LOL kellesdee it seem you have many fan....

Edited by Calvinchun, 01 February 2012 - 02:13 AM.


#9 Souldustwolf

    Newbie

  • Member
  • 4 posts

Posted 01 February 2012 - 12:30 PM

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, 01 February 2012 - 01:15 PM.


#10 kellessdee

    mrrow ~!

  • Moderator
  • 899 posts

Posted 07 February 2012 - 02:08 AM

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)





#11 kellessdee

    mrrow ~!

  • Moderator
  • 899 posts

Posted 07 February 2012 - 02:30 AM

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

IN THE MEANTIME....

SCRIPT WITH BUG FIX + BREWMEISTER's MODIFICATION ADDED:
Spoiler


#12 LexMark266

    Newbie

  • Member
  • 2 posts

Posted 07 February 2012 - 11:26 PM

i'm sorry but i'm not the best at scripting. Where in the script database do i put these codes. and what code do i use to open this menu say from an item?

#13 kellessdee

    mrrow ~!

  • Moderator
  • 899 posts

Posted 08 February 2012 - 12:20 AM

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.


#14 Souldustwolf

    Newbie

  • Member
  • 4 posts

Posted 08 February 2012 - 08:21 PM

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, 08 February 2012 - 08:24 PM.


#15 LexMark266

    Newbie

  • Member
  • 2 posts

Posted 08 February 2012 - 10:24 PM

hey, so now i got the screen to open but how do i make an item add the recipe to the recipe list?

and the Recipe[Index] is what number in order the item will be in on the menu right?

#16 JakalX

    Newbie

  • Member
  • 2 posts

Posted 25 February 2012 - 08:04 PM

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

Spoiler


#17 JakalX

    Newbie

  • Member
  • 2 posts

Posted 25 February 2012 - 08:06 PM

Oops, was that necro?

#18 pkmaster99

    Newbie

  • Member
  • 5 posts

Posted 28 March 2012 - 09:33 PM

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 Posted Image

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

Edited by pkmaster99, 28 March 2012 - 10:55 PM.






0 user(s) are reading this topic

members, guests, anonymous users