I'm in need of help creating a save and read method. I'm working on an update for my friend mod which will be adding in quests. The whole quest script works exactly how it should but when you exit the game my save method fails and you have to start the quests all over again. Could somebody please help me with this?
I'm in need of help creating a save and read method. I'm working on an update for my friend mod which will be adding in quests. The whole quest script works exactly how it should but when you exit the game my save method fails and you have to start the quests all over again. Could somebody please help me with this?[/header]
[header=3]There are two ways how to do:[/header]
[header=3]1. ModPe.saveData...:[/header]
[header=3]I´m not sure at the first[/header]
[header=3]----script start----[/header]
var text;
var name;
//All these functions-methods you need just once.
//To save more texts just change the name (name = "1"; name = "2").
function savetext{
ModPE.saveData(name) = text;
}
function loadtext{
text = ModPE.readData(name);
}
[header=3]----script end----[/header]
[header=3]2. With a text file:[/header]
[header=3]----script start----[/header]
-
View User Profile
-
View Posts
-
Send Message
Curse Premium[header=3]There are two ways how to do:[/header]
[header=3]1. ModPe.saveData...:[/header]
[header=3]I´m not sure at the first[/header]
[header=3]----script start----[/header]
function savetext{function loadtext{[header=3]----script end----[/header]
[header=3]2. With a text file:[/header] [header=3]----script start----[/header]
function newLevel() {path = android.os.Environment.getExternalStorageDirectory().getPath() + "/games/com.mojang/minecraftWorlds/" + Level.getWorldDir() + "/";
}
function save{function loadtext{text = content.split(";")[0];text2 = content.split(";")[1];text3 = content.split(";")[2];function save(path, filename, content) {try {
java.io.File(path).mkdirs();
var newFile = new java.io.File(path, filename);
newFile.createNewFile();
var outWrite = new java.io.OutputStreamWriter(new java.io.FileOutputStream(newFile));
outWrite.append(content);
outWrite.close();
} catch(err) {
clientMessage(err);
}
}
function load(path, filename) {var content = "";if (java.io.File(path + filename).exists()) {
var file = new java.io.File(path + filename),
fos = new java.io.FileInputStream(file),
str = new java.lang.StringBuilder(),
ch;
while ((ch = fos.read()) != -1) {str.append(java.lang.Character(ch)); }
content = String(str.toString());
fos.close();
}
return content;
}
[header=3]----script end----
I hope this helps
Thanks for this help but I need some more help. How do I use it?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHere is an exmple for the .txt version:
http://www.minecraftforum.net/forums/minecraft-pocket-edition/mcpe-mods-tools/mcpe-mod-tool-help-requests/2325998-saving-a-txt-at-a-modpe-script-javascript-on