update
This commit is contained in:
1
file_write/README.md
Normal file
1
file_write/README.md
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/leenkx3d/leenkx/wiki/reference#write-json
|
||||
28
file_write/Sources/lnx/WriteFile.hx
Normal file
28
file_write/Sources/lnx/WriteFile.hx
Normal file
@ -0,0 +1,28 @@
|
||||
package lnx;
|
||||
|
||||
class WriteFile extends iron.Trait {
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
notifyOnInit(function() {
|
||||
|
||||
// File writing in Krom
|
||||
// To save data in HTML5, see file_storage example
|
||||
|
||||
#if kha_krom
|
||||
// Data to save
|
||||
var o = { test: "Hello" };
|
||||
var s = haxe.Json.stringify(o);
|
||||
|
||||
// Save file into game build folder
|
||||
// Playing from Blender the file will be saved at
|
||||
// file_write/build_file/debug/krom/my_file.json
|
||||
var path = Krom.getFilesLocation() + "/my_file.json";
|
||||
|
||||
// Write file
|
||||
var bytes = haxe.io.Bytes.ofString(s);
|
||||
Krom.fileSaveBytes(path, bytes.getData());
|
||||
#end
|
||||
});
|
||||
}
|
||||
}
|
||||
BIN
file_write/file_write.blend
Normal file
BIN
file_write/file_write.blend
Normal file
Binary file not shown.
Reference in New Issue
Block a user