Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Ikkerens on June 15, 2010, 03:43:30 pm

Title: String/int merging
Post by: Ikkerens on June 15, 2010, 03:43:30 pm
Hey, my first topic :D

Anyway, im trying to use external levels for my upcoming game.
So far I managed to make the tilemap editor and store the map in AppVars.
The game currently has the ability to load 1 level.

But im trying to merge an integer into a string, so that the level loading is dynamic.

However, I don't know how. Already tried this:
Code: [Select]
1->L
"vSpLvl0"+L->Str0

But, I was unsuccesful.
Any ideas?

Thanks in advance,
Ikkerens
Title: Re: String/int merging
Post by: Quigibo on June 15, 2010, 04:25:51 pm
Try this:
Code: [Select]
1->L
"vSpLvl00"->Str0
L+'0'->{Str0+7}

Should load levels from 00-09.  If you need more, you have to replace the first digit also.
Title: Re: String/int merging
Post by: Ikkerens on June 15, 2010, 04:29:35 pm
Could you clarify that line for me please?
I don't really see what you're doing right there.
Thanks.
Title: Re: String/int merging
Post by: Quigibo on June 15, 2010, 04:36:55 pm
The string is in memory somewhere in the program.  So all we need to do is right before we load the levels, change one letter from a 0 to a 1 for instance.  That would be the 8th byte of that string which is a +7 offset from the start.

Since these are ascii characters in the string and not actually numbers, we have to convert the number L from a number to an ascii character.  Since the ascii characters are in order, we can just start at the character '0' and then add the offset to find the character.
Title: Re: String/int merging
Post by: Ikkerens on June 15, 2010, 05:00:00 pm
Ah, I see.
Thanks once again.