fortaat wrote:
Why do you want a 12 digit code? It's much easier to use python to create a txt file that will print all variables. It's also very easy to import it.
It's also even easier still to use multi-persistent data, but I guess the one advantage of a 12-digit code is that you can write it down and use it on another computer without having to copy digital files around.
The problem with a 12-digit code is that it's very, very limiting as to how much information it can store. Also, you will need to use Python, it's not something you can feasibly do just in Ren'Py-script.
Off the top of my head, I would go with reducing the information you want to transfer to the absolute minimum set, representable in the smallest, most-simple data types possible. That is, prefer boolean (True/False) values to integers (whole numbers), prefer integers to numbers with a fractional part, prefer numbers of any kind to strings of text... meaning that the player's name is the least-convenient thing to store in such a code.
Once you've represented the data in the smallest form possible, you can string that together into a known sequence of bits (1s or 0s) and assemble them into bytes (sequences of 8 1s or 0s), which you can then transcode into characters using - for example - a
base-64 encoding such as
MIME. There will be readily-available libraries for such things in Python already. The MIME-encoded string which you produce is the code which you can give to the player to pass their data around.
One big question is why you need to encode the user's name in the code? If you're just trying to prevent the player passing codes to his friends it won't necessarily work, because they only have to tell their friends what name to use to decode the string successfully as well. Not to mention that if you're making the script easy enough for casual programmers to follow and edit, those same casual programmers will be able to work out what they need to change to 'hack' a code to accept whatever name they choose. Not to mention that if you fix the length of the code (if it absolutely has to be twelve characters every time, for example) then you'll also have to limit the length of the player's name - even if you reduce it as much as possible (allow only capital letters, say), it's only possible to store 14 characters of text data in a 12-character base-64-encoded code.
(Not including the name means you have so much more information-space for actual game data, of course. And means that people don't get punished for forgetting exactly how they spelled the name they typed into the first game.)