function modTick is a hook that plays anything under this hook every 1/20 second, also known as, a tick
20 ticks is equal to one second
Example:
In this case you are going to explode inside 5 seconds.
//variables (name doesnt matter)
counter = true;//makes the count, well count
count = 0;//tick starts with 0
//hook function
function modTick() {//modTick
if(counter == true) {//if the value of counter is true
count++;//adds the count value 20 per second
if(count == 100) {//100 = 5 seconds. It means any code below this will trigger when count reaches 100(5 seconds)
explode(Player.getX(),Player.getY(),Player.getZ(),3);//Player explodes, Radius is 3
}
}
And so far that is it. Youcan change the ticks per second by:
ModPE.setGameSpeed(ticks);//replace ticks with a number
function modTick is a hook that plays anything under this hook every 1/20 second, also known as, a tick
20 ticks is equal to one second
Example:
In this case you are going to explode inside 5 seconds.
//variables (name doesnt matter)
counter = true;//makes the count, well count
count = 0;//tick starts with 0
//hook function
function modTick() {//modTick
if(counter == true) {//if the value of counter is true
count++;//adds the count value 20 per second
if(count == 100) {//100 = 5 seconds. It means any code below this will trigger when count reaches 100(5 seconds)
explode(Player.getX(),Player.getY(),Player.getZ(),3);//Player explodes, Radius is 3
}
}
And so far that is it. Youcan change the ticks per second by:
ModPE.setGameSpeed(ticks);//replace ticks with a number
thx a lot,its work!,but i need more info about modpe.savedata,my custom mob is return to the old mob when i restarting enter the world,can you help that?
thx a lot,its work!,but i need more info about modpe.savedata,my custom mob is return to the old mob when i restarting enter the world,can you help that?
I would use ModPE.saveData(string, var);
and have it so that when you leave the game
function leaveGame() {
(i think)
it gets the health and age and then when you load a world
function selectLevelHook() {
you use ModPE.readData(string); and have it set the health and age back to that
since long,I dont understand how to create function modtick and ModPe.savedata and ModPe.readdata
so if you know,can you make examples for me?
please make with simple script,if not,give comments
thnx for helping
So here is my comment
function modTick is a hook that plays anything under this hook every 1/20 second, also known as, a tick
20 ticks is equal to one second
Example:
In this case you are going to explode inside 5 seconds.
//variables (name doesnt matter)
counter = true;//makes the count, well count
count = 0;//tick starts with 0
//hook function
function modTick() {//modTick
if(counter == true) {//if the value of counter is true
count++;//adds the count value 20 per second
if(count == 100) {//100 = 5 seconds. It means any code below this will trigger when count reaches 100(5 seconds)
explode(Player.getX(),Player.getY(),Player.getZ(),3);//Player explodes, Radius is 3
}
}
And so far that is it. Youcan change the ticks per second by:
ModPE.setGameSpeed(ticks);//replace ticks with a number
thx a lot,its work!,but i need more info about modpe.savedata,my custom mob is return to the old mob when i restarting enter the world,can you help that?
I would use ModPE.saveData(string, var);
and have it so that when you leave the game
function leaveGame() {(i think)it gets the health and age and then when you load a world
function selectLevelHook() {you use ModPE.readData(string); and have it set the health and age back to that
If this helps press the little +1 button.
Hope this helps!
~Matt