I have made a simple ModPE script that turn a Torch into a "Magic Wand". To activate, you must place a torch somewhere. Afterwards, you will see a message saying "Magic Wand Enabled". Afterwards, you can hit any mob with that torch and it will disappear. Note, you must have at least 2 Torches if in Survival mode, or be in Creative mode. The link to download is http://db.tt/6waIBvLT. Enjoy using this script!
Erase these red parts to fix that. Also you need to add an else where I put a green one here, and alot of your spaces are missing. Other than that, it looks good!
Rollback Post to RevisionRollBack
Back to modding! Follow me on Twitter @byteandahalf
I added that Else that you have in red because even if you hit a mob with a sword or whatever, the mob would disappear. I will try what you suggested and see if that makes a difference. I wanted the script to reset whenever something besides a torch was placed/used.
About your script, you have an "else" that causes setting any other block that's not a torch to reset the script.
var makethemobfly = 0;
function useItem(x,y,z,itemId,blockId)
{
if(itemId==50)
{
if(makethemobfly == 0)
{
makethemobfly = 1;
print("Magic Wand Equipped");
}
else
if(makethemobfly == 1)
{
print("Magic Wand Already Equipped");
}
}
else
{
makethemobfly = 0;
}
}
function attackHook(attacker,victim)
{
if(makethemobfly == 1)
{
preventDefault();
setVelY(victim, 50);
}
}
Erase these red parts to fix that. Also you need to add an else where I put a green one here, and alot of your spaces are missing. Other than that, it looks good!
Back to modding! Follow me on Twitter @byteandahalf