From 2c54a8be3b0f196c345c4efd7c112a3ecf1018a3 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Mon, 18 Jun 2018 13:25:08 +0300 Subject: [PATCH] Add a sawmill! --- elepower_machines/bases/storage.lua | 2 +- elepower_machines/register.lua | 52 ++++++++++++++++++ .../textures/elepower_sawmill.png | Bin 0 -> 6724 bytes 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 elepower_machines/textures/elepower_sawmill.png diff --git a/elepower_machines/bases/storage.lua b/elepower_machines/bases/storage.lua index 51aeb6e..4a11735 100644 --- a/elepower_machines/bases/storage.lua +++ b/elepower_machines/bases/storage.lua @@ -6,7 +6,7 @@ local function can_dig(pos, player) end local function item_in_group(stack, grp) - return minetest.get_item_group(stack:get_name(), grp) > 0 + return ele.helpers.get_item_group(stack:get_name(), grp) end function elepm.register_storage(nodename, nodedef) diff --git a/elepower_machines/register.lua b/elepower_machines/register.lua index f832d0e..2cb38bd 100644 --- a/elepower_machines/register.lua +++ b/elepower_machines/register.lua @@ -126,6 +126,58 @@ elepm.register_crafter("elepower_machines:furnace", { groups = {oddly_breakable_by_hand = 1} }) +------------- +-- Sawmill -- +------------- + +elepm.register_craft_type("saw", { + description = "Sawmilling", + inputs = 1, +}) + +-- Register all logs as sawable, if we can find a planks version +minetest.after(0.2, function () + local wood_nodes = {} + for name in pairs(minetest.registered_nodes) do + if ele.helpers.get_item_group(name, "wood") then + wood_nodes[#wood_nodes + 1] = name + end + end + + -- Begin making associations + -- Get crafting recipe for all woods + local assoc = {} + for _,wood in ipairs(wood_nodes) do + local recipes = minetest.get_all_craft_recipes(wood) + for _, recipe in ipairs(recipes) do + if recipe.items and #recipe.items == 1 then + assoc[recipe.items[1]] = wood + end + end + end + + -- Register sawmill craft + for tree, wood in pairs(assoc) do + elepm.register_craft({ + type = "saw", + recipe = { tree }, + output = wood .. " 6", + time = 8, + }) + end +end) + +elepm.register_crafter("elepower_machines:sawmill", { + description = "Sawmill", + craft_type = "saw", + ele_usage = 32, + tiles = { + "elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png", + "elepower_machine_side.png", "elepower_machine_side.png", "elepower_sawmill.png", + }, + groups = {oddly_breakable_by_hand = 1} +}) + ---------------------- -- Power Generation -- ---------------------- diff --git a/elepower_machines/textures/elepower_sawmill.png b/elepower_machines/textures/elepower_sawmill.png new file mode 100644 index 0000000000000000000000000000000000000000..3a014acc0bd11c22d24d193845b409ba4539730d GIT binary patch literal 6724 zcmeHL2~-o;8V(?c2nuLLKqUlFP$tV{BOw7%5F!LpcCA$>lLv7p|9<~>|NC$E&MfBz z`&*dVnPD&(3r>J34&IAHnTT2|oL1dKafP<3?g*g<|z?MY5yy0dUTeuO6B)rf$k*5j=;;UsUso z;;xnr-;OM+k{7e_{!`9>Gdne6W@<`q47okaHYb79yU($EM|)FmfYIVY?+i^sQ#M^= z*VItQ65_n_)c&&_9hOD7tQh;nSy$o*ZD2|m^{(>;gK!5+O^?OQS_u zi!W9YLsE1x^OX~Pr!8=CU2rE=1q4`sK!$}BU=@ip0K?3Zx0e&li= z*lFrgYii-PGiwYQWk^;Iql6b}X|mFaF}$36tYCkxt8sUUV9k=rwG&3!NxEdYZpY_u z+00`Pf>Yd*l)Kx%oVSPIiW^%$%fRMot;ve|G1=z^QHfK;E*CNf-Fu-`%{De~&Ay(D zS?yJBd^Rb%d_|y1qoH4V!d|C`i0$MR$;S=Nhm1a(d2*H0opoy`Ou-qMPEW4q_hJA6 zV3RCx>YO|*(qJK+xob;p&aTn+j?0QW*JxxTT)uIK-GBReL$clU$fEsC%v<8(#_<#O z?jznfe9Lp*!_MyxwrTGz$?__|Rt~bCb>A^%bZED0^L+8i#0H=Nosbu{vAlim-L(hRMQbU; zn6~DRk>=Hf#=G}{X(`@&#CGg4+fS{k#Als;Jg&yhuz394f(m2d(B9RlmzoNn-~6G- z>ULsW)A{_@t%d3*ZYPnZwF@w>1V;|W@A{TW&3DhPCq&;SPkWTnc=xRDE|-ZT9%S2_ zHi(ao1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