Saving Files on different locations (Saving text to them comes later on)
For this, we will need some variables to show the mod, where these files are.
var SDCARD = android.os.Environment.getExternalStorageDirectory();
var First_Folder = new java.io.File(SDCARD, "/testFolder/anotherFolder/");
var Second_folder = new java.io.File(First_Folder, Level.getWorldDir());
var Test_File = new java.io.File(Second_Folder, "testfile.json");
What this does:var IDK = ... You have to make a new variable for every folder/file.android.os.Environment.getExternalStorageDirectory() stands for the location of the external Storage new java.io.File() with this you say to the mod: Hey, there is a new file/folder SDCARD, "/testFolder/anotherFolder/" you show, that a file/folder is at a location inside of "SDCARD". In this case the new folder is "anotherFolder" SDCARD is the name of a variable "/testFolder/anotherFolder/" this is the new location of a file/folder Level.getWorldDir() this gives you the foldername of the worldfolder (cool sentence!) "testfile.json" this is the name of a file
Next you have to say the mod, that it should make these files/folders, when they don't exist. Otherwise, it will give you an error.
if(!Test_File.exists()){
Test_File.mkdirs();
}
What this does:! it looks for the boolean after it and says the difference then (it turns true to false and false to true)Test_File.exists() it gives you a boolean that is true, when there is this specified file, and a false, when there isn't such a file Test_File.mkdirs() it creates the file and every parent directory, that is missing
Hello guys!
I am ThexXTURBOXx and this are my Minecraft PE Modding Tutorials.
I am German, so sorry for my bad English.
I have modded 2 years for PC and since 3 years I am modding MCPE mods (but only for my own YET).
In this tutorials I will show you things about MCPE Modding, that you won't find very often in the internet.
I will edit this "first post", when I add something
What you have to know BEFORE
My tutorials about "Making Basic Mods",
Know JavaScript pretty well
And here are my tutorials!
var SDCARD = android.os.Environment.getExternalStorageDirectory();
var First_Folder = new java.io.File(SDCARD, "/testFolder/anotherFolder/");
var Second_folder = new java.io.File(First_Folder, Level.getWorldDir());
var Test_File = new java.io.File(Second_Folder, "testfile.json");
new java.io.File() with this you say to the mod: Hey, there is a new file/folder
SDCARD, "/testFolder/anotherFolder/" you show, that a file/folder is at a location inside of "SDCARD". In this case the new folder is "anotherFolder"
SDCARD is the name of a variable
"/testFolder/anotherFolder/" this is the new location of a file/folder
Level.getWorldDir() this gives you the foldername of the worldfolder (cool sentence!)
"testfile.json" this is the name of a file
if(!Test_File.exists()){
Test_File.mkdirs();
}
Test_File.mkdirs() it creates the file and every parent directory, that is missing
Looking for testers, translators and sounds for
Wait, why would the file be .json?
The heck is this for
You should be able to make a txt, too. I choose the format JSON, because I know that it works (haven't even texted txt )
Looking for testers, translators and sounds for