Portable Tank

This commit is contained in:
Evert Prants 2018-06-21 13:14:12 +03:00
parent d40b08a492
commit a969a5e721
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
12 changed files with 78 additions and 42 deletions

View File

@ -134,6 +134,16 @@ minetest.register_craft({
} }
}) })
-- Portable Tank
minetest.register_craft({
output = "elepower_dynamics:portable_tank",
recipe = {
{"group:glass", "elepower_dynamics:fluid_duct", "group:glass"},
{"group:glass", "group:glass", "group:glass"},
{"default:bronze_ingot", "default:bronze_ingot", "default:bronze_ingot"},
}
})
----------- -----------
-- Items -- -- Items --
----------- -----------

View File

@ -11,6 +11,7 @@ dofile(modpath.."/craftitems.lua")
dofile(modpath.."/plastic.lua") dofile(modpath.."/plastic.lua")
dofile(modpath.."/tools.lua") dofile(modpath.."/tools.lua")
dofile(modpath.."/nodes.lua") dofile(modpath.."/nodes.lua")
dofile(modpath.."/tanks.lua")
dofile(modpath.."/dusts.lua") dofile(modpath.."/dusts.lua")
dofile(modpath.."/gears.lua") dofile(modpath.."/gears.lua")
dofile(modpath.."/worldgen.lua") dofile(modpath.."/worldgen.lua")

View File

@ -1,4 +1,4 @@
name = elepower_dynamics name = elepower_dynamics
description = Elepower Dynamics. Conduits and materials! description = Elepower Dynamics. Conduits and materials!
depends = elepower_papi,elepower_fapi,default depends = elepower_papi,elepower_fapi,default,fluid_tanks
optional_depends = moreores,pipeworks,homedecor optional_depends = moreores,pipeworks,homedecor

View File

@ -0,0 +1,10 @@
fluid_tanks.register_tank("elepower_dynamics:portable_tank", {
description = "Portable Tank",
capacity = 8000,
accepts = true,
tiles = {
"elepower_tank_base.png", "elepower_tank_base.png", "elepower_tank_side.png",
"elepower_tank_side.png", "elepower_tank_side.png", "elepower_tank_side.png"
}
})

View File

@ -0,0 +1,9 @@
fluid_tanks.register_tank("elepower_dynamics:portable_tank", {
description = "Portable Tank",
capacity = 8000,
accepts = true,
tiles = {
"elepower_tank_base.png", "elepower_tank_side.png", "elepower_tank_base.png^elepower_power_port.png",
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

View File

@ -1,3 +1,3 @@
name = elepower_farming name = elepower_farming
description = Electric Farming Automation! description = Electric Farming Automation!
depends = elepower_papi, elepower_tools, elepower_fapi, bucket, farming depends = elepower_papi, elepower_tools, elepower_fapi, bucket, farming, fluid_tanks

View File

@ -252,4 +252,13 @@ if minetest.get_modpath("bucket") ~= nil then
bucket.register_liquid("elepower_farming:sludge_source", "elepower_farming:sludge_flowing", bucket.register_liquid("elepower_farming:sludge_source", "elepower_farming:sludge_flowing",
"elepower_farming:bucket_sludge", "#121212", "Sludge Bucket") "elepower_farming:bucket_sludge", "#121212", "Sludge Bucket")
fluid_tanks.register_tank(":elepower_dynamics:portable_tank", {
description = "Portable Tank",
capacity = 8000,
accepts = true,
tiles = {
"elepower_tank_base.png", "elepower_tank_side.png", "elepower_tank_base.png^elepower_power_port.png",
}
})
end end

View File

@ -172,8 +172,6 @@ local function plant(pos, range, stack, inv)
soil = "farming:soil" soil = "farming:soil"
end end
print(dump(base_node), soil,wet_soil)
if base_node.name ~= soil and base_node.name ~= wet_soil then if base_node.name ~= soil and base_node.name ~= wet_soil then
minetest.set_node(base_pos, {name = soil}) minetest.set_node(base_pos, {name = soil})
end end

View File

@ -27,44 +27,43 @@ minetest.register_node("elepower_farming:tree_extractor", {
minetest.register_abm({ minetest.register_abm({
nodenames = {"elepower_farming:tree_extractor"}, nodenames = {"elepower_farming:tree_extractor"},
label = "elefluidSapAccumulator", label = "elefluidSapAccumulator",
interval = 8, interval = 8,
chance = 1/6, chance = 1/6,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local fluid_c = meta:get_int("tree_fluid_storage") local buffer = fluid_lib.get_buffer_data(pos, "tree")
if fluid_c == CAPACITY then return end if not buffer or buffer.amount == buffer.capacity then return end
local fpos = ele.helpers.face_front(pos, node.param2) local fpos = ele.helpers.face_front(pos, node.param2)
local fluid = 0 local amount = 0
local ftype = meta:get_string("tree_fluid") local ftype = buffer.fluid
local fname = "Tree Sap" local fnode = minetest.get_node_or_nil(fpos)
local fnode = minetest.get_node_or_nil(fpos)
if fnode and ele.helpers.get_item_group(fnode.name, "tree") then if fnode and ele.helpers.get_item_group(fnode.name, "tree") then
local fdata = fluid_table[fnode.name] local fdata = fluid_table[fnode.name]
if fdata and (ftype == "" or ftype == fdata.fluid) then if fdata and (ftype == "" or ftype == fdata.fluid) then
fluid = fdata.fpc amount = fdata.fpc
ftype = fdata.fluid ftype = fdata.fluid
fname = minetest.registered_nodes[ftype].description:gsub(" Source", "")
end end
end end
if fluid == 0 then if amount == 0 then
meta:set_string("infotext", "Place me in front of a tree!") meta:set_string("infotext", "Place me in front of a tree!")
return return
end end
local give = 0 local give = 0
if fluid_c + fluid > CAPACITY then if buffer.amount + amount > buffer.capacity then
give = CAPACITY - fluid_c give = buffer.capacity - buffer.amount
else else
give = fluid give = amount
end end
fluid_c = fluid_c + give buffer.amount = buffer.amount + give
buffer.fluid = ftype
meta:set_int("tree_fluid_storage", fluid_c) meta:set_int("tree_fluid_storage", buffer.amount)
meta:set_string("tree_fluid", ftype) meta:set_string("tree_fluid", buffer.fluid)
meta:set_string("infotext", ("%s: %d/%d %s"):format(fname, fluid_c, CAPACITY, fluid_lib.unit)) meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
end end
}) })

View File

@ -21,13 +21,13 @@ minetest.register_node("elepower_machines:accumulator", {
minetest.register_abm({ minetest.register_abm({
nodenames = {"elepower_machines:accumulator"}, nodenames = {"elepower_machines:accumulator"},
label = "elefluidAccumulator", label = "elefluidAccumulator",
interval = 2, interval = 2,
chance = 1/5, chance = 1/5,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local water_c = meta:get_int("water_fluid_storage") local buffer = fluid_lib.get_buffer_data(pos, "water")
if water_c == CAPACITY then return end if not buffer or buffer.amount == buffer.capacity then return end
local positions = { local positions = {
{x=pos.x+1,y=pos.y,z=pos.z}, {x=pos.x+1,y=pos.y,z=pos.z},
@ -36,29 +36,29 @@ minetest.register_abm({
{x=pos.x, y=pos.y,z=pos.z-1}, {x=pos.x, y=pos.y,z=pos.z-1},
} }
local fluid = 0 local amount = 0
for _,fpos in pairs(positions) do for _,fpos in pairs(positions) do
local node = minetest.get_node(fpos) local node = minetest.get_node(fpos)
if node.name == "default:water_source" then if node.name == "default:water_source" then
fluid = fluid + 1000 amount = amount + 1000
end end
end end
if fluid == 0 then if amount == 0 then
meta:set_string("infotext", "Submerge me in water!") meta:set_string("infotext", "Submerge me in water!")
return return
end end
local give = 0 local give = 0
if water_c + fluid > CAPACITY then if buffer.amount + amount > buffer.capacity then
give = CAPACITY - water_c give = buffer.capacity - buffer.amount
else else
give = fluid give = amount
end end
water_c = water_c + give buffer.amount = buffer.amount + give
meta:set_int("water_fluid_storage", water_c) meta:set_int("water_fluid_storage", buffer.amount)
meta:set_string("infotext", ("Water: %d/%d %s"):format(water_c, CAPACITY, fluid_lib.unit)) meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
end end
}) })