New IC: "Check player inventory"
LadyCailinBot opened this issue ยท 22 comments
CRAFTBOOK-2488 - Reported by pmpmpm
Hello,
Actually, nothing in CraftBook ICs allow you to check if the player has this item in his inventory, or if he is holding it. The only possible interaction is with blocks or items.
So here is my suggestion: Adding a door that would check player(s) inventory(ies) with different ways:
Inv Check
MC####
Radius=Offset (leave blank to check the player on top of the block behind the sign)
PlrNbr:Nbr:InHand:ID
Radius/Offset: Obvious
PlrNbr: Number of players to check (1 by default. If there isn't enough players, the IC won't output high)
Nbr: Number of needed items (1 by default, work if there is more items than this number)
InHand: Is the player(s) holding it? If there are multiple players, they should all hold the item in their hand
ID: Block/Item ID
That's all. Do you think it's possible to do? Is there better parameters?
Thanks for reading!
Comment by me4502
Are you sure the correct slot had the item in when you tested it as false?
Comment by me4502
Which slot was it in. Keep in mind the first inventory slot is slot 0, and I can't remember if that starts or ends at the hotbar.
Comment by pmpmpm
Er, actually I wrote "3" which I thought was the third hotbar slot (starting from the left). And it was this slot, not the next one.
Or I may be totally wrong. Which is frightening since I have a test in half an hour ^.^'
Comment by me4502
This site allows for an easy way of working out inventory ID's.
Comment by pmpmpm
Okay, so either I'm really really stupid (which is likely) and I don't understand something, or there's something not working.
I wrote this line:
3*2=1:false:3
And the output is high when I have the two dirt blocks in my fourth hotbar slot (which corresponds to the ID 39 according to the link you've given, not to the ID 3 I wrote on the IC).
Comment by me4502
With the slot weirdness, that is a bukkit bug if it doesn't work.
Comment by pmpmpm
Well, so:
Radius is working;
Offset is working;
ID is working;
data is working;
Players is working;
InHand is working;
Slot is kinda messed up but still working. The slot 0 is the first hotbar slot, it seems.
Sounds quite well!
Comment by pmpmpm
Looks like it's far better than what I've thought first x)
Thanks for that.
Comment by me4502
Thanks, tell me how it goes.. Or if you have any ideas for improvement.
Comment by pmpmpm
I couldn't test it now (very very hard week right now, exams and so), but here's a small idea:
Being able to define Item Packs in the config. For example, you could build some big statue asking you to approach with peace in your heart. In this case, you could define an Item Pack "Weapons" with swords, axes, bow, and so in it. You use it with this IC (with a "ip" prefix? Like "ip:Weapons*1=1:True") and storm the bad guy approaching with war in heart!
Edit: Okay, tested a bit.
I used a radius of 10 and the following fourth line:
3*2=1:true:3
So I tested if I had 2 blocks of dirt in my hand, and in the third slot. Perfectly working! The IC always ouputs high at the right time. So high signal when I have only one block for example, or when it's not in the good slot. The only thing that surprised me was that if we were 2 in the detection area, and one didn't have the 2 dirt blocks, the IC didn't output high. So PlayerNumber issue.
However, when writing "false" instead of "true", the IC never ouputs high, even when I do the right things. But when I write nothing for that (I tested a bit with only ID and data), it works well.
So I think that, for the parameters:
Radius is working;
Offset is working (tested quickly);
ID is working;
data is working (tested with leaves);
Players: Something is broken;
InHand: Something is broken when writing "False";
Slot: Working;
Comment by me4502
Okay, I implemented players. I did a test of inHand, and it is always set to false no matter if you have it blank or False. Can you please screenshot your setup?
Comment by pmpmpm
Attached as screenshot1. This IC never outputs high when triggered.
Comment by me4502
Hmm.. So that checks Slot 3, how do you know it isn't slot thats bugged and not inHand?
Comment by pmpmpm
Because I tested slot before, with "true" in place of "false". When having the dirt in my hand but on another slot, it didn't work, which proves that "slot" works.