From b157cd674c85a100186dd0b52e3b350935e9f71d Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Tue, 19 Jun 2018 17:21:32 +0300 Subject: [PATCH] Pipeworks support!! --- elepower_farming/nodes/harvester.lua | 16 +++-- elepower_farming/nodes/init.lua | 1 + elepower_farming/nodes/planter.lua | 2 + elepower_farming/nodes/tree_extractor.lua | 57 ++++++++++++++++++ .../elefarming_machine_tree_extractor.png | Bin 0 -> 1601 bytes elepower_machines/bases/crafter.lua | 2 + elepower_machines/bases/generator.lua | 2 + elepower_papi/machine.lua | 27 +++++++++ elepower_papi/mod.conf | 2 +- 9 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 elepower_farming/nodes/tree_extractor.lua create mode 100644 elepower_farming/textures/elefarming_machine_tree_extractor.png diff --git a/elepower_farming/nodes/harvester.lua b/elepower_farming/nodes/harvester.lua index ca8ca64..db0da87 100644 --- a/elepower_farming/nodes/harvester.lua +++ b/elepower_farming/nodes/harvester.lua @@ -17,19 +17,22 @@ local fdir_areas = { {x = 0, z = 4, y = 0}, }, { -- POS Z (2) - {x = -4, z = 0, y = 0}, - {x = 4, z = 8, y = 0}, + {x = -4, z = 0, y = 0}, + {x = 4, z = 8, y = 0}, }, { -- POS X (3) - {x = 0, z = -4, y = 0}, - {x = 8, z = 4, y = 0}, + {x = 0, z = -4, y = 0}, + {x = 8, z = 4, y = 0}, }, nil, nil } local function harvest(pos, harvested, fdir) - local front = ele.helpers.face_front(pos, fdir) - local ranges = fdir_areas[fdir + 1] + local front = ele.helpers.face_front(pos, fdir) + local ranges = fdir_areas[fdir + 1] + + if not ranges then return nil end + local range_st = vector.add(front, ranges[1]) local range_end = vector.add(front, ranges[2]) @@ -122,6 +125,7 @@ ele.register_machine("elepower_farming:harvester", { ele_machine = 1, ele_user = 1, cracky = 1, + tubedevice = 1, }, on_construct = function (pos) local meta = minetest.get_meta(pos) diff --git a/elepower_farming/nodes/init.lua b/elepower_farming/nodes/init.lua index d31c2a6..5ead624 100644 --- a/elepower_farming/nodes/init.lua +++ b/elepower_farming/nodes/init.lua @@ -2,3 +2,4 @@ dofile(elefarm.modpath.."/nodes/planter.lua") dofile(elefarm.modpath.."/nodes/harvester.lua") dofile(elefarm.modpath.."/nodes/fluids.lua") +dofile(elefarm.modpath.."/nodes/tree_extractor.lua") diff --git a/elepower_farming/nodes/planter.lua b/elepower_farming/nodes/planter.lua index 327cbd5..eb40df4 100644 --- a/elepower_farming/nodes/planter.lua +++ b/elepower_farming/nodes/planter.lua @@ -242,6 +242,8 @@ ele.register_base_device("elepower_farming:planter", { ele_machine = 1, ele_user = 1, cracky = 1, + tubedevice = 1, + tubedevice_receiver = 1, }, on_construct = function (pos) local meta = minetest.get_meta(pos) diff --git a/elepower_farming/nodes/tree_extractor.lua b/elepower_farming/nodes/tree_extractor.lua new file mode 100644 index 0000000..4a892bd --- /dev/null +++ b/elepower_farming/nodes/tree_extractor.lua @@ -0,0 +1,57 @@ + +local CAPACITY = 8000 + +minetest.register_node("elepower_farming:tree_extractor", { + description = "Tree Sap Extractor", + groups = {fluid_container = 1, oddly_breakable_by_hand = 1, cracky = 1}, + tiles = { + "elefarming_machine_base.png", "elefarming_machine_base.png", "elefarming_machine_side.png", + "elefarming_machine_side.png", "elefarming_machine_side.png^elepower_power_port.png", + "elefarming_machine_tree_extractor.png", + }, + fluid_buffers = { + tree_sap = { + capacity = CAPACITY + } + }, + on_construct = function ( pos ) + local meta = minetest.get_meta(pos) + meta:set_string("tree_sap_fluid", "elepower_farming:tree_sap_source") + end +}) + +minetest.register_abm({ + nodenames = {"elepower_farming:tree_extractor"}, + label = "elefluidSapAccumulator", + interval = 8, + chance = 1/6, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.get_meta(pos) + local tree_sap_c = meta:get_int("tree_sap_fluid_storage") + if tree_sap_c == CAPACITY then return end + + local fpos = ele.helpers.face_front(pos, node.param2) + local fluid = 0 + local fnode = minetest.get_node_or_nil(fpos) + if fnode and ele.helpers.get_item_group(fnode.name, "tree") then + fluid = fluid + 100 + end + + if fluid == 0 then + meta:set_string("infotext", "Place me in front of a tree!") + return + end + + local give = 0 + if tree_sap_c + fluid > CAPACITY then + give = CAPACITY - tree_sap_c + else + give = fluid + end + + tree_sap_c = tree_sap_c + give + + meta:set_int("tree_sap_fluid_storage", tree_sap_c) + meta:set_string("infotext", ("Tree Sap: %d/%d %s"):format(tree_sap_c, CAPACITY, elefluid.unit)) + end +}) diff --git a/elepower_farming/textures/elefarming_machine_tree_extractor.png b/elepower_farming/textures/elefarming_machine_tree_extractor.png new file mode 100644 index 0000000000000000000000000000000000000000..dfe6f4abc7710890d0f407a0be9d5fcb009dec81 GIT binary patch literal 1601 zcmV-H2EO@;P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3ysmg6W4M*p*lS%M`Y9?QWz&Y2y|^5=tK65Ew@ zdV0($gJl^BT?taA{_}S;f8kn~3{G;hUNA(0 zULKFZO?ic!q0dvE=R65=eVHiM`C>o6NOK|%)4*YI8WMUK*yhA0&54AkW&3#EAIsWY z4E}WqdFr?MeuM#krr)f1cIwDm+%0e3yNGe%&3eSGbVtPx`^(Vv*&M12pSTLihC6o; z1@23bgx=v!61hthW0g4MGZdi3X7d=wBd(vXPoA5@^@;q1bdBhZ{Drg`0X<&Gg^*kQ zk8;wd+`J+k++Hj@w=AFJr7jbToH_8dRzhp_vASd(mh9%Dj-`wd^!6UD@s&gK_|q-) zVD}c$0!ktSXF-zfXqh50FgCJOC{d$2`b-%vTCVKTGiMgc2EqUsk@LW9d!xo4fD7QW zWTb;Y%F7oTX5%oIDZp@{V30k8$q1kPQ8V8twbl!YXbUS=@QZt9!;4Oi$ZP~P5TQ1M zsw2QhyI!5EfS`^r2P`mcd!GULcco`?$p9@-RP>KJB46eN2oXF`I70#gn?uErqs?Pu z^F#<_0H6fdSuF3sLaJQgBwG;&IH&^H#y6gZDl0$4*a!ha#ToHngAxQRYZdw9Z9ons z6}77B)N9bF$%*R~=A3tZM@?S5_3EAXKK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