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 --
-----------

View File

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

View File

@ -1,4 +1,4 @@
name = elepower_dynamics
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

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
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",
"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

View File

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

View File

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

View File

@ -26,8 +26,8 @@ minetest.register_abm({
chance = 1/5,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local water_c = meta:get_int("water_fluid_storage")
if water_c == CAPACITY then return end
local buffer = fluid_lib.get_buffer_data(pos, "water")
if not buffer or buffer.amount == buffer.capacity then return end
local positions = {
{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},
}
local fluid = 0
local amount = 0
for _,fpos in pairs(positions) do
local node = minetest.get_node(fpos)
if node.name == "default:water_source" then
fluid = fluid + 1000
amount = amount + 1000
end
end
if fluid == 0 then
if amount == 0 then
meta:set_string("infotext", "Submerge me in water!")
return
end
local give = 0
if water_c + fluid > CAPACITY then
give = CAPACITY - water_c
if buffer.amount + amount > buffer.capacity then
give = buffer.capacity - buffer.amount
else
give = fluid
give = amount
end
water_c = water_c + give
buffer.amount = buffer.amount + give
meta:set_int("water_fluid_storage", water_c)
meta:set_string("infotext", ("Water: %d/%d %s"):format(water_c, CAPACITY, fluid_lib.unit))
meta:set_int("water_fluid_storage", buffer.amount)
meta:set_string("infotext", fluid_lib.buffer_to_string(buffer))
end
})