Encoding files?

Non-platform specific questions.

Encoding files?

Postby SuperSonic » Tue Dec 06, 2011 12:28 am

Hey everyone. I was wondering how I can encode a file using GE script. To be more specific, I want a bit of code that will open a file and then read each character. For each character it reads, it will add a certain number to it's ID and store the result in an array. So for example, it would take the string "abc" and turn it into "def". See what I mean? :D

I promise to give points to anyone who can solve the problem. Thank you :P

Sonic
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Encoding files?

Postby tintran » Tue Dec 06, 2011 2:43 am

file "abc.c" contains
abc
last line of file here.

output
def odvw#olqh#ri#iloh#khuh1

is that right?
Edit: removed .zip with missing data folder.
Last edited by tintran on Tue Dec 06, 2011 4:11 am, edited 1 time in total.
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Encoding files?

Postby SuperSonic » Tue Dec 06, 2011 3:25 am

Thanks but could you upload the data folder with the ttf? :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Encoding files?

Postby tintran » Tue Dec 06, 2011 4:10 am

whoops,
here it is
Attachments
readfile.zip
(19.86 KiB) Downloaded 98 times
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Encoding files?

Postby SuperSonic » Tue Dec 06, 2011 1:44 pm

Thanks. I'll check it out :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Encoding files?

Postby SuperSonic » Tue Dec 06, 2011 2:04 pm

Great, it works just fine. +1 :wink:

However, I'm a complete newb when it comes to file Input/Output so could you answer a few questions for me? :roll:
So even though the code works, I have no clue what all of the functions mean. Could you explain them to me?
If I wanted to overwrite the abc.c file, what code should I use?
I will have to decode the file as well so what code should I use for that?
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Encoding files?

Postby SuperSonic » Tue Dec 06, 2011 6:32 pm

I wrote:If I wanted to overwrite the abc.c file, what code should I use?

Actually, I think I figured that part out myself but could you still answer the other two questions I had? :)
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Encoding files?

Postby tintran » Tue Dec 06, 2011 7:36 pm

here's some additional code for writing to file
and an extra function called codeString (which encodes and decodes depending on the id you pass it)
each line of code is commented
Attachments
readwritefile.zip
(21.13 KiB) Downloaded 103 times
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Encoding files?

Postby SuperSonic » Tue Dec 06, 2011 7:58 pm

Thanks dude. This is perfect :D

Another +1 :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Encoding files?

Postby tintran » Tue Dec 06, 2011 8:13 pm

i have 10 points , yes! :D
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score

Re: Encoding files?

Postby SuperSonic » Tue Dec 06, 2011 8:31 pm

tintran wrote:i have 10 points , yes! :D

:P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest