External Data Extension [2.0.0]

LIBERADO

  • *
  • Posts: 2720
If you don't need to use them later in the game, it would probably be better to save them in a different place. Perhaps a set of blocks should be put together for file IO.
Yes, that would be perfect. But if that is not possible, I think that using the "extras" folder is better than not having the save image feature.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

ETHproductions

  • *
  • Posts: 430
@Mineat: For which platform are you building? I'm not sure, but it may work differently depending on the platform....

@LIBERADO: OK, I'll leave it as is. My experiments of alternate ways of getting the images aren't going well anyway. I'll also make sure all of the saving blocks have the option to save to a relative path (e.g. inside the extras folder), or an absolute path (e.g. C:/Users/...).

@Justin: That's what I'm working on at this very moment! :)
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

LIBERADO

  • *
  • Posts: 2720
@LIBERADO: OK, I'll leave it as is. My experiments of alternate ways of getting the images aren't going well anyway. I'll also make sure all of the saving blocks have the option to save to a relative path (e.g. inside the extras folder), or an absolute path (e.g. C:/Users/...).
Thank you very much!
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

Mineat

  • Posts: 376
@ETH: All. I tried to build it in flash to try your workarounds, though.

Justin

  • *
  • Posts: 4716
Merged off-topic posts from Attribute Saving extension.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

ETHproductions

  • *
  • Posts: 430
Today I realized that, while the File IO is useful for coding this extension, it really has enough features that it deserves its own extension. So I'm changing gears and starting a new extension that will be completely dedicated to the File IO. I have added in a couple of blocks for saving files in this extension; I believe they'll be useful here.

@Mineat: If you'd like, you could send me your game file via PM so I can investigate.

@Justin: Thanks for moving the posts!
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

LIBERADO

  • *
  • Posts: 2720
... So I'm changing gears and starting a new extension that will be completely dedicated to the File IO.
:) This sounds very interesting.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

id8games

  • Posts: 205
2 quick questions:
Does this extension and the upcoming File I/O extension work with txt files when the game is running on a mobile device? Is it safe to assume that when the game is compiled for mobile, any files in the "extras" folder are wrapped into the app?

Mineat

  • Posts: 376
Feel free to keep and edit the game, as long as you credit the authors who made the engine extensions. I wanted to make something crucial to my upcoming reboot of the Munchers series that would serve as an external benefactor for other learning games.

ETHproductions

  • *
  • Posts: 430
1. Does this extension and the upcoming File I/O extension work with .txt files when the game is running on a mobile device?
2. Is it safe to assume that when the game is compiled for mobile, any files in the "extras" folder are wrapped into the app?

1. All of the text blocks should work correctly on Mobile. However, I'm not sure about the 'save text' block. If you're willing, would you please test the extension on a mobile device, and tell me how it goes?
2. As far as I know, it's completely safe. :) Check out this post about using the extras folder.

Feel free to keep and edit the game, as long as you credit the authors who made the engine extensions.

Remember, one of those authors was me. ;) I don't think I'll keep developing the game, but I'll make a sample quiz game using the External Data and Attribute Saving extensions.
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

thiagojabur

  • Posts: 48
I do not think it will work on mobile, at least not on Android(but the devs can tell better). As far as I can tell, the default setup for Android apps do not set <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />, so, you're not allowed to write either on the device (because your app is actually compressed/packed) nor the SD card. Also, you need to get the context, which is pointed out by  Joshua Granick here (check his post from  January 24, 2014 at 7:43 AM)

http://www.openfl.org/archive/community/programming-haxe/how-create-folders-write-files-android/

I'm trying to write files on Android, if I get any progress I will post it here.

Justin

  • *
  • Posts: 4716
We already have a section in Stencyl's game settings for adding haxeflags to the project.xml file. We ought to have a way of directly adding on to the project.xml file, so that you can use the line Joshua Granick gave.

Code: [Select]
<android permission="android.permission.WRITE_EXTERNAL_STORAGE" />
For now, that can actually be hacked in by modifying your AndroidManifest.xml, but that would need to be done again each time you update Stencyl.

Stencyl\plaf\haxe\lib\lime\lime\legacy\templates\android\template\AndroidManifest.xml

Add <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> underneath this line:
<uses-permission android:name="::__current__::" />::end::::end::
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

thiagojabur

  • Posts: 48
We already have a section in Stencyl's game settings for adding haxeflags to the project.xml file. We ought to have a way of directly adding on to the project.xml file, so that you can use the line Joshua Granick gave.

Code: [Select]
<android permission="android.permission.WRITE_EXTERNAL_STORAGE" />
For now, that can actually be hacked in by modifying your AndroidManifest.xml, but that would need to be done again each time you update Stencyl.

Stencyl\plaf\haxe\lib\lime\lime\legacy\templates\android\template\AndroidManifest.xml

Add <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> underneath this line:
<uses-permission android:name="::__current__::" />::end::::end::

Well, you were faster than me, but yeah, thats the way. Also, managed to create directories and save stuff on Android, as Joshua pointed out, you need to get the context. Here are some snippets:

Code: [Select]
if (!FileSystem.exists(SystemPath.userDirectory + "/data")) {
FileSystem.createDirectory(SystemPath.userDirectory + "/data");
}

That will create a folder named data for your stuff. You can create on the root too, your call. To be sure where those files are being saved, you can use an alert to print the path. Now, for actually saving stuff

Code: [Select]
File.write(SystemPath.userDirectory + "/data/blorg.xml", false);
File.saveContent(SystemPath.userDirectory+ "/data/blorg.xml", "potato");

Where you can replace "potato" for any string you want to save. Tested on a Galaxy Tab and it works :)

ETHproductions

  • *
  • Posts: 430
Good to hear, thiagojabur! I'll update the extension using this code. I currently can't test on a mobile device, so would it be alright if PM you when it's ready for testing?

Just for clarification, the files from /stencylworks/games/your_game /extras are stored in the compiled game in the folder /assets/data, at least on Flash/Desktop. Is this the case on Android as well?

Also, would you be able to figure it out for iOS? :)
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Tebbo

  • *
  • Posts: 48
I'm still a total neophyte but this kind of extension is so useful for so many different kinds of games.
Thank you for your contribution to the community!