- Joined
- Jan 26, 2019
- Messages
- 90
I write the integer values like this:
1 (first) character indicates the length of this value, the remaining characters are the value itself.
Example: "123" = 4 Symbols
ASDF
A = length
S = 1
D = 2
F = 3
However, if the value doesn't exist/equals 0, it still takes up 1 character (the length character that means 0).
It turns out that if I store 100 empty values, that's 100 extra characters.
In other maps, for example in twrpg, if you have a lot of items, then the loading code will be long, but if there are no items, then the code is short, which means that empty values are not written into the code.
However, if I try not to write empty values into the code, then the following can happen when loading:
Saved gold = 0
Saved lumber = 123
Saved item in #1 slot = 5
At the time of loading, the system does not know that gold = 0 because the code is shorter and lacks the necessary characters, so it immediately reads the next value and puts it in first place. (she thinks that the first meaning is wood and not gold, because there is no information about gold)
Result:
Loaded gold = 123
Loaded lumber = 5
Loaded item in #1 slot = 0
This happens because the system reads the parameters in order.
I probably need to read the code in such a way that it knows where 0 is, but how will I know if I don't write 0 in the code?
I think there is some method, but at the moment I haven't been able to come up with one.
1 (first) character indicates the length of this value, the remaining characters are the value itself.
Example: "123" = 4 Symbols
ASDF
A = length
S = 1
D = 2
F = 3
However, if the value doesn't exist/equals 0, it still takes up 1 character (the length character that means 0).
It turns out that if I store 100 empty values, that's 100 extra characters.
In other maps, for example in twrpg, if you have a lot of items, then the loading code will be long, but if there are no items, then the code is short, which means that empty values are not written into the code.
However, if I try not to write empty values into the code, then the following can happen when loading:
Saved gold = 0
Saved lumber = 123
Saved item in #1 slot = 5
At the time of loading, the system does not know that gold = 0 because the code is shorter and lacks the necessary characters, so it immediately reads the next value and puts it in first place. (she thinks that the first meaning is wood and not gold, because there is no information about gold)
Result:
Loaded gold = 123
Loaded lumber = 5
Loaded item in #1 slot = 0
This happens because the system reads the parameters in order.
I probably need to read the code in such a way that it knows where 0 is, but how will I know if I don't write 0 in the code?
I think there is some method, but at the moment I haven't been able to come up with one.