I was thinking about making a game, where its possible for a user to generate a custom save code, that could then be later used to load the game. The game data would be stored in a list. By doing this, I want to make an example list of {1,3,14,2} turn into 201031402. The way I plan to load the data is the following:
Input "Code:",Str1
expr(sub(Str1,1,1→N
DelVar L₁(length(Str1)-1)/N→dim(L₁
For(E,0,dim(L₁)-1
expr(sub(Str1,2+EN,N→L₁(E+1
End
L₁
If you want to download the code to turn the data into a list to see how it works, click here
The problem I am having is in actually creating the number. I presume the code would use routines from the number one-liners, and would do something like this:
Use the Number of Digits in Nonzero Integer routine to determine the longest data point. Store this to String 1
For, each of the data points in the list:
Determine the length of that point
Determine how many 0's need to be concatenated to make this the same length as the longest data point
Append that many 0's onto String 1
Append the Data point onto string 1
End
I am just having trouble making the function generate the save code. I know it will use the Number-To-String routine, and the routine for determining the Number of Digits in Nonzero Integer. If anyone would be able to help make the function that would turn the string into code, it would be helpful.