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 / app not loading text file when started outside IDE

Author
Message
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2015 12:27
I have a text file where I store my array in the media folder of the app. If I do some changes to this text file and run the program from the Ide, my function reads in the new information I have added to it. But if shut down agk, make som alterations to the text file and start my app outside the Ide, it won't read in the new information.

Whats happening here?

Tim
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Nov 2015 12:39
if you save the data from agk the file is in appdata folder.
i guess u started the ide as admin and the normal exe in other user context?

app/media is a template and if the file exists in appdata it will used.
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Nov 2015 12:40 Edited at: 3rd Nov 2015 12:41
When your app saves the file, it saves it to its own app-data sandbox folder (counter-intuitively, it doesn't over-write the original in your media folder). When reading the file back again, it will check there first by default, so any manual changes to the original will get ignored unless you delete the one created by your app. The location of the saved file depends on platform.

[edit] Markus beat me to it!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2015 12:47
I edit the file outside of agk. I never save to it from my app. I only read from it.

I am on a mac.

So Markus, what you are saying is that when my app is compiled it packs the textile inside the app? That makes sense. Is there a way to force my app to read the file from the same folder as the app?

Tim
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Nov 2015 13:01
Have you looked to see if the text file is in the /Users/MyUsername/Library/Application (or wherever they are put on MAC these days)?
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2015 13:10 Edited at: 3rd Nov 2015 13:13
It´s not. The media folder is packed inside the .app file when compiled. Thats the difference between mac and windows. So the text file is in there. Thats why the app is reading the file from there and not in the media folder in the project folder.
What I need to do now is to force the finished compiled app to read from a textfile outside itself....
I tried to use set folder() but my app hangs...
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Nov 2015 13:47
Try saving the text file to the sandbox folder. AppGameKit will try to read it from there first. If it can't find it, it will use the one in the media.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2015 13:50
Where is the sandbox folder on mac?
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Nov 2015 14:18
I think it is /Users/MyUsername/Library/Application (find your app name)

V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Nov 2015 14:38 Edited at: 3rd Nov 2015 14:39
ah ok me thought you are using a pc.
i guess the logic at mac it similar than a pc.
ex: hiscore:
load "hiscore.txt" (default if not exist)
save "hiscore.txt"
load "hiscore.txt" (using the saved file in user folder)
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2015 15:31 Edited at: 3rd Nov 2015 16:26
Markus and Cjb
I solved it!

It seems that for some reason I am allowed to edit the file in the app package itself.
To others that need to do the same as me - here is my scenario:

I have made a game editor for my game outside of agk. It is made in Livecode. The reason is that its much faster to set up buttons, fields and working with text in livecode. I smacked it up in a week. This game editor creates an array for my game and stores it to a text file. What I do then is to build the "player" of my game in AppGameKit - Because AppGameKit is much better to make a game with. Then I import the text file from my editor into the AppGameKit app.

My problem initially was that my AppGameKit app didn't read this text file on the mac, because agk packs all the media files into to app itself when it´s built. What I found out is that I am able to store the array text file from my game editor inside the agk.app by using the following file path :"/users/myusername/AGK Projects/MyAGKappProjectfolder/MyAGKapp.App/Contents/Resources/media/myarray.txt"

The key here is that the "MyAGKapp.app" that agk produces is actually a folder. This is also true of every other ".app" files on the mac. Its usually not advised to write into the application, but since Im the developer, I am the boss.

BUT, if it was possible to create a folder for the agk app under "application support" that the application will use - like other apps in the mac system - then I will be glad if anyone could tell me how.

Tim
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Nov 2015 17:02
Nice! Glad you got it sorted. This information should be documented somewhere (I suspect it probably is) as very useful to know. I'll keep this in mind for when I eventually get my Apple dev licence sorted. Thanks!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2015 17:46 Edited at: 3rd Nov 2015 17:54
I need to update this because I finally found the sandbox folder that CJB talked about. It´s in a weird location, deep inside the folder system of the mac. I found it when i used the " getwritePath()" function in agk,
This was the result:

"/Users/myusername/Library/Containers/com.thegamecreators.AGKTestAppMacOS/Data/Library/Application Support/AGK Player/media"

Now, That´s a mouthful !

When I put my text file in this folder my agk app would read from this file every time, even if I changed the file inside the app. So this folder is top priority when your agk app searches for the files you want it to load.
This location is so utterly hard to remember, so i deleted the file and went for my last solution of writing into the app.
What a mess.

Cheers

Tim
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Nov 2015 18:27 Edited at: 3rd Nov 2015 18:28
what said the string GetDocumentsPath() at mac,
maybe its a better location for testing your created data from ide and "exe".

me also mislike this much copys of ressources because navigations to sub sub sub folders.
buts today common that the ide make copys for os targets / debug or release versions and .net can make folders for every version...
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Nov 2015 18:35
Quote: "/Users/myusername/Library/Containers/com.thegamecreators.AGKTestAppMacOS/Data/Library/Application Support"

It sucks, but the path is generated by the OS for us, and due to sandboxing rules is the only place the app is allowed to write. If the app isn't sandboxed then you have more freedom to where you can write, but then I'm not sure if you can put it on the AppStore.
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2015 19:39 Edited at: 3rd Nov 2015 19:42
Markus,
GetDocumentsPath() gave me : "/Users/myusername/Library/Containers/com.thegamecreators.AGKTestAppMacOS/Data/Documents"

But neither "setRawWritePath()" or "setFolder()" makes the program use the folder I want.

Paul,
No problem. This is only under development not in the final app. My "level editor" is not made in Agk. When I have made changes to a level i have a button in the editor that runs my AppGameKit app, that again loads the file.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Nov 2015 20:14
ohh, not a better path.
seems you need a Alias / Link for your save folder
AGK (Steam) V2 Beta .. : Windows 10 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-11-17 00:58:09
Your offset time is: 2024-11-17 00:58:09