Autocrafter: Add register function for uncraftable items
This commit is contained in:
parent
b4a658c29f
commit
976dd379ca
@ -28,6 +28,13 @@ local STANDBY_TICKS = 3
|
|||||||
local COUNTDOWN_TICKS = 4
|
local COUNTDOWN_TICKS = 4
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
|
local UncraftableItems = {}
|
||||||
|
|
||||||
|
-- Add all nodes/items which should not be crafted with the autocrafter
|
||||||
|
function techage.register_uncraftable_items(item_name)
|
||||||
|
UncraftableItems[item_name] = true
|
||||||
|
end
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
return "size[8,9.2]"..
|
return "size[8,9.2]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
@ -71,6 +78,12 @@ local function get_craft(pos, inventory, hash)
|
|||||||
local recipe = inventory:get_list("recipe")
|
local recipe = inventory:get_list("recipe")
|
||||||
local output, decremented_input = minetest.get_craft_result(
|
local output, decremented_input = minetest.get_craft_result(
|
||||||
{method = "normal", width = 3, items = recipe})
|
{method = "normal", width = 3, items = recipe})
|
||||||
|
|
||||||
|
-- check if registered item
|
||||||
|
if UncraftableItems[output.item:get_name()] then
|
||||||
|
output.item = ItemStack()
|
||||||
|
end
|
||||||
|
|
||||||
craft = {recipe = recipe, consumption = count_index(recipe),
|
craft = {recipe = recipe, consumption = count_index(recipe),
|
||||||
output = output, decremented_input = decremented_input}
|
output = output, decremented_input = decremented_input}
|
||||||
autocrafterCache[hash] = craft
|
autocrafterCache[hash] = craft
|
||||||
|
Loading…
Reference in New Issue
Block a user