ModPE Script function useItem(x,y,z,itemId,blockId,side) { if(itemId == 267) { bl_spawnMob(x, y, z, 32, image); //Can spawn any mob(peaceful or hostile)that is given as param mobid. ; } }
Thats one that doesn't work !!!!!! Please idk why lol ( need to spawn a mob )
function getTile(x,y,z); // Idk
Need help with threse
_ _ _ _ _ _ _- function setVelX(ent, amount); function setVelY(ent, amount); function setVelZ(ent, amount); _ _ _ _ _ _ _-_
function explode(x, y, z, radius); // Explodes blocks
function addItemInventory(id, amount);
function rideAnimal(player, target);
function getCarriedItem();
function preventDefault(); // Prevents hittng something from doing an attack function and or i think it can prevent u from taking damage
function setTile(x,y,z,type); // Sets a block to a different block right ?
I want to do
function useItem(x,y,z,itemId,blockId,side) { if(itemId == 267) { preventDefault()
Ok so that's whats i need help with Not really so much of what thet do but how i can use it !!
There's a site called hackpad where u can add code and edit it ! anybody can add ! It's really cool !! Just go here ---> https://modpe.hackpa...ipt-ideKsiF9dru ---> That way u can easily understand and see how u made code ! ALL IN REAL TIME !!
Basically, getTile() returns a number corresponding to the ID of the block at that location. So, for example, if you have a TNT block at location x = 11, y = 22, z = 33:
getTile(11, 22, 33);
should give you 46, which is the data value of TNT.
But of course, just getting the number without using it is kinda useless, so what if you did something based on whether it's equal to something?
if (getTile(11, 22, 33) == 46) {
clientMessage("There's TNT at that location");
}
If the number returned by getTile is equal to 46, then call the method clientMessage to display the string "There's TNT at that location".
But wait! What if we don't just want to check that location? Maybe we can check the block that the player clicked.
the ModPE framework calls your code with a few variables (where numbers are stored - you use them where you would usually use a number).
function useItem(x,y,z,itemId,blockId,side) {
if (blockId == 1 && getTile (x, y+1, z) == 1) {
clientMessage("You have two stone blocks.");
}
}
Note that variables are used there - so now you see why your script doesn't work.
function useItem(x,y,z,itemId,blockId,side) {
if(itemId == 267) { //if the itemId variable (which ModPE sets to the item the player holds) is equal to 267
bl_spawnMob(x, y, z, 32, image); //spawn mob at location x, y, z, with ID 32 (Zombie) and the texture name contained in the variable image
}
}
As you see, we don't actually have a variable called image - which is why it's erroring out. Remember that, with clientMessage, we made literal strings (text that isn't in a variable) by surrounding the text in quotes. So, if we want a zombie wearing the player skin, which is mob/char.png, let's call it with a literal string saying "mob/char.png".
function useItem(x,y,z,itemId,blockId,side) {
if(itemId == 267) { //if the itemId variable (which ModPE
// sets to the item the player holds) is equal to 267
bl_spawnMob(x, y, z, 32, "mob/char.png"); //spawn mob at location x, y, z
// with ID 32 (Zombie) and the texture name "mob/char.png"
}
}
(By the way: anything after the // are comments and are ignored by the computer; they are just helpful notes)
(Another by-the-way: anything beginning with bl_ is BlockLauncher-only, so they won't work on iOS. I hope you are on Android: if so, ANDROID ROCKS! WHOO!)
function useItem(x,y,z,itemId,blockId,side) {
if(itemId == 267) {
bl_spawnMob(x, y, z, 32, image); //Can spawn any mob(peaceful or hostile)that is given as param mobid. ;
}
}
Thats one that doesn't work !!!!!!
function getTile(x,y,z); // Idk
Need help with threse
function setVelX(ent, amount);
function setVelY(ent, amount);
function setVelZ(ent, amount);
function explode(x, y, z, radius); // Explodes blocks
function addItemInventory(id, amount);
function rideAnimal(player, target);
function getCarriedItem();
function preventDefault(); // Prevents hittng something from doing an attack function and or i think it can prevent u from taking damage
function setTile(x,y,z,type); // Sets a block to a different block right ?
I want to do
function useItem(x,y,z,itemId,blockId,side) {
if(itemId == 267) {
preventDefault()
Add your comments and edits here !!
Ok so that's whats i need help with
There's a site called hackpad where u can add code and edit it ! anybody can add ! It's really cool !! Just go here ---> https://modpe.hackpa...ipt-ideKsiF9dru ---> That way u can easily understand and see how u made code ! ALL IN REAL TIME !!
Thanks
? Explain
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumBasically, getTile() returns a number corresponding to the ID of the block at that location. So, for example, if you have a TNT block at location x = 11, y = 22, z = 33:
should give you 46, which is the data value of TNT.
But of course, just getting the number without using it is kinda useless, so what if you did something based on whether it's equal to something?
if (getTile(11, 22, 33) == 46) { clientMessage("There's TNT at that location"); }If the number returned by getTile is equal to 46, then call the method clientMessage to display the string "There's TNT at that location".
But wait! What if we don't just want to check that location? Maybe we can check the block that the player clicked.
the ModPE framework calls your code with a few variables (where numbers are stored - you use them where you would usually use a number).
function useItem(x,y,z,itemId,blockId,side) { if (blockId == 1 && getTile (x, y+1, z) == 1) { clientMessage("You have two stone blocks."); } }Note that variables are used there - so now you see why your script doesn't work.
function useItem(x,y,z,itemId,blockId,side) { if(itemId == 267) { //if the itemId variable (which ModPE sets to the item the player holds) is equal to 267 bl_spawnMob(x, y, z, 32, image); //spawn mob at location x, y, z, with ID 32 (Zombie) and the texture name contained in the variable image } }As you see, we don't actually have a variable called image - which is why it's erroring out. Remember that, with clientMessage, we made literal strings (text that isn't in a variable) by surrounding the text in quotes. So, if we want a zombie wearing the player skin, which is mob/char.png, let's call it with a literal string saying "mob/char.png".
function useItem(x,y,z,itemId,blockId,side) { if(itemId == 267) { //if the itemId variable (which ModPE // sets to the item the player holds) is equal to 267 bl_spawnMob(x, y, z, 32, "mob/char.png"); //spawn mob at location x, y, z // with ID 32 (Zombie) and the texture name "mob/char.png" } }(By the way: anything after the // are comments and are ignored by the computer; they are just helpful notes)
(Another by-the-way: anything beginning with bl_ is BlockLauncher-only, so they won't work on iOS. I hope you are on Android: if so, ANDROID ROCKS! WHOO!)