From 0.2x onwards, the way in which Samphi saves player item data is vastly different. I apologise about that, I tried to make it cross-compatible, but the new item needs more flexibility in how it stores data and the old system just can’t provide that.
I’ve always been open about people editing their save files. If you want to give yourself 1,000,000 of an item, you should be able to. This article will outline how the new item save data works, so you’ll be able to move over your old items, or give yourselves new ones whenever you want!
Here’s how the new save file for item data looks:
Looks like nonsense at first, but let’s go through it line-by-line.
Icon count is the number of items that the save file has to load. Pretty self-explanatory! This should simply match the number of icons you have data for.
From here things get a little more cryptic. Starting with the first character, the number at the start of the line is the index of the item. In programming we start counting from 0, so in the line above the 0 means it’s the first icon that the game will load.
All lines start with the index; the next character determines what type of data it is:
Item id. All items in Samphi have an index. In this case, the id is 37 so that’s a spade item. There is a lookup table at the end of this blog showing all id’s, and once the wiki is up and running fully you’ll be able to easily find them there also.
item quantity. This is simply the number of items in the stack.
Item position. This is which slot the icon belongs in. Be sure not to give 2 items the same item position as it will cause problems in the game.
Chest index*. This is which chest the item is in. So for example, if you had 2 chests in your level, and you wanted the item in the first you
0s = chest slot*. This is the slot index for which slot of the chest the item is in.
So that’s what all the values mean! The way Samphi loads data is by first reading that icon_count value, and then counting up from 0. So, remembering we start counting at 0 in programming, let’s say our icon_count value is 3. In this case, we’ll be reading items which start with 0, 1, and 2; three overall.
Practical examples are always best, so let’s look at one. Let’s work with the same data as before:
Here we have 2 items, one is a spade (37), and the other is an axe (4). Let’s assume we want to give ourselves 20 wood. First, we need to update our icon_count value as we now have one more item to load:
Now we need to add the details of our item. Remember, we already have 2 items here, and we’re adding our third, so all lines need to start with the number 2 as that’s going to be the third one loaded. .
We’ll start with what item we want and how many of it:
Now we need to choose its slot. Remember not to give two icons the same value here. We can see that our other items have the slots 1 and 2, so let’s stick it in slot 3:
I’m not going to show the chest slots, as I advise putting items in chests in the game. But if you do want to tinker, just remember that xC means chest index, and xS is the slot in that chest. For this example, I’m leaving them blank, but they still need to be there! We just use 0s.
Pulling all that together we get the following data:
That’s the save data. A little complex on face value, but actually not too bad. There are issues like having to ensure you use the correct slot value, but I plan on creating an editor for this type of thing later down the line. Same goes for level editing, I want to build a tool for it, so there’s no point in creating a robust editing system now when it will be rendered defunct down the line.
Hopefully, this will enable you to make changes to your data and potentially restore any lost item from moving between versions 0.1x and 0.2x! Thanks for reading and all feedback is welcome. Here’s the item lookup table as promised!