Note: I'm an experienced programmer. Sometimes I just need to get a foothold to start working.
I have a nephew and a brother who like to play pocket edition together, and I decided to host a server they could play on. First attempt was using PocketMine on my pc. I figure, what the hey, I can host craftbukkit just fine, why not pocket edition. NOPE. Uses up 2 cores and still runs pretty sluggishly. Scrapped that idea pretty quickly. Next up, I tried several emulators before realizing they were pretty inadequate as well. Finally just installed android on my CubieBoard2 (small arm7 computer like the Raspberry Pi) and started up Minecraft Pocket Edition. Seems to work nice and smooth. That is, until the 1G ram is used up, then it needs to quit and reload to save the changes. Ran into an issue where large portions of the world weren't saved and it crashed.
[tl;dr] I've needed to automate some of this so I don't have to swap over to my device any time I need to reboot and what not, so I'd like to try generating an Administrator Toolkit mod to do this from another device. Few issues I'm seeing. Firstly, I see procCmd(string cmd) can be used when something is typed out on the chat, but I can't get which entity sent it, meaning any commands I set would be accessible to all users (unless I'm misunderstanding, and it's only the server that can type these, which is equally problematic). Also, reading ModPE.leaveGame(); there are notes saying that nothing a tick later will be executed, meaning I can't tell it to re-load the level?
Simple Example Script:
var AdminID = null;
var waitTicks = 0;
function procCmd(command) {
var args = command.split(" ");
if(args[0] == "shutdown") {
clientMessage("Server going down in 5s");
waitTicks = 5*20;
} else if (args[0] == "time") {
if (args.length == 2) {
if (args[1] == "day")
Level.setTime(1000);
else
Level.setTime(parseInt(args[1]));
} else {
clientMessage("Usage: time [day|(0-24000)]");
}
} else if (args[0] == "mode") {
if (args.length == 2) {
if (args[1] == "1")
Level.setGameMode(0);
else if (args[1] == "2")
Level.setGameMode(1);
else
clientMessage("Usage: mode [0|1]");
} else {
clientMessage("Usage: mode [0|1]");
}
}
}
function modTick() {
Player.setHealth(10);
if (waitTicks > 0) {
waitTicks--;
if (waitTicks == 0)
ModPE.leaveGame();
}
}
Code snippets are preferred. Links to Pocket Edition 10.5 protocols (so I can design my own server software) would be acceptable. Links to alternative server solutions is also acceptable. Preferred usage is BlockLauncher scripting, but alternative solutions will be researched.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Note: I'm an experienced programmer. Sometimes I just need to get a foothold to start working.
I have a nephew and a brother who like to play pocket edition together, and I decided to host a server they could play on. First attempt was using PocketMine on my pc. I figure, what the hey, I can host craftbukkit just fine, why not pocket edition. NOPE. Uses up 2 cores and still runs pretty sluggishly. Scrapped that idea pretty quickly. Next up, I tried several emulators before realizing they were pretty inadequate as well. Finally just installed android on my CubieBoard2 (small arm7 computer like the Raspberry Pi) and started up Minecraft Pocket Edition. Seems to work nice and smooth. That is, until the 1G ram is used up, then it needs to quit and reload to save the changes. Ran into an issue where large portions of the world weren't saved and it crashed.
[tl;dr] I've needed to automate some of this so I don't have to swap over to my device any time I need to reboot and what not, so I'd like to try generating an Administrator Toolkit mod to do this from another device. Few issues I'm seeing. Firstly, I see procCmd(string cmd) can be used when something is typed out on the chat, but I can't get which entity sent it, meaning any commands I set would be accessible to all users (unless I'm misunderstanding, and it's only the server that can type these, which is equally problematic). Also, reading ModPE.leaveGame(); there are notes saying that nothing a tick later will be executed, meaning I can't tell it to re-load the level?
Simple Example Script:
var AdminID = null;
var waitTicks = 0;
function procCmd(command) {
var args = command.split(" ");
if(args[0] == "shutdown") {
clientMessage("Server going down in 5s");
waitTicks = 5*20;
} else if (args[0] == "time") {
if (args.length == 2) {
if (args[1] == "day")
Level.setTime(1000);
else
Level.setTime(parseInt(args[1]));
} else {
clientMessage("Usage: time [day|(0-24000)]");
}
} else if (args[0] == "mode") {
if (args.length == 2) {
if (args[1] == "1")
Level.setGameMode(0);
else if (args[1] == "2")
Level.setGameMode(1);
else
clientMessage("Usage: mode [0|1]");
} else {
clientMessage("Usage: mode [0|1]");
}
}
}
function modTick() {
Player.setHealth(10);
if (waitTicks > 0) {
waitTicks--;
if (waitTicks == 0)
ModPE.leaveGame();
}
}
Code snippets are preferred. Links to Pocket Edition 10.5 protocols (so I can design my own server software) would be acceptable. Links to alternative server solutions is also acceptable. Preferred usage is BlockLauncher scripting, but alternative solutions will be researched.