I am making a pe port of a mod and i need to know how to delete an item from a function and how to cause a function just by having a certain item in inventory and slot in hot bar
Well, you can do this a couple different ways. The Native C way, I don't know. However, with Block Launcher you can do something like this:
i = 36;
item = item_id_goes_here;
function modTick() {
if (Player.getCarriedItem() == item) {
while (i >= 0) {
if (Player.getInventorySlot(i) == item) {
Player.clearInventorySlot(i);
} else {
i = i-1;
}
}
}
}
Basically what this does is it checks if you are holding the right item, then it searches for the item in your inventory. 36 is the number of inventory slots you have in MCPE. It checks every tick (or twentieth of a second). Hope this helps!
EDIT:
IF it doesn't help, could you clarify what you mean? I probably didn't understand it.
dent=30px]
Well, you can do this a couple different ways. The Native C way, I don't know. However, with Block Launcher you can do something like this:
i = 36; item = item_id_goes_here; function modTick() { if (Player.getCarriedItem() == item) { while (i >= 0) { if (Player.getInventorySlot(i) == item) { Player.clearInventorySlot(i); } else { i = i-1; } } } }
Basically what this does is it checks if you are holding the right item, then it searches for the item in your inventory. 36 is the number of inventory slots you have in MCPE. It checks every tick (or twentieth of a second). Hope this helps!
EDIT:IF it doesn't help, could you clarify what you mean? I probably didn't understand it.
[/indent]
I am making a pe port of a mod and i need to know how to delete an item from a function and how to cause a function just by having a certain item in inventory and slot in hot bar
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumWell, you can do this a couple different ways. The Native C way, I don't know. However, with Block Launcher you can do something like this:
Basically what this does is it checks if you are holding the right item, then it searches for the item in your inventory. 36 is the number of inventory slots you have in MCPE. It checks every tick (or twentieth of a second). Hope this helps!
EDIT:
IF it doesn't help, could you clarify what you mean? I probably didn't understand it.
You can contact me on twitter: @kd8lvtTV
Or on Discord: kd8lvt#5371
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumA quick edit on the code, the code I previously posted ONLY CHECKS ONCE - Slight oversight on my part hehe Heres a better one:
You can contact me on twitter: @kd8lvtTV
Or on Discord: kd8lvt#5371