How do I make a Crafting System?

1 favourites
  • 9 posts
From the Asset Store
Template for maintaining an inventory with crafting possibilities. Completely documented in text and video.
  • Hi,

    I just finished creating an inventory system for my survival game and now I am moving on to a crafting system. I don't really know how to approach it. My inventory system is centered around sprites with different animations, frames, and instance variables that make them the specific item they are. The animations help to show what category the item is (resource, tool, armour, or food and drink). The frame is the the items ID within their respective category. The instance variables show specifics such as amount of item in inventory or resources and food and drink, and durability and damage for stuff like tools and armour. To me, my item system seems a little complicated, so I am stumped on how to build a crafting system with this. I would like the system to be like minecraft's crafting system but i don't know how to pre make recipies. The inventory system uses inventory slots that have instance variables that carry each specific item's information when they are in the specific slot. Does anyone have any advice or ideas? If you need any more elaboration please ask

  • A recipe would be itemA + itemB = new item. To check if you have those items you use an identifier I guess in your case the ID, or an item name.

  • okay, but how could I do that with a grid?

  • I'm not familiar with minecraft, how does the crafting work? Or what do you expect to happen? I guess you didn't use an array, that will make it more difficult but it's still doable.

  • In MC, the game stores the crafting recipes in a JSON file that uses characters to make up the 3x3 or 2x2 grid, it looks smth like this:

    I'm not sure if you could replicate this in C3, but this template is used in each file for each recipe

  • Im not to great at writing stuff in a JSON file like that but I can give it a shot. What I was hoping to happen was I would have a 3x3 grid and I would drop my items from my inventory in there and then based on how they were configured the game would have an output that would give me a different item. I guess I could have special slots for crafting and check for different configurations for each recipe but I was hoping I could just automate it a bit more. Could I do this with an array?

  • Don't worry about the top row unless you think you're going to have shapeless recipes (recipes that can be crafted in any arrangement). You can probably do this in an array, but you would need to assign a key in a dictionary or smth. This is all theoretical tho, you'll have to experiment a bit.

  • Okay, I will see what I can do, thanks for all the ideas!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could use an array or the 3x3 grid but if you know how to manipulate an array in that way then you might as well redo the inventory so it uses an array. I don't know how 3x3 works in minecraft but if using an array, each of the 9 slots relates to an xy o the array, when you drop an item in you set the item name in the array. I don't know what it's looking for in a 3x3, but if it was 2 items you would compare the items at X=0 and X=1 and see if it matches a recipe. Recipes would probably be in a second array for comparison.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)