Developer postOriginal post (opens in a new tab)

Early Access Update 41 – Re-coding & opening the crafting system

Happy Friday amigos. We made it. The week is over and it’s time to relax. Well, not for me, but hopefully for you. :D We’re dipping our toes back into more of a technical post this time! I like to throw these in occasionally. There’s a big problem with the way the crafting system works and I’ve decided it’s time to tackle it. Let’s take a look at how and why.

Short answer: I wrote it years ago, and it’s the LEAST scalable system you could imagine. To add an item, I need to add it to ~5 scripts, make sure data structures line up because they’re horrible duplicated, blah, blah, blah. It’s awful, and adding new items is not only a pain in the ass but highly prone to bugs. It needs re-writing and once re-written you’ll be able to customize item recipes through a simple file.

Long answer: I’ll try keep this brief …

I’ve mentioned before that Samphi was the first real programming I ever did. I wanted to learn to make games so I picked up GameMaker and learned the drag and drop stuff. 5 years later here we are with the same project. Cool, but it means the project contains some awful software design decisions.

The crafting data in Samphi is ALL OVER the place. There’s bits of structures here, bits of data there … it’s just a royal mess. All recipes are also hardcoded so the only way they can be changed is if I edit the games actual code. I don’t like this. It’s way too inflexible so I’m implementing a new flexible system that makes use of JSON.

I won’t go into what JSON is, but it’s a cool way of storing data essentially. Instead of Samphi’s recipes been stored scattered all over the codebase, they are going to be loaded from a single configuration file on game start that is open to editing just like anything else. Here’s an example of the file I’m currently using to test the system:

This is the crafting JSON for the arrow item. We can see it gives the name at the top, the list of ingredients, and how many are made each time. This file is going to be totally open so if you want to edit these values and balance the game how you feel is right then you can! Not happy with how many sticks are crafted at a time? Double it!

This system is early but is coming along great. There’s still a few problems to solve, but initial testing looks good!

There’s always a balance between adding new content and re-factoring old systems. You guys have all purchased the game so I feel a big pressure to get fresh content to you, but on the flip side when there is a system like this that’s so broken at its core the old phrase ‘A stitch in time saves nine’ comes into play. You can only sweep these issues under the carpet for so long. COULD I continue adding new items with the janky system? Yes, but the longer that goes on the more bugs will pop up and the more of a job it’ll be when we eventually take the inevitable plunge to fix the system.

When you’re in a team, this is less of an issue. You can delegate, having some programmers maintain old systems while a different team will work on new tools. Well, unless my cat Frank starts programming we’re on our own. :D That’s why the change, and that’s why now.

Onto something a little more visual before I sign off. I’ve been using the following image in my last few updates:

You will probably notice that my house has different coloured blocks for its roof. That’s currently the result of Photoshop, but not for much longer. I’ve always wanted multiple trees in Samphi, and now the Oak tree has been re-designed I’m starting on the pine tree. Here’s a work-in-progress shot:

I’m not super keen on what I have so far, but it’s a start! Having two types of wood adds all kinds of variety the crafting system and I’m looking forward to getting it in the game!

A big part of my work will be continuing my work on the crafting system’s underlying structure. Past that there will be continued work on the tree and I’ll see if I can fit anything else in. Like last week I’m not going to be making any promises as it’s deadline time so time is even tighter than normal!

Sorry this updates a bit boring. It happens when I’m working on technical stuff, but you can’t build a good house without solid foundation and every so often I like to sure them up. :)

Thanks for reading and enjoy your weekend! See you back here same time next week. Ciao. :)

As always you can show your support and keep up to date with development by following me here:

Visit my websites
Greeny Games Website
Samphi Website

Follow me on Twitter
Greeny Games Twitter
Samphi Twitter