External Data Extension
Recently I've been working on an extension that's able to get files from the 'extras' folder, such as described in
this topic. It's gone quite well; I even managed to add in a saving feature.
Features:- Get text from a file
- Modify that text
- Get a sound from a file
- Play an .swf file (on Flash)
- Save text files and .png images (on Desktop or Mobile)
All except the saving blocks work correctly on Flash; should be the same with HTML5. All except the SWF blocks work on Windows and Android, and it should be the same on everything else.
(If you can test it on Mac, Linux, or iOS, please tell me how it works!)Designed to work with Stencyl v3.4+. Some blocks may not work in older versions.
Download for 3.4+(
How to Install and Update an Extension)
(Legacy downloads:
3.1,
3.2,
3.3. Please note that these are no longer being maintained.)
(
View on GitHub)
If upgrading from the 3.3 version of the extension:1. Install the extension as usual. Note that it will not overwrite the 3.3 version, resulting in two versions of the extension in your folder.
2. For each game you want to upgrade:
a. Open the game.
b. In the Extensions settings, disable the "External Data 3.3" extension and enable the "External Data" extension.
c. Save and close the game.
DO NOT open any resources before closing. d. Reopen the game. It should now have successfully upgraded.
Instructions1. Download, install and enable the extension (link above).
2. Inside your game, press
Debug > View > View Folder for this Game, then open up the highlighted folder.
3. Create a new folder and name it
extras.
4. Place any necessary files inside this folder.
5. Use the blocks to get data from the files.
Using File PathsFile extensions work like this:
- For the
text from file,
save text,
append line, and
image from file blocks, you
must use the correct file extension (e.g.
.txt,
.png, etc.)
- For the
sound from file block, you
must not use a file extension. (The extension chooses
.mp3 or
.ogg automatically, depending on the platform.)
- For the
swf and
save image blocks, it doesn't matter.
- Any subfolders in the path (after
extras) must be included.
Examples:
.../extras/test.txt should be put into the
text block as
test.txt.../extras/subfolder/test.txt should be put into into the
text block as
subfolder/test.txt.../extras/preloader.swf can be put into into either
swf block as
preloader.swf, or just
preloader.../extras/image.png can be put into into the
save image block as
image.png, or just
image.../extras/sfx/jump1.mp3 and
.../extras/sfx/jump1.ogg should both be put into the
sound block as
sfx/jump1For future versions I plan to add the ability to manipulate files outside of the extras folder (perhaps outside of the game folder itself), but I have yet to determine how to implement this block-wise.
BlocksReturns the text from the inputted file. If it has multiple lines in it, it may need to be processed with the following block.
Splits the text into a list by putting each line of the file into a new item.
The inputted text will have line breaks added wherever there is a
\r in the text. For example,
Hello\rWorld! will result in:
Hello
World!Replaces each of the line breaks in the text with
\r. Useful for debugging purposes.
Removes any line breaks from the text.
Adds a new line of text to the text attribute.
Adds a line of text to the end of the file. Useful for generating logs.
Doesn't work on Flash or HTML5.Returns the text with preserved Unicode characters. This is a workaround of Stencyl's automatic Unicode-to-code-point conversion, which results in glyphs outside the
ASCII range encoding safely, but incorrectly.
Returns the line break character.
Draws a list onto the screen, item by item. The top left of the box it draws in is at the inputted x and y.
Prints a list out to the console, item by item.
Gets a sound from a .mp3 or .ogg file, depending on the platform. This block can be used just like any other sound block.
Plays an .swf file.
Only works on Flash. If you notice that it isn't playing in the correct position, or for the correct length of time, try using the other block.
NOTE: The first of these two blocks has been tested to the fullest of my ability, but I cannot confirm that it works perfectly. If you can use it with a newer SWF, please tell me how it works!
Saves a text file to the extras folder.
Doesn't work on Flash or HTML5.Saves an image (as a .png or a .jpg/.jpeg) to the extras folder.
Doesn't work on Flash or HTML5.
Version History2.0.0 (10/24/17)
- Updated for 3.4+
- Added "save as PNG/JPEG" block
1.6.1 (11/19/15)
Added beta HTML5 support
1.6 (08/27/15)
Added blocks:
- append line ___ to file: ___
- unicode text: ___
1.5.1 (07/14/15)
Bug fix: Missing subfolders are not taken into account when saving
1.5 (07/13/15)
Images that were saved after compilation can now be accessed
Added block: image from file (already existed in the palette, but had to be recoded to use a custom function)
1.4 (07/09/15)
Actually fixed the bug with saving and loading data on mobile
- Added in one missing slash
1.3.1 (06/06/15)
(Hopefully!) Fixed a bug with saving and loading data on mobile
1.3 (06/05/15)
Should now save data on mobile targets (NEEDS TESTING!)
1.2.2 (05/09/15)
Changed "text without line breaks" to "replace line break with \r in text"
Changed "text with added line breaks" to "replace \r with line break in text"
Added block: remove line breaks from text
1.2.1 (03/09/15)
Bug fix: Trying to retrieve non-existing file on Flash causes a null error
1.2 (03/08/15)
Added blocks:
- add line: _____ to ___
- save data ___ to file: ___
- save PNG ___ to file: ___
1.1 (03/05/15)
Added blocks:
- text with added line breaks
- text without line breaks
- print list
1.0.1 (03/03/15)
Added block:
- line break
1.0 - Initial public release (02/04/15)
Blocks:
- get text from file
- split text into lines
- draw list
- get sound from file
- play SWF/AVM1
If you have any questions, comments, or suggestions, feel free to post them below!
ETH