Uploading text files with your game

The Pixie
There is a function GetFileData that will open and read a text file. It works fine offline, but what happens when you put your game on-line? How do you upload your text files to the Quest site?

Pertex
This only works with files within your published .quest-file. I wish it would be possible to load and write files on other servers that easy

The Pixie
So how do you include files in your .quest file?

Alex
Pertex wrote:I wish it would be possible to load and write files on other servers that easy


You can use JavaScript to get or post data via an AJAX call.

Pertex
The Pixie wrote:So how do you include files in your .quest file?


choose 'publish' in the Tools menu of the editor and quest copys the game file and all ressource files from the game directory into the .quest file. Vou can't change the quest file at runtime.

Alex wrote:You can use JavaScript to get or post data via an AJAX call.


That's possible, but not that easy. I had several problems with it. There seems to be a sort of caching. After you have added a new entry to it loading a file a second time returns the old values . And the chrome/javascript engine doesn't allow access to files on other servers.

The Pixie
Pertex wrote:choose 'publish' in the Tools menu of the editor and quest copys the game file and all ressource files from the game directory into the .quest file. Vou can't change the quest file at runtime.

That is what I tried originally, but the files were not there. Is there some mechanism to tell quest which to include? Or are certain file types not included? Presumably it works for sound and images okay.

Alex
Only certain file extensions are included.

See https://quest.codeplex.com/SourceContro ... ackager.cs

It adds these: *.jpg;*.jpeg;*.png;*.gif;*.js;*.wav;*.mp3;*.htm;*.html

Looks like you should be able to manually add extra files by setting them as a resource in your ASLX (see http://quest5.net/wiki/Resource_element) although looking at that code, it seems that will only work if the resource element is defined in a library.

The Pixie
Presumably I can just rename a text file to whatever.html, and include that?

ETA: I have tested this, and naming a text file as whatever.html will get it included in your .quest package, and when you upload it, you can open it up with:

mystring = GetFileData ("whatever.html")

Silver
Alex wrote:Only certain file extensions are included.

See https://quest.codeplex.com/SourceContro ... ackager.cs

It adds these: *.jpg;*.jpeg;*.png;*.gif;*.js;*.wav;*.mp3;*.htm;*.html

Looks like you should be able to manually add extra files by setting them as a resource in your ASLX (see http://quest5.net/wiki/Resource_element) although looking at that code, it seems that will only work if the resource element is defined in a library.


Arghh, which means although vorbis makes multiple sounds viable in chromium, it won't work online because that extension isn't included but mp3 will work online but not with chromium. That's easily solved by including both files, as html5 will read down them until it finds a compatible one it can play, but it'll bump up the game file size somewhat.

Silver
Thinking on that means vorbis isn't supported at all If they're disregarded at the publish stage as anyone downloading the game to chromium won't have the files.

Which means I'll have to try incuding them as a resource which looks complicated.

Alex
As of Quest 5.6 you can update the publishfileextensions attribute on the game element to set which file extensions are included, so you can just add *.ogg to this.

Silver
I was literally just about to start creating a library and was coming back to this thread to find the link. :lol:

That sounds a lot easier. Cheers!

The Pixie
Alex wrote:As of Quest 5.6 you can update the publishfileextensions attribute on the game element to set which file extensions are included, so you can just add *.ogg to this.

That is good. But the default list does not include XML, which used to be included automatically,

The Pixie
Another rather important issue is that my game is now unable to access the included files. I had tried this in 5.5, using files with a .xml extension and they worked fine. Now in Quest 5.6, both .txt and .xml are included in thr package, once publishfileextensions is set accordingly, but GetFileData will no longer open the file:
Error running script: Error evaluating expression 'GetFileData(filename)': Cannot find a file called 'father.txt' in current 


If it is any help, this is the test game:
http://textadventures.co.uk/games/view/ ... or-a-train

Alex
XML files never used to be included automatically. You can see the change here - https://github.com/textadventures/quest ... d8d8b2b677. The default included file extensions are the same, with the addition of .svg.

If GetFileData is not working please log an issue, as it will get lost here otherwise.

Silver
So, in theory, adding filename extensions should also work with fonts?

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums