Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / HexToBase64() to string and string to original sequence of numbers?

Author
Message
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 24th Jan 2020 14:53
Hi everyone,

I'm using procedural generation for quite a few of my games and I am experimenting with setting a seed number, so I can have a seed of random numbers that will give the same level each time. My question is, how can I best convert a very long number to a string and more importantly how do I convert it back? I don't think AppGameKit Studio has a FromBase64String() command unfortunately?

Using HexToBase64(int) works for converting it to a string, but there is no command to convert it back again? Any suggestions on how to go about this or should I just write my own encoding / decoding?

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Jan 2020 21:11
integer Val( str, base )
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 24th Jan 2020 22:13
What exactly should 'base' be?? Is it the length of the string, the original integer length or something else entirely? Because any integer higher than 0 pretty much crashes it. And using 0 results in nothing being converted. Unless I'm missing something obvious, I'm stuck here.



blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Jan 2020 22:21
I know val(string, 16) will convert hex
I'm pretty sure val(string, 8) will convert octal and val(string, 2) will convert binary
I would say if your string doesn't conform to the base it would probably crash
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 24th Jan 2020 23:06
Yeah, that definitely makes it crash. I'm still a bit confused lol.

Converting to Hex and back works fine (haven't checked large strings). But I would ultimately want a player to input a seed value, like in games like Binding of Isaac. So people can play the 'same' level from a seed. Might have to just write my own converting of a random seed to a string of sorts though.

Login to post a reply

Server time is: 2024-04-26 08:35:12
Your offset time is: 2024-04-26 08:35:12