• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] Complicated String/Real Conversion

L

LeQuestionnaire

Guest
I'm trying to write a script that does, for example, the following:

Takes a string, perhaps it's ABCD, and returns the sum of the position of each individual character in the alphabet (e.g. A = 1), but with a twist. As the script runs through the string, adding the corresponding numerical value of each character to the total of all the ones before it, it will check to see if the character's position in the alphabet is less than that of the character who's position in the string is right in front of it, and if so, then subtract instead of add.

For example, what I'd return for the string "ABCD" is -2, because - 1 - 2 - 3 + 4 = -2. For the string "ACDB", I'd return 2 because - 1 - 3 + 4 + 2 = 2.

This would make for a pseudo-random number generator whose "random" number actually corresponds to the seed string, but I've been messing with this for ages and I just can't get it to work. Help?
 

jazzzar

Member
hello @LeQuestionnaire , here you need to check each character and check the next of it, i'll help you without the code, if you can't get it to work i might write the string for you, however you need to try and figure it yourself, make two variables, one called curr_char, and the other one next_char, now for the curr_char, you need to make a switch variable, to check if the char is a, b,c,d, .................,z, which is somehow long but can be easily done, now after you know the value of it, do the same thing for the next one, and check if the curr_char < next_char, if so multiply by -1, i believe this can be achieved in different ways, using ascii code can be used to, if you know how it works tho, try to get things a little bit working using what i said, best of luck for you :)

EDIT :
nevermind i decided to make the thing for you as i had some time on my hands, here it is :
Dropbox link

please take your time reading it, do it carefully and try to understand how it works, it's fairly simple, if you have ANY question feel free to ask here, or pm me, i'm really happy to help :)
 
Last edited:
Top