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 Classic Chat / Little lost on file commands

Author
Message
Doz
16
Years of Service
User Offline
Joined: 16th Apr 2008
Location:
Posted: 8th Sep 2011 06:34
So was hoping to get a little help, can't quite figure out how a text file should be set up to be able to read back from it. I'm hoping to store a bunch of coordinates for sprites and other level data, but right now I can't get it to read anything. Anyone have an example file to read from and some code that works? Thanks.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Sep 2011 06:45
Just load up the example read and write projects that come with AGK. That should get you started.

Doz
16
Years of Service
User Offline
Joined: 16th Apr 2008
Location:
Posted: 8th Sep 2011 08:11
Hmm, I just pulled those up but its not writing out the .txt file that it is supposed to, no errors that I can tell either.

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Sep 2011 09:37
Quote: "Hmm, I just pulled those up but its not writing out the .txt file that it is supposed to, no errors that I can tell either."

AGK has a default file writing folder which is located in Documents and it doesn't write to the project folder. So check your documents folder. It should be something like Documents - AppGameKit - some madly long folder name. AppGameKit does this because on some platforms like iOS there is only one place an app is permitted write files to.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Sep 2011 12:31 Edited at: 8th Sep 2011 12:32
As Hodgey says, AppGameKit puts the file where it must. It's kind of like the ID system for entities, where you don't know what the ID of the sprite is, and you don't care what the ID of the sprite is.

In your case, does it matter where the file is? Post some code so we can see what might be the problem.

If you want to know where AppGameKit is writing to and reading from, you can us GetWritePath().

Here's an example based on the one that comes with AGK.



The filepath is really long, probably so long that it would run off the right side of the screen, so I broke it up into separate strings. It's sloppy, but it will show you where your files are going. The last part is so long that you may need to set your screen to a landscape type resolution (640, 480) to see it.

Doz
16
Years of Service
User Offline
Joined: 16th Apr 2008
Location:
Posted: 8th Sep 2011 18:01
Ah, I thought I had read somewhere that it would write out to the media folder, I'll have to look at that other directory when I get off work. Thanks again.

Doz
16
Years of Service
User Offline
Joined: 16th Apr 2008
Location:
Posted: 9th Sep 2011 03:06
Ok, so after playing around with this for a bit, I realize the issue I had understanding it. It is not actually writing out ascii values to the file. I had hoped to use a csv file or something as the source of the data but it looks like that will not work like I planned. Thanks both of you for the help.

Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 9th Sep 2011 03:21
Oh, hey, what you want is ReadLine instead of ReadString, it will read in each line as text.

Doz
16
Years of Service
User Offline
Joined: 16th Apr 2008
Location:
Posted: 9th Sep 2011 03:39
Well, that doesn't really do what I was after easily either. This works, and actually solves the issue of putting some slight tamper protection on the level/score data. I just made a helper program now to write out the data file to use, vs exporting it from a spreadsheet.

Login to post a reply

Server time is: 2024-04-20 13:52:39
Your offset time is: 2024-04-20 13:52:39