Author Topic: String/int merging  (Read 6070 times)

0 Members and 2 Guests are viewing this topic.

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
String/int merging
« 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

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: String/int merging
« Reply #1 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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: String/int merging
« Reply #2 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.

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: String/int merging
« Reply #3 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.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: String/int merging
« Reply #4 on: June 15, 2010, 05:00:00 pm »
Ah, I see.
Thanks once again.

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...