Hellow i was just wandering if anyone could help me i am trying to make a mod in Modpe and i was wandering if this was the correct syntax for a command and to give the player STONE
function modTick() {
function procCmd(command) {
var cmd = command.split(" ");
var grab1 = "grab stone";
if(cmd[0] == grab1) {
function Player.addItemInventory(1, 64, 0);
}
}
}
function procCmd(command) {
var cmd = command.split(" ");
if(cmd[0] == "grab" && cmd[1]=="stone") {
Player.addItemInventory(1, 64, 0);
}
}
And more shorter...
function procCmd(command) {
if(command=="grab stone") {
function Player.addItemInventory(1, 64, 0);
}
}
The template for the function splittet the command, so that it can be use as parameter. But if you don´t need it as parameter you can just use it as the last.
If you use the way with .split() the command will be splitted at each (space) and puttet into an array, so (for example) "random sentence" would be splitted into "random" and "sentence", and you use them as cmd[0] for the first and cmd[1] for the second (and so on...)
If you have problems understanding all this you should use my last way. It don´t splits the command and you can use it easier (advanced Mods use the .split(), but better use what you understand and you maybe don´t need it for the Mod you are making).
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hellow i was just wandering if anyone could help me i am trying to make a mod in Modpe and i was wandering if this was the correct syntax for a command and to give the player STONE
function modTick() {
function procCmd(command) {
var cmd = command.split(" ");
var grab1 = "grab stone";
if(cmd[0] == grab1) {
function Player.addItemInventory(1, 64, 0);
}
}
}
It should be correct all you need to do is /grab stone and it should work.
I just took the Minecraft Noob test! Check out what I scored. Think you can beat me?!
To take the test, check out
http://minecraftnoobtest.com/test.php
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumNo, false:
A hook can not be in another hook, so procCmd() can´t be in modTick().
You write the "function" only before hooks.
Do it so:
function procCmd(command) {
var cmd = command.split(" ");
var grab1 = "grab";
var grab2 = "stone";
if(cmd[0] == grab1 && cmd[1] == grab2) {
Player.addItemInventory(1, 64, 0);
}
}
You can make it shorter:
function procCmd(command) {
var cmd = command.split(" ");
if(cmd[0] == "grab" && cmd[1]=="stone") {
Player.addItemInventory(1, 64, 0);
}
}
And more shorter...
function procCmd(command) {
if(command=="grab stone") {
function Player.addItemInventory(1, 64, 0);
}
}
The template for the function splittet the command, so that it can be use as parameter. But if you don´t need it as parameter you can just use it as the last.
If you use the way with .split() the command will be splitted at each (space) and puttet into an array, so (for example) "random sentence" would be splitted into "random" and "sentence", and you use them as cmd[0] for the first and cmd[1] for the second (and so on...)
If you have problems understanding all this you should use my last way. It don´t splits the command and you can use it easier (advanced Mods use the .split(), but better use what you understand and you maybe don´t need it for the Mod you are making).