How do I Crafting System?

Get help using Construct 2

Post » Mon Mar 28, 2016 5:30 pm

So I just finished my inventory system and am looking to move forward into a crafting system. However I just can't wrap my head around how one would work and I haven't found any examples online. I read online that you can treat it like a monetary system. You want to buy a sharpened rock you pay 2 rocks and get the upgraded item. You want to buy a knife you pay 1 wood, 1 sharpened rock, 1 vine etc. I can't figure out how to store the prices/recipes of the crafted objects then check that list to see if the player has those items in their inventory to make it. Could anyone explain how this might work or even throw together a simple .capx combining multiple items to create a single item? Below attached is my .capx for my current inventory system.

Inventory .CAPX
https://dl.dropboxusercontent.com/u/729 ... ntory.capx

WSAD - MOVE
TAB - Toggle Inventory
LEFT CLICK - Select Inventory Item
LEFT CLICK OUTSIDE INVENTORY - Drops selected item
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Tue Mar 29, 2016 5:40 pm

Little bumpski, hopefully someone might have an idea I still haven't come up with a good approach to this.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Tue Mar 29, 2016 7:49 pm

this is pretty easy How exactly do you want it to work ?

I know that you do a check with variables such as When you hit craft button the item you add a condition such as this if you have 2 or more rock then minus two rock and add one flint stone. its all in the control variable check.

if you have a shop to buy with money its the same thing you are crafting a candy bar with money. you trade one for another.

The question is how do you want to do the crafting?
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Tue Mar 29, 2016 8:06 pm

So I would like it to work like this, when the inventory is opened, slots will show at the bottom of the screen that contain all the different items you can make based on the current items in your inventory. Some items may require you to be standing by a certain in game object like a crafting table or furnace to show up in the list. It's basically a rip from Terraria's crafting mechanics.

https://www.youtube.com/watch?v=gz_n8or_BT8
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Tue Mar 29, 2016 8:52 pm

First you need the complete 'tech-tree' on paper. I suggest you start there. Then make a layout with the complete tech-tree with the right sprites. Ordered in nodes. They easyst will be in way that each parent has only two childs. Now you have a visual tree to walk thru with conditions based on instance variables. If you really want to do whats in the video, then you stand for a huge amount of work.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Mar 29, 2016 9:59 pm

So my thinking is this I can create a dictionary object for each key there will be a recipe name like Sharp Rock, Spear, Knife etc and for their values I will put in the materials and amounts needed to create that item with separators I can tokenat to.Image

That way when the inventory is opened i can run through the entire recipe dictionary see what materials and how much of each I need to create that item if I have it in my inventory then spawn the crafted item on screen so that I can click it to craft it. What do you guys think? Sound like this will work?
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Sat Apr 09, 2016 2:53 am

So I think I figured it out using my above idea. Basically I have a check_Craft function that checks to see if the player can craft an item any time an item is added or taken away from the inventory. I use tokencount to find out how many materials the item needs to be crafted. So if the recipe value has 2 "|" separators I know it needs 1 material or if it has 4 "|" separators I know it needs 2 materials etc. Then I use tokenat to find out what material and how much of each material it needs. So far I only have it working for the sharp rock and it is just a text based thing that says if you can or cannot craft a sharp rock but I think this will work. Fingers crossed, the .capx above has been updated with my most recent code.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Sat Apr 09, 2016 2:27 pm

Hmm.... I missed this post last week or maybe I could have given you some ideas. Good job working on it and figuring it out on your own though!

I might be able to help you simplify it if you are interested. Here is a capx I put together based on your system.
https://www.dropbox.com/s/a5tp1k9f2s9e9 ... .capx?dl=0

The major improvement is that it is infinitely scale able by using loops - it does not matter how many parts there are to any recipe. Also you will never refer to any material/ingredient/item by name or any specific amount in the events, this keeps things flexible. Otherwise, you might end up creating an event for every recipe you have, which could be hundreds!

Also, I highly recommend using different tokens in your recipe book (, and |)! Then you can use nested tokenats and it will be much easier to wrap your head around.

Hopefully this will be of help to you, and you can figure out how to use it best for your own project and add features ect. I commented the capx, but let me know if you have any questions about how it works.
Mistakes were made.
B
52
S
26
G
111
Posts: 1,630
Reputation: 62,681

Post » Sat Apr 09, 2016 11:18 pm

This is freaking amazing, thank you so much for your help. What took me 68 events to accomplish you were able to do in 16 and really as you said your format is much more flexible.There is just no way I would have thought to do it this way even if I had gone back and refactored. It's awesome to see you even took parts of my idea with the tokenat and tokencount and re-purposed it in such a useful way. Love this community so much, ya'll always come through for me. Thank you so much again. I'll post again once I have an updated .capx working from your example.
Image
B
46
S
17
G
2
Posts: 201
Reputation: 4,526

Post » Sun Apr 10, 2016 1:30 am

I also suggest you populate your dictionary by importing (use AJAX) a text file (or .csv spreadsheet, or xml file) as a project file, instead of adding each dictionary key through the event sheet. Working with significant amounts of text in construct can be a pain! I usually use notepad just to keep it simple and quick. The newline expression can also be used as a token for tokenat, which is awesome.
Mistakes were made.
B
52
S
26
G
111
Posts: 1,630
Reputation: 62,681

Next

Return to How do I....?

Who is online

Users browsing this forum: JackTYGA and 16 guests