Pipeworks support!!
This commit is contained in:
parent
9d32873abb
commit
b157cd674c
@ -30,6 +30,9 @@ local fdir_areas = {
|
||||
local function harvest(pos, harvested, fdir)
|
||||
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)
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
|
57
elepower_farming/nodes/tree_extractor.lua
Normal file
57
elepower_farming/nodes/tree_extractor.lua
Normal file
@ -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
|
||||
})
|
BIN
elepower_farming/textures/elefarming_machine_tree_extractor.png
Normal file
BIN
elepower_farming/textures/elefarming_machine_tree_extractor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -13,6 +13,8 @@ function elepm.register_crafter(nodename, nodedef)
|
||||
|
||||
nodedef.groups["ele_machine"] = 1
|
||||
nodedef.groups["ele_user"] = 1
|
||||
nodedef.groups["tubedevice"] = 1
|
||||
nodedef.groups["tubedevice_receiver"] = 1
|
||||
|
||||
nodedef.on_timer = function (pos, elapsed)
|
||||
local refresh = false
|
||||
|
@ -6,6 +6,8 @@ function elepm.register_fuel_generator(nodename, nodedef)
|
||||
|
||||
nodedef.groups["ele_machine"] = 1
|
||||
nodedef.groups["ele_provider"] = 1
|
||||
nodedef.groups["tubedevice"] = 1
|
||||
nodedef.groups["tubedevice_receiver"] = 1
|
||||
|
||||
nodedef.on_timer = function (pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
-- Machine definitions
|
||||
|
||||
local pw = minetest.get_modpath("pipeworks") ~= nil
|
||||
|
||||
--[[
|
||||
Groups:
|
||||
ele_machine Any machine that does something with power
|
||||
@ -120,6 +122,26 @@ function ele.capacity_text(capacity, storage)
|
||||
return "Charge: " .. storage .. "/" .. capacity .. " " ..ele.unit
|
||||
end
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
return inv:add_item("src", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
input_inventory = "dst",
|
||||
|
||||
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
||||
}
|
||||
|
||||
-- Register a base device
|
||||
function ele.register_base_device(nodename, nodedef)
|
||||
-- Override construct callback
|
||||
@ -154,6 +176,11 @@ function ele.register_base_device(nodename, nodedef)
|
||||
nodedef.can_dig = can_dig
|
||||
end
|
||||
|
||||
-- Pipeworks support
|
||||
if pw and nodedef.groups and (nodedef.groups["tubedevice"] or nodedef.groups["tube"]) then
|
||||
nodedef['tube'] = tube
|
||||
end
|
||||
|
||||
-- Finally, register the damn thing already
|
||||
minetest.register_node(nodename, nodedef)
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = elepower_papi
|
||||
description = Elepower Power Network API
|
||||
optional_depends = default
|
||||
optional_depends = default,pipeworks
|
||||
|
Loading…
Reference in New Issue
Block a user