this is a questies #774
-
sens I can't make an account on the computer craft website and I'm banned to make questions on StackOverflow I'm asking to hear How can I get the first item in the inventory that isn't on a list? and yes I will try to fix the problem whit StackOverflow |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
This would have been better as a discussion instead of an issue. There are new forums: https://forums.computercraft.cc/index.php Discord is also a thing: https://discord.computercraft.cc/ Also, please work on your spelling, I can understand that it can be difficult if English is not your first language. You might find Grammarly helpful. |
Beta Was this translation helpful? Give feedback.
-
Hrmr, what do you mean by "isn't on a list" here? Unless you're talking about Russel's Paradox, I'm not quite sure what you mean. A good starting point is probably the documentation on inventories, especially the |
Beta Was this translation helpful? Give feedback.
-
I'm assuming you're looking at how to check if an item in a chest or etc is not in a blacklist? If so, initialize a table of all the item identifiers which are "bad" (this may change between versions), then you will want to loop through the inventory and the items to check if:
Something like this might work (you will need to modify it). My code assumes 1.12.2 with Plethora (as I've not had too much of a chance to mess with 1.16), so if you're on newer versions of mc, some of the code may need to be different. local blacklist = {
["minecraft:dirt:0"] = true, -- these strings are in the format "modid:blockid:damage"
["minecraft:stone:0"] = true,
... -- whichever other items
}
local chest = peripheral.find("chest")
local list = chest.list()
for i = 1, chest.size() do -- for each slot in the chest
local item = list[i]
if item then -- if there is an item in this slot
if not blacklist[string.format("%s:%s", item.name, item.metadata)] then -- if the item is NOT in the blacklist
-- do something with the item.
end
end
end |
Beta Was this translation helpful? Give feedback.
I'm assuming you're looking at how to check if an item in a chest or etc is not in a blacklist?
If so, initialize a table of all the item identifiers which are "bad" (this may change between versions), then you will want to loop through the inventory and the items to check if:
Something like this might work (you will need to modify it). My code assumes 1.12.2 with Plethora (as I've not had too much of a chance to mess with 1.16), so if you're on newer versions of mc, some of the code may need to be different.