mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 15:23:43 +01:00
V1.06 Grinder recipes with API added
This commit is contained in:
parent
944bccaf5d
commit
12649d2f9b
@ -1,4 +1,4 @@
|
||||
# TechPack V1.05
|
||||
# TechPack V1.06
|
||||
|
||||
TechPack, a Mining, Crafting, & Farming Modpack for Minetest.
|
||||
|
||||
@ -28,7 +28,7 @@ TechPack provides:
|
||||
- Several lamp nodes in different colors (can be switched on/off)
|
||||
- a Quarry node to dig for stones and other ground nodes
|
||||
- a Harvester node to chop wood, leaves and crops
|
||||
- a Grinder node to grind cobble stone to gravel
|
||||
- a Grinder node to grind all kinds of cobblestone to gravel, gravel to sand, and sand to clay
|
||||
- a Gravelsieve node to sieve ores from gravel
|
||||
- an Autocrafter node for automated crafting of tools and items
|
||||
- a Fermenter node to produce Bio Gas from leaves
|
||||
@ -78,3 +78,4 @@ Gravelsieve optional: moreores, hopper, pipeworks
|
||||
- 2018-03-29 V1.03 * Area protected chest added to tubelib_addons1
|
||||
- 2018-03-31 V1.04 * Maintenance, minor issues, Unifieddyes support for Color Lamp, Street Lamp added
|
||||
- 2018-04-27 V1.05 * Ceiling lamp added, further improvements
|
||||
- 2018-06-09 V1.06 * Recipes with API to grinder added
|
||||
|
@ -20,6 +20,8 @@ local STOP_STATE = 0
|
||||
local STANDBY_STATE = -1
|
||||
local FAULT_STATE = -3
|
||||
|
||||
-- Grinder recipes
|
||||
local Recipes = {}
|
||||
|
||||
local function formspec(state)
|
||||
return "size[8,8]"..
|
||||
@ -67,14 +69,19 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
|
||||
local function convert_stone_to_gravel(inv)
|
||||
local cobble = ItemStack("default:cobble")
|
||||
local gravel = ItemStack("default:gravel")
|
||||
if inv:room_for_item("dst", gravel) and inv:contains_item("src", cobble) then
|
||||
inv:add_item("dst", gravel)
|
||||
inv:remove_item("src", cobble)
|
||||
return true
|
||||
local function grinding(inv)
|
||||
for _,stack in ipairs(inv:get_list("src")) do
|
||||
if not stack:is_empty() then
|
||||
local name = stack:get_name()
|
||||
if Recipes[name] then
|
||||
local output = Recipes[name]
|
||||
if inv:room_for_item("dst", output) then
|
||||
inv:add_item("dst", output)
|
||||
inv:remove_item("src", ItemStack(name))
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -137,7 +144,7 @@ local function keep_running(pos, elapsed)
|
||||
local running = meta:get_int("running") - 1
|
||||
--print("running", running)
|
||||
local inv = meta:get_inventory()
|
||||
local busy = convert_stone_to_gravel(inv)
|
||||
local busy = grinding(inv)
|
||||
|
||||
if busy == true then
|
||||
if running <= STOP_STATE then
|
||||
@ -293,3 +300,30 @@ tubelib.register_node("tubelib_addons1:grinder", {"tubelib_addons1:grinder_activ
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
if minetest.global_exists("unified_inventory") then
|
||||
unified_inventory.register_craft_type("grinding", {
|
||||
description = "Grinding",
|
||||
icon = 'tubelib_addons1_grinder.png',
|
||||
width = 1,
|
||||
height = 1,
|
||||
})
|
||||
end
|
||||
|
||||
function tubelib.add_grinder_recipe(recipe)
|
||||
Recipes[recipe.input] = ItemStack(recipe.output)
|
||||
if minetest.global_exists("unified_inventory") then
|
||||
recipe.items = {recipe.input}
|
||||
recipe.type = "grinding"
|
||||
unified_inventory.register_craft(recipe)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
tubelib.add_grinder_recipe({input="default:cobble", output="default:gravel"})
|
||||
tubelib.add_grinder_recipe({input="default:desert_cobble", output="default:gravel"})
|
||||
tubelib.add_grinder_recipe({input="default:mossycobble", output="default:gravel"})
|
||||
tubelib.add_grinder_recipe({input="default:gravel", output="default:sand"})
|
||||
tubelib.add_grinder_recipe({input="default:sand", output="default:clay"})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user