Out of my Crafting Comfort Zone

10
Official Construct Team Post
Laura_D's avatar
Laura_D
  • 28 Aug, 2020
  • 482 words
  • ~2-3 mins
  • 1,197 visits
  • 1 favourites

Hey guys, it's Friday and that means it's blog time! I'm still on the crafting theme this week, and thanks to Kyatric, real progress has been made!

So, let's step back a bit. Earlier this week I made the fatal mistake of answering a thread in the forums. This reminded me that actually I know NOTHING. But, what this did do was introduce a new direction for the crafting tests I was doing. And by introduced I mean forced me to look at things that I wasn't ready for.

The idea was it would be good to access data that was more deeply nested within a JSON so you could store crafting recipes and the amount of an item you need to craft something. I started off trying to combine my inventory structure of arrays and dictionaries with the click-controlled crafting I'd put together. Which on the surface was a great idea, but I couldn't quite pull the data from the JSON I needed.

Thankfully, Kyatric is FAR better with Construct than I – he has been using it a lot longer! And he stepped in to create a system that worked. And he did goooood.

So, the project uses an array and dictionary to track what items the player has, a JSON file to store item data and recipes, plus a few extra arrays for the recipe validation steps. When you click on an item, it assigns it to an ingredient slot and registers it in the crafting array. When you've got the items you want to use you can click the green button to start crafting – like last week's project.

When you decide to start crafting, the check function loops through the JSON to determine which ingredients are needed in a recipe and uses a secondary array to check how many loops are needed. It'll then also check in the dictionary to see if the player has enough of a selected ingredient to craft.

If you meet the requirements then the result slot will change to show the new item and the dictionary will update to add the new item. It also resets all the crafting slots and the crafting arrays so you can start again. You can also click the red button to clear everything.

That's a very brief overview of the project, if you want to know more about it, it's worth looking at the project itself. I will do my best to expand it a bit and make an example version and a tutorial to go with it, but this may take a bit of time as I continue to wrap my head around it all!

Subscribe

Get emailed when there are new posts!

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!