I gave gdevelop a command to write a string of text to a text file:
So these two can successfully write to the file and read from it. However the file is always empty
So it does not write to the file that I am telling it to write to at all. Playing the game moves the data to god know where and there is no way for me to figure out what gdevelop is exactly writing to the file (how)
Btw I am doing this to see what syntax gdevelop uses to structure the data in the text file. There seems to be no documentation on that at the wiki.
You need to load the file in memory, then write in it, and finally commit your changes by closing/unload it.
And btw, write/read from file might not work if you use it for dialog purpose in a web project.
For example : my dialogs are written in a text file, but all accuentated characters are messed up when I read them and show them in my html5 game. In that case, my dialogs must be written directly into the events.
Do they get messed up only when you host the game on a server?
Are you using non latin characters for the dialogue?
This might be an encoding issue. Perhaps maybe submit a bug report about it.
I am sorry, but it still doesnt actually write to a file on my file system. Can somebody please share an example file, where gdevelop writes to and reads from a text file on the file system (not memory) -for a html5 game!
In HTML5 games, GD saves-in and reads-from the browser cache, I think. Maybe you could debug your file system in native platform, when everything is OK return to the HTML5 platform
âfileâ in the sentence of the action is misleading but thatâs because these actions were originally meant for the native platform :
-With native platform, real (XML) files are written.
-With HTML5 platform, there is no way to write on the file system. Still, to be able to save data like hi score, I used WebStorage (en.wikipedia.org/wiki/Web_storage) to simulate files.
So your âfilesâ are written properly, but not as real files but as JSON stored inside the browser. Thatâs a limitation of HTML5 (but make sense when you think about it, itâs just harder to understand because when youâre testing your game you make no distinction between your machine and the fake server created by GD and used to serve the game).
No way, in the extensions window, right click over Native platform ==> Use this platform, then you can preview your game with the native and browser modes (use the little arrow below the Preview button), let us know if this doesnât work
I tried that, still no luck Gdevelop just doesnt show the option to play it as a native when I enable native as a platform. This is possibly another bug.
Can you guys just share with me an example project where gdevelop html5 game gets a number of different text strings from an external text file. I just want to see how a text file is structured (root/group/itemâ>contents) in order to use it for a story type game experiment.
The wiki page doesnt seem to have any data on the subject/
GD needs to know if the value saved is a number or a string, you know, to convert it correctly
About âtexteâ instead âtextâ, is it really a problem? I mean, the idea is to write and read from GD, at least I donât write the text structure myself, itâs painful and unnecessary (and you can bug your data). If the values saved to the file are fixed (because it seems that you want to write them yourself)⌠why donât use strucures?
By the way, it seems that you just need to change âtexteâ by âtextâ(or whatever you want) in the lines 263, 330 and 333 from this file: FileTools.cpp
Anyway I think that having some french words in the program is a nice detail, they are there since the origin of the software, words as âtexteâ, âouiâ, âafficherâ, etc. are over all the code (where people that just use the software donât notice), I donât know if 4ian is planning to change it someday, but I think itâs nice and weird, just beautiful
The idea is to use an external text file to store the gameâs story dialogue (npc speech). This way it is easy to edit it, easy to change it, easy to translate it.
I think that there should be something in the wiki about this - especially if the file itself needs to use specific french words in its syntax - you gotta include it in the softwareâs documentation how such file is structured. A tutorial of sorts would be nice. A lot of people like to have story driven games. Those games rely heavily on a lot of text to communicate to the user. In order to write a good, reliable NPC/dialogue system you need to have the engine access data that is stored in a convenient way that doesnt rely on the engine to be edited.
If xml files are not the best way to go about this with gdevelop, then what is? How would you implement that?
Can you load a json file from your hard disk instead? Are those more manageable and easier to write/read?
Thanks in the advance for the advice.
Also how about this:
If the text has quotes (=âthis is a stringâ) - the engine thinks its a string. If it doesnt (=66) - then its a value.
The less repetative writing you gotta do in an xml file, the better.
Anyways, best type of file I found so far to store this kind of stuff seems to be CSV tables. I already made a feature suggestion for gdevelop to load and interpret CSV tables: viewtopic.php?f=22&t=6235
Why csv tables? They require the least amount of typing for telling the engine when to use what avatar , sound effect and show text. Instead of typing over and over again âavatar=johnâ for each line john says - you just simply have a column called avatar and you type John in the cells that correspond to the ID of the dialogue line that is running.
It is the most convenient way so far. Less typing than jason for this sort of job.
The csv file is a simple text file - it can contain the data of multiple tables - so it is sort of like a 3d array in a text file with the ability to get to cells by calling them via their row/column names- that opens the opportunity for some very cool scripting that arrays can not do. It is awesome!
Thatâs what I was talking about earlier: as long as you use english characters, all is fine. But use ĂŠ or è or ĂŻ or any accentued characters, and the html5 export f*ck it up. Itâs an issue within GD, where the project file is in UTF-8 and the generated js files are in Unicode (or something like that), while your txt files are in whatever encoding you use.
I donât think you can resolve it at your level.
The best way to do this is to hardcode your dialogs into an external event.
Then, use a variable to get the right text.
Ex:
If showDialog > 0 then
if showDialog == 1 then put âbleh bleh blehâ in text variable myCurrentDialog
if showDialog == 2 then put âbloo bloo blooâ in text variable myCurrentDialog
etc.
showDialog = 0 //exit the external event
end if
That way, you can use myCurrentDialog in any way you want.
Then, for translation purpose, you can encapsulate the firt âif then end ifâ into another if.
Ex :
if myCurrentLanguage == 0 then end if//english text
if myCurrentLanguage == 1 then end if //french translation of the english text
etc.
Notice this will generate lots of copy/paste.
Meaning you better be sure of your dialog system before translating it.
Or you will have lots of corrections to make for every tinkering.
Ok, now this would be useful if I could load up an spreadsheet file exported as an XML file from another application.
There is however a problem in the way gdevelop reads these values!
To get to a value , it is using this:
<test1 texte="this is a dialogue 1" />
However values in most XML files, in open office and gnumeric exported tables look like this:
<table:table table:name="Sheet1" table:style-name="ta1">
<table:table-column table:style-name="co1" table:number-columns-repeated="2" table:default-cell-style-name="Default"/>
<table:table-row table:style-name="ro1">
<table:table-cell office:value-type="string" calcext:value-type="string">
<text:p>This is dialogue1</text:p>
with
<text:p>This is dialogue1</text:p>
being the final value I want gdevelop to read!
How do I tell gdevelop to read a group name as a value?
With gnumeric I get this:
<Cells>
<Cell Row="0" Col="1" ValueType="60">words</Cell>
<Cell Row="0" Col="2" ValueType="60">avatars</Cell>
<Cell Row="1" Col="1" ValueType="60">Hi I am george</Cell>
<Cell Row="1" Col="2" ValueType="60">george</Cell>
<Cell Row="2" Col="1" ValueType="60">and I am wanda</Cell>
<Cell Row="2" Col="2" ValueType="60">wanda</Cell>
<Cell Row="3" Col="1" ValueType="60">tets </Cell>