coolwhip 0 Report post Posted December 10, 2017 loading a text file in phaser with typescript is trival with a simple: this.game.load.text("reference", "url") however attempting to write or modify external text files appears to be way more complicated. I'm guessing this is for security reasons, but still don't see why there can't be a "game.write.text()" method or something similar? Quote Share this post Link to post Share on other sites
Odk 5 Report post Posted December 10, 2017 Not sure what would be your use case? When you publish your game "url" will be remote http server. In theory you could write a method that will send HTTP POST or PUT request to server and then server will write (if you program it to do so) the content to file. But once your game will have more than one player it will probably lead to data corruption. Better say what you want to achieve and then maybe someone will be able to point you toward proper solution. Quote Share this post Link to post Share on other sites
Fenopiù 4 Report post Posted December 11, 2017 If you have your data in an array you could do it in that way: let textarray = ["text1", "text2", "text3"]; let txtContent = "data:text/csv;charset=utf-8,"; textarray.forEach(function (rowArray) { let row = rowArray.join(","); txtContent += row + "\r\n"; }); let encodedUri = encodeURI(txtContent); let link = document.createElement("a"); link.setAttribute("href", encodedUri); link.setAttribute("download", "my_data.csv"); document.body.appendChild(link); // Firefox link.click(); Quote Share this post Link to post Share on other sites
Refeuh 6 Report post Posted December 12, 2017 Does it have to be an external file ? Standard behaviour would be to rely on the local storage for persistence of application-specific data. Quote Share this post Link to post Share on other sites
Fenopiù 4 Report post Posted December 12, 2017 Yes, you can edit the code to upload instead of download the file ;-) Quote Share this post Link to post Share on other sites
HMR's 0 Report post Posted July 13, 2018 I'm new to Nodejs, Can you tell me how can i give the path to download the file to a specific location? Quote Share this post Link to post Share on other sites