Update time friends.
Well, it’s been another solid week of engine stuff so unfortunately there’s really nothing to show. 🙁 Instead of not putting out an article, I figure instead why don’t I explain exactly what I’m taking so much time doing, and why I need to re-code the item system in Samphi.
If you’re not into looking behind the scenes, then this update won’t be for you I’m afraid. Feel free to pop back next week! For those interested, let’s get started.
The following changes are required of items, and are the reasons behind the re-write. I’ll address each in turn:
- Ability to deal with multiple item stacks
- Ability to save items in chests
- Ability to load custom item names/descriptions
- Moving items from string IDs to numeric IDs
The first problem we’ll look at is with item stacks. To accommodate chests, and other future plans, Samphi needs to be able to deal with multiple stacks of the same item. Currently, all item data is stored in a single list that looks something like this:
The amount of each item is tracked by the game, not the icons, so that means if you create two icons for the same item they can’t have independent amounts. For example, if you have one stack of apples in a chest, and another on your hot bar, each time you collect an apple they will both go up, and both show the same amount.
This is the biggest issue with items as this list system is heavily used in most areas of the game code. It was silly to set the game up like this in the first place, but if everyone knew everything right off-the-bat we’d all be professionals. What I’m currently doing is moving away from this main list and instead store quantities in each icon.
The second issue that needs addressing is changing the way the game saves/loads items. Currently all item data belongs to the player, and is stored in player data files. That means you can’t really store items in a chest. With the current system, if you created a chest in a world, then used that world with a new character, the items wouldn’t be in the chest. Not very useful.
To fix this, the game needs to save items that the player currently has equipt in the player data, and save items in chests to the world save file. This isn’t really a bad job, and shouldn’t take much time.
This one’s also not a big issue but goes along with the icon re-write. Currently, icons’ names and descriptions are hard coded. That means in the actual object itself in code I set these values myself. In order to support multiple languages freely, this value needs to be set externally.
I’ve moved items to loading their data from an external ‘.sam’ (my extension that’s functionally the same as .txt) file based on what language is currently selected. A system like this means it’s very easy to add more languages, and allows users to configure their own descriptions and names for items should you wish to do so. When the next update comes out there will be support for English, Italian, Turkish and Spanish. 🙂
This one is very programmy and won’t result in any changed functionality. Very simply, icons are currently distinguished by their name. So, I know the apple item is an apple because its name is ‘apple’. This isn’t ideal for a number of boring reasons, so I’m moving over to a numerical id, so I’ll know the apple icon is an apple because it will have an ID of 1.
Once all of these things has been done Samphi will have a MUCH more stable and flexible item system. We’ll be able to have multiple item stacks, chests, customizable names and descriptions etc. It sucks because it means that periods go where the game doesn’t seem to change, but hopefully this post illustrates some of things that are happening under the hood. 🙂
Next update there’ll hopefully be something to show from this boring engine work! Maybe get multiple item stacks running, then getting those other smaller jobs complete.
Either way, I’m making good progress with this work, so be it in the next update or the one after, I can see the end of tunnel and dev can get back to adding game content!
Hope you all have a great weekend, and if you have any questions drop me a comment!
As always you can show your support and keep up to date with development by following me here: