Is there a script in modpe so that it brings our username and uses it. For e.g if you tap a stick on the ground it will say "(Your Name) Welcome"
Rollback Post to RevisionRollBack
Make sure you follow me on twitter! @DarkDiaMiner IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Unfortunately no, but it is possible with pocketmine so it seems possible in ModPE (Its @player BTW)
Oh because when i tried out the modpe script Supergamer when i went inside the game it said "Welcome, Darkdiamondminer!"
Rollback Post to RevisionRollBack
Make sure you follow me on twitter! @DarkDiaMiner IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Yup, it said "Welcome, SuperGamer, Darkdiamondminer"
Rollback Post to RevisionRollBack
Make sure you follow me on twitter! @DarkDiaMiner IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
It is possible, thanks to the ability to read files from SD Card. Lemme give a second to find it.
EDIT:
var sdcard = android.os.Environment.getExternalStorageDirectory();
var directory = new File(sdcard.getAbsolutePath() + "/games/com.mojang");
var minecraftpe = new java.io.File(directory + "/minecraftpe/");
var userName = new java.io.File(minecraftpe, "options.txt");
var br = new java.io.BufferedReader(new FileReader(userName));
var s = br.readLine();
var line = s.split(":");
function getUsername(){
if((s = br.readLine()) != null){
return line[1];
}
br.close();
}
Ok Thanks! you helped me a lot!I dont really understand the code. can you put explanations?
Rollback Post to RevisionRollBack
Make sure you follow me on twitter! @DarkDiaMiner IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Yes i noticed that already. But all i need is to understand the script so i can add that to my mod. (with permission of course)
Rollback Post to RevisionRollBack
Make sure you follow me on twitter! @DarkDiaMiner IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Technically, that's not Java, but ModPEScript calling Java programs.
Rhino, the scripting engine used to interpret ModPE Scripts, has a function that lets you access Java classes from ModPE Script. So the syntax is still ModPE script (e.g. variables are still var), but you can access stuff from the Java side.
(I really should make an official way of getting options)
Technically, that's not Java, but ModPEScript calling Java programs.
Rhino, the scripting engine used to interpret ModPE Scripts, has a function that lets you access Java classes from ModPE Script. So the syntax is still ModPE script (e.g. variables are still var), but you can access stuff from the Java side.
(I really should make an official way of getting options)
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
var sdcard = android.os.Environment.getExternalStorageDirectory();
// This variable, sdcard, is the path of the sdcard directory. For most devices it is /mnt/sdcard
var directory = new File(sdcard.getAbsolutePath() + "/games/com.mojang");
// MrARM you didnt import File, so it should be new java.io.File()
// directory is the /sdcard/games/com.mojang directory, where mcpe config and worlds are saved
var minecraftpe = new java.io.File(directory + "/minecraftpe/");
// This is the settings directory containing settings and clientId(random, for LAN multiplayer, you might find these numbers in the /worldname/players directory) TXT files
var userName = new java.io.File(minecraftpe, "options.txt");
//this variable is options.txt file
//MrARM you are giving an extremely misleading var nane...
// If you just want to get the settings file, you can skip all these annoymous lines and just do:
var optionsFile=new java.io.File(android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/minecraftpe","options.txt");
//then... idk what he is doing because line and br and s aren't global variables / fields
//So I skip it. Read mine instead below:
/*
var br = new java.io.BufferedReader(new FileReader(userName));
var s = br.readLine();
var line = s.split(":");
function getUsername(){
if((s = br.readLine()) != null){
return line[1];
*/
// MrARM meant to read the options.txt file into a string, so...
var bReader= new java.io.BufferedReader(new java.io.FileReader(optionsFile));
//this creates a reader that reads the file. Don't be misled by the word Buffered - it only matters when the text is 8196+ chars.
var line=bReader.readLine();
// The readLine() function reads the first line in the file. If you call it again, it returns the second line, vice versa, and null when the document ends. Here, username is normally located at the first line, if the client did nothing naughty about it.
var username=line.split(":")[1];
// splits the line into pieces at ":". The second piece, i.e. [1], is normally the username. So finally we get the username.
bReader.close():
// dont ask, just do it.
}
Challenge 1: can you get them all in one line?
Challenge 2: Some players have the character : in their username. Then, the piece from : on. Can you use the for loop and the function username.substring() to achieve it?
Answer for the challenges:
Answer for challenge 1:
var username=new java.io.BufferedReader(new java.io.FileReader(new java.io.File(android.os.Environment.getExternalStorage()/*.getAbsolutePath() is omitable because android/rhino/whatever converts it into string automatically*/+"/games/com.mojang/minecraftpe","options.txt"))).readLine().split(":")[1];
Answer for challenge 2:
Two methods:
1. Use for loop to find the offset of the first : and do line.substring(offsetA);
2. Find the offset yourself: line.substring(12).
var username=new java.io.BufferedReader(new java.io.FileReader(new java.io.File(android.os.Environment.getExternalStorage()+"/games/com.mojang/minecraftpe","options.txt"))).readLine().split(":")[1].substring(12);
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
var sdcard = android.os.Environment.getExternalStorageDirectory();
// This variable, sdcard, is the path of the sdcard directory. For most devices it is /mnt/sdcard
var directory = new File(sdcard.getAbsolutePath() + "/games/com.mojang");
// MrARM you didnt import File, so it should be new java.io.File()
// directory is the /sdcard/games/com.mojang directory, where mcpe config and worlds are saved
var minecraftpe = new java.io.File(directory + "/minecraftpe/");
// This is the settings directory containing settings and clientId(random, for LAN multiplayer, you might find these numbers in the /worldname/players directory) TXT files
var userName = new java.io.File(minecraftpe, "options.txt");
//this variable is options.txt file
//MrARM you are giving an extremely misleading var nane...
// If you just want to get the settings file, you can skip all these annoymous lines and just do:
var optionsFile=new java.io.File(android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/minecraftpe","options.txt");
//then... idk what he is doing because line and br and s aren't global variables / fields
//So I skip it. Read mine instead below:
/*
var br = new java.io.BufferedReader(new FileReader(userName));
var s = br.readLine();
var line = s.split(":");
function getUsername(){
if((s = br.readLine()) != null){
return line[1];
*/
// MrARM meant to read the options.txt file into a string, so...
var bReader= new java.io.BufferedReader(new java.io.FileReader(optionsFile));
//this creates a reader that reads the file. Don't be misled by the word Buffered - it only matters when the text is 8196+ chars.
var line=bReader.readLine();
// The readLine() function reads the first line in the file. If you call it again, it returns the second line, vice versa, and null when the document ends. Here, username is normally located at the first line, if the client did nothing naughty about it.
var username=line.split(":")[1];
// splits the line into pieces at ":". The second piece, i.e. [1], is normally the username. So finally we get the username.
bReader.close():
// dont ask, just do it.
}
Challenge 1: can you get them all in one line?
Challenge 2: Some players have the character : in their username. Then, the piece from : on. Can you use the for loop and the function username.substring() to achieve it?
Answer for the challenges:
Answer for challenge 1:
var username=new java.io.BufferedReader(new java.io.FileReader(new java.io.File(android.os.Environment.getExternalStorage()/*.getAbsolutePath() is omitable because android/rhino/whatever converts it into string automatically*/+"/games/com.mojang/minecraftpe","options.txt"))).readLine().split(":")[1];
Answer for challenge 2:
Two methods:
1. Use for loop to find the offset of the first : and do line.substring(offsetA);
2. Find the offset yourself: line.substring(12).
var username=new java.io.BufferedReader(new java.io.FileReader(new java.io.File(android.os.Environment.getExternalStorage()+"/games/com.mojang/minecraftpe","options.txt"))).readLine().split(":")[1].substring(12);
Edit again: yes read() reads a single character but readLine() reads the file content until meeting the characters \n, \r, \r\n or end or document.
First of all, those were my variables from supergamer
I am implementing it back now. It was there before but I recoded and forgot to add the welcome message back.
All it does is it reads the options.txt file. Yoy can find really easy tutorials on reading files on YouTube. I do recommend learning java first before starting making mods using the Java bridge that is implemented in Rhino.
IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Oh because when i tried out the modpe script Supergamer when i went inside the game it said "Welcome, Darkdiamondminer!"
IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Ok Thanks! you helped me a lot!I dont really understand the code. can you put explanations?
IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
I think thats java
IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Lol Go Learn Java then.
ModPE!?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumTechnically, that's not Java, but ModPEScript calling Java programs.
Rhino, the scripting engine used to interpret ModPE Scripts, has a function that lets you access Java classes from ModPE Script. So the syntax is still ModPE script (e.g. variables are still var), but you can access stuff from the Java side.
(I really should make an official way of getting options)
Isnt Javascript modpe?
var sdcard = android.os.Environment.getExternalStorageDirectory(); // This variable, sdcard, is the path of the sdcard directory. For most devices it is /mnt/sdcard var directory = new File(sdcard.getAbsolutePath() + "/games/com.mojang"); // MrARM you didnt import File, so it should be new java.io.File() // directory is the /sdcard/games/com.mojang directory, where mcpe config and worlds are saved var minecraftpe = new java.io.File(directory + "/minecraftpe/"); // This is the settings directory containing settings and clientId(random, for LAN multiplayer, you might find these numbers in the /worldname/players directory) TXT files var userName = new java.io.File(minecraftpe, "options.txt"); //this variable is options.txt file //MrARM you are giving an extremely misleading var nane... // If you just want to get the settings file, you can skip all these annoymous lines and just do: var optionsFile=new java.io.File(android.os.Environment.getExternalStorageDirectory()+"/games/com.mojang/minecraftpe","options.txt"); //then... idk what he is doing because line and br and s aren't global variables / fields //So I skip it. Read mine instead below: /* var br = new java.io.BufferedReader(new FileReader(userName)); var s = br.readLine(); var line = s.split(":"); function getUsername(){ if((s = br.readLine()) != null){ return line[1]; */ // MrARM meant to read the options.txt file into a string, so... var bReader= new java.io.BufferedReader(new java.io.FileReader(optionsFile)); //this creates a reader that reads the file. Don't be misled by the word Buffered - it only matters when the text is 8196+ chars. var line=bReader.readLine(); // The readLine() function reads the first line in the file. If you call it again, it returns the second line, vice versa, and null when the document ends. Here, username is normally located at the first line, if the client did nothing naughty about it. var username=line.split(":")[1]; // splits the line into pieces at ":". The second piece, i.e. [1], is normally the username. So finally we get the username. bReader.close(): // dont ask, just do it. }Challenge 1: can you get them all in one line?
Challenge 2: Some players have the character : in their username. Then, the piece from : on. Can you use the for loop and the function username.substring() to achieve it?
Answer for the challenges:
var username=new java.io.BufferedReader(new java.io.FileReader(new java.io.File(android.os.Environment.getExternalStorage()/*.getAbsolutePath() is omitable because android/rhino/whatever converts it into string automatically*/+"/games/com.mojang/minecraftpe","options.txt"))).readLine().split(":")[1];Two methods:
1. Use for loop to find the offset of the first : and do line.substring(offsetA);
2. Find the offset yourself: line.substring(12).
var username=new java.io.BufferedReader(new java.io.FileReader(new java.io.File(android.os.Environment.getExternalStorage()+"/games/com.mojang/minecraftpe","options.txt"))).readLine().split(":")[1].substring(12);Edit again: yes read() reads a single character but readLine() reads the file content until meeting the characters \n, \r, \r\n or end or document.
First of all, those were my variables from supergamer
I am implementing it back now. It was there before but I recoded and forgot to add the welcome message back.
All it does is it reads the options.txt file. Yoy can find really easy tutorials on reading files on YouTube. I do recommend learning java first before starting making mods using the Java bridge that is implemented in Rhino.
java.io*