cylindrical tank finished
parent
0a7804aa1c
commit
524c297c33
|
@ -77,8 +77,8 @@ minetest.register_abm({
|
|||
interval = 5,
|
||||
chance = 5,
|
||||
action = function(pos)
|
||||
minetest.get_node_timer(pos):start(15*60) -- concrete takes half an hour to cure at best
|
||||
-- minetest.get_node_timer(pos):start(5) -- fast cure for debugging
|
||||
-- minetest.get_node_timer(pos):start(15*60) -- concrete takes half an hour to cure at best
|
||||
minetest.get_node_timer(pos):start(5) -- fast cure for debugging
|
||||
end
|
||||
})
|
||||
|
||||
|
|
103
craftitems.lua
103
craftitems.lua
|
@ -1,112 +1,19 @@
|
|||
|
||||
|
||||
--[[
|
||||
minetest.register_craftitem(":bitumen:bitumen", {
|
||||
description = "Bitumen",
|
||||
inventory_image = "bitumen_bitumen.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- these are temporary until the piping system is done
|
||||
minetest.register_craftitem(":bitumen:synthetic_crude", {
|
||||
description = "Synthetic Crude Oil",
|
||||
inventory_image = "bitumen_synthetic_crude.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:lube_oil", {
|
||||
description = "Heavy Lubricating Oil",
|
||||
inventory_image = "bitumen_lube_oil.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craftitem(":bitumen:fuel_oil", {
|
||||
description = "Fuel Oil",
|
||||
inventory_image = "bitumen_fuel_oil.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:diesel", {
|
||||
description = "Diesel",
|
||||
inventory_image = "bitumen_diesel.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:kerosene", {
|
||||
description = "Kerosene",
|
||||
inventory_image = "bitumen_kerosene.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:gasoline", {
|
||||
description = "Gasoline",
|
||||
inventory_image = "bitumen_gasoline.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:jet_fuel", {
|
||||
description = "Jet Fuel",
|
||||
inventory_image = "bitumen_jet_fuel.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:lpg", {
|
||||
description = "LPG",
|
||||
inventory_image = "bitumen_lpg.png",
|
||||
minetest.register_craftitem("bitumen:galv_steel_sheet", {
|
||||
description = "Galvanized Steel Sheet",
|
||||
inventory_image = "bitumen_galv_steel_sheet.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_craftitem(":bitumen:lpg_regulator", {
|
||||
description = "LPG Regulator",
|
||||
inventory_image = "bitumen_lpg_regulator.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
-- these may need to just be tools
|
||||
minetest.register_craftitem(":bitumen:small_lpg_bottle", {
|
||||
description = "Small LPG Bottle",
|
||||
inventory_image = "bitumen_small_lpg_bottle.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:gas_can", {
|
||||
description = "Plastic Gas Can",
|
||||
inventory_image = "bitumen_gas_can.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_craftitem(":bitumen:brass_ingot", {
|
||||
description = "Brass Ingot",
|
||||
inventory_image = "bitumen_brass_ingot.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:brass_dust", {
|
||||
description = "Brass Dust",
|
||||
inventory_image = "bitumen_brass_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":bitumen:carbon_steel_ingot", {
|
||||
description = "Carbon Steel Ingot",
|
||||
inventory_image = "bitumen_carbon_steel_ingot.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craftitem(":bitumen:carbon_steel_dust", {
|
||||
description = "Carbon Steel Dust",
|
||||
inventory_image = "bitumen_carbon_steel_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
|
|
54
crafts.lua
54
crafts.lua
|
@ -187,11 +187,57 @@ minetest.register_craft({
|
|||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bitumen:oil_drum 27",
|
||||
output = "bitumen:oil_drum 3",
|
||||
recipe = {
|
||||
{"default:steelblock", "default:tin_ingot", "default:steelblock"},
|
||||
{"default:steelblock", "", "default:steelblock"},
|
||||
{"default:steelblock", "default:steelblock", "default:steelblock"},
|
||||
{"default:tin_ingot", "default:tin_ingot", "default:tin_ingot"},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- tanks
|
||||
minetest.register_craft({
|
||||
output = "bitumen:galv_steel_sheet 3",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"", "", ""},
|
||||
{"default:steel_ingot", "default:tin_ingot", "default:steel_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bitumen:cylinder_tank 1",
|
||||
recipe = {
|
||||
{"default:galv_steel_sheet", "default:galv_steel_sheet", "default:galv_steel_sheet"},
|
||||
{"default:galv_steel_sheet", "", "default:galv_steel_sheet"},
|
||||
{"default:galv_steel_sheet", "default:galv_steel_sheet", "default:galv_steel_sheet"},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bitumen:cylinder_tank_top 1",
|
||||
recipe = {
|
||||
{"", "bitumen:intake", ""},
|
||||
{"", "bitumen:cylinder_tank", ""},
|
||||
{"", "", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bitumen:cylinder_tank_bottom 1",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"", "bitumen:cylinder_tank", ""},
|
||||
{"", "bitumen:spout", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bitumen:galv_steel_sheet 4",
|
||||
type = "shapeless",
|
||||
recipe = {"bitumen:cylinder_tank_cracked"},
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,63 @@
|
|||
|
||||
|
||||
|
||||
local function check_tank_foundation(bpos)
|
||||
local meta = minetest.get_meta(bpos)
|
||||
local height = meta:get_int("height")
|
||||
|
||||
if height < 1 then
|
||||
return
|
||||
end
|
||||
|
||||
local d = math.ceil(height / 5)
|
||||
|
||||
return bitumen.check_foundation(
|
||||
{x = bpos.x - 2, y = bpos.y - 1 - d, z = bpos.z - 2},
|
||||
{x = bpos.x + 2, y = bpos.y - 2 , z = bpos.z + 2},
|
||||
{
|
||||
["default:stone"] = 1,
|
||||
["default:desert_stone"] = 1,
|
||||
["default:steelblock"] = 1,
|
||||
["bitumen:concrete"] = 1,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
-- check poor foundation
|
||||
minetest.register_abm({
|
||||
nodenames = {"bitumen:cylinder_tank_bottom"},
|
||||
interval = 30,
|
||||
chance = 10,
|
||||
action = function(pos)
|
||||
if not check_tank_foundation(pos) then
|
||||
--print("tank failure")
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local fill = meta:get_int("fill")
|
||||
local height = meta:get_int("height")
|
||||
|
||||
if height < 2 then
|
||||
-- no middle segments
|
||||
return
|
||||
end
|
||||
|
||||
local fillh = math.ceil(fill / (9 * 60))
|
||||
|
||||
local y = math.random(1, fillh)
|
||||
minetest.set_node({x=pos.x, y=pos.y+y, z=pos.z}, {name="bitumen:cylinder_tank_cracked"})
|
||||
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
local function try_add_fluid(tpos)
|
||||
|
||||
-- find the bottom node
|
||||
local tmeta = minetest.get_meta(tpos)
|
||||
local rbpos = tmeta:get_string("bpos")
|
||||
if not rbpos then
|
||||
--print("no bpos")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -15,8 +66,6 @@ local function try_add_fluid(tpos)
|
|||
local npos = {x=tpos.x, y=tpos.y+1, z=tpos.z}
|
||||
local tnet = bitumen.pipes.get_net(npos)
|
||||
if not tnet or not tnet.fluid or tnet.fluid == "air" then
|
||||
--print("no tnet")
|
||||
--print(dump(tnet.fluid))
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -29,12 +78,10 @@ local function try_add_fluid(tpos)
|
|||
|
||||
-- check for full
|
||||
if fill >= capacity then
|
||||
--print("empty")
|
||||
return
|
||||
end
|
||||
|
||||
if fill > 0 and fluid ~= tnet.fluid then
|
||||
--print("wrong fluid to take")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -43,7 +90,6 @@ local function try_add_fluid(tpos)
|
|||
|
||||
local taken, tfluid = bitumen.pipes.take_fluid(npos, remcap)
|
||||
if taken == 0 then
|
||||
--print("none taken")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -54,7 +100,6 @@ local function try_add_fluid(tpos)
|
|||
end
|
||||
|
||||
fill = fill + taken
|
||||
--print("cyl tank fill: " .. fill .. " ("..tfluid..")")
|
||||
|
||||
bmeta:set_int("fill", fill)
|
||||
end
|
||||
|
@ -66,7 +111,6 @@ local function try_give_fluid(bpos)
|
|||
local npos = {x=bpos.x, y=bpos.y-1, z=bpos.z}
|
||||
local tnet = bitumen.pipes.get_net(npos)
|
||||
if not tnet then
|
||||
--print("no bnet")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -78,7 +122,6 @@ local function try_give_fluid(bpos)
|
|||
|
||||
-- check for empty
|
||||
if fill <= 0 or fluid == "air" then
|
||||
--print("tank empty " .. fluid .. " " ..fill)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -86,12 +129,10 @@ local function try_give_fluid(bpos)
|
|||
|
||||
local pushed = bitumen.pipes.push_fluid(npos, fluid, math.min(fill, 64), lift)
|
||||
if pushed == 0 then
|
||||
--print("none pushed")
|
||||
return
|
||||
end
|
||||
|
||||
fill = math.max(fill - pushed, 0)
|
||||
--print("cyl tank fill: " .. fill .. " ("..fluid..") [push]")
|
||||
|
||||
bmeta:set_int("fill", fill)
|
||||
end
|
||||
|
@ -102,8 +143,6 @@ end
|
|||
-- tank data is stored based on the bottom position
|
||||
local function init_tank(tpos, bpos)
|
||||
|
||||
--print(dump(tpos))
|
||||
--print(dump(bpos))
|
||||
|
||||
local fluid = "air"
|
||||
local tnet = bitumen.pipes.get_net({x=tpos.x, y=tpos.y+1, z=tpos.z})
|
||||
|
@ -117,16 +156,16 @@ local function init_tank(tpos, bpos)
|
|||
}}
|
||||
local tmeta = minetest.get_meta(tpos)
|
||||
tmeta:from_table(tmetad)
|
||||
--print(dump2(tmeta:to_table()))
|
||||
|
||||
local cap = (tpos.y - bpos.y) * 60 * 9
|
||||
--print("capacity: ".. cap)
|
||||
local height = tpos.y - bpos.y
|
||||
local cap = height * 60 * 9
|
||||
|
||||
local bmeta = minetest.get_meta(bpos)
|
||||
local bmetad = {fields = {
|
||||
capacity = cap,
|
||||
fill = 0,
|
||||
fluid = fluid,
|
||||
height = height,
|
||||
tpos = minetest.serialize(tpos),
|
||||
}}
|
||||
bmeta:from_table(bmetad)
|
||||
|
@ -135,6 +174,30 @@ local function init_tank(tpos, bpos)
|
|||
end
|
||||
|
||||
|
||||
local function find_bottom(pos)
|
||||
|
||||
local p = {x=pos.x, y=pos.y, z=pos.z}
|
||||
|
||||
while 1==1 do
|
||||
-- find the bottom and check the fill
|
||||
|
||||
local n = minetest.get_node(p)
|
||||
if n.name == "bitumen:cylinder_tank_bottom" then
|
||||
return p
|
||||
elseif n.name ~= "bitumen:cylinder_tank"
|
||||
and n.name ~= "bitumen:cylinder_tank_cracked"
|
||||
and n.name ~= "bitumen:cylinder_tank_top"
|
||||
|
||||
then
|
||||
return nil
|
||||
end
|
||||
|
||||
p.y = p.y - 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function can_dig_tank(pos, player)
|
||||
--if 1==1 then return true end
|
||||
-- check owner
|
||||
|
@ -145,21 +208,14 @@ local function can_dig_tank(pos, player)
|
|||
-- if player:get_player_name() ~= owner then
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
local p = {x=pos.x, y=pos.y, z=pos.z}
|
||||
|
||||
while 1==1 do
|
||||
-- find the bottom and check the fill
|
||||
local n = minetest.get_node(p)
|
||||
if n.name == "bitumen:cylinder_tank_bottom" then
|
||||
local meta = minetest.get_meta(p)
|
||||
local fill = meta:get_int("fill")
|
||||
return fill <= 0
|
||||
elseif n.name ~= "bitumen:cylinder_tank" and n.name ~= "bitumen:cylinder_tank_top" then
|
||||
return true
|
||||
end
|
||||
|
||||
p.y = p.y - 1
|
||||
local n = find_bottom(pos)
|
||||
if n == nil then
|
||||
return true
|
||||
else
|
||||
local meta = minetest.get_meta(pos)
|
||||
local fill = meta:get_int("fill")
|
||||
return fill <= 0
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -177,9 +233,9 @@ minetest.register_node("bitumen:cylinder_tank", {
|
|||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
{ -1.7, -.5, -1.2, 1.7, .5, 1.2 },
|
||||
{ -1.2, -.5, -1.7, 1.2, .5, 1.7 },
|
||||
{ -1.3, -.5, -1.3, 1.3, .5, 1.3 },
|
||||
{ -1.5, -.5, -1.1, 1.5, .5, 1.1 },
|
||||
{ -1.1, -.5, -1.5, 1.1, .5, 1.5 },
|
||||
-- { -8.2, -.5, -.2, -7.8, 10, .2 },
|
||||
-- { -.2, -.5, -8.2, .2, 10, -7.8 },
|
||||
-- { 8.2, -.5, -.2, 7.8, 10, .2 },
|
||||
|
@ -189,13 +245,68 @@ minetest.register_node("bitumen:cylinder_tank", {
|
|||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.7, -.5, -1.7, 1.7, .5, 1.7 },
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.7, -.5, -1.7, 1.7, .5, 1.7 },
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=1, level =2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
on_construct = function(pos)
|
||||
-- local meta = minetest.get_meta(pos)
|
||||
-- if placer then
|
||||
-- local owner = placer:get_player_name()
|
||||
-- meta:set_string("owner", owner)
|
||||
-- end
|
||||
-- meta:set_float("fluid_level", 0)
|
||||
-- meta:set_float("capacity", math.floor(3.14159 * .75 * 9 * 9 * 9 * 64))
|
||||
-- meta:set_string("infotext", "0%")
|
||||
|
||||
--bitumen.pipes.on_construct(pos)
|
||||
end,
|
||||
|
||||
-- on_destruct = bitumen.magic.on_destruct,
|
||||
|
||||
can_dig = can_dig_tank,
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_node("bitumen:cylinder_tank_cracked", {
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
description = "Cracked Cylinder Tank Segment",
|
||||
tiles = {
|
||||
"default_tin_block.png",
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.3, -.5, -1.3, 1.3, .5, 1.3 },
|
||||
{ -1.5, -.5, -1.1, 1.5, .5, 1.1 },
|
||||
{ -1.1, -.5, -1.5, 1.1, .5, 1.5 },
|
||||
-- { -8.2, -.5, -.2, -7.8, 10, .2 },
|
||||
-- { -.2, -.5, -8.2, .2, 10, -7.8 },
|
||||
-- { 8.2, -.5, -.2, 7.8, 10, .2 },
|
||||
-- { -.2, -.5, 8.2, .2, 10, 7.8 },
|
||||
},
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
|
@ -232,9 +343,9 @@ minetest.register_node("bitumen:cylinder_tank_top", {
|
|||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.5, -.5, -1.5, 1.5, .0, 1.5 },
|
||||
{ -1.7, -.5, -1.2, 1.7, .0, 1.2 },
|
||||
{ -1.2, -.5, -1.7, 1.2, .0, 1.7 },
|
||||
{ -1.3, -.5, -1.3, 1.3, .0, 1.3 },
|
||||
{ -1.5, -.5, -1.1, 1.5, .0, 1.1 },
|
||||
{ -1.1, -.5, -1.5, 1.1, .0, 1.5 },
|
||||
{ -1.2, -.1, -1.2, 1.2, .2, 1.2 },
|
||||
{ -.7, -.1, -.7, .7, .4, .7 },
|
||||
{ -.1, .1, -.1, .1, .5, .1 },
|
||||
|
@ -243,13 +354,13 @@ minetest.register_node("bitumen:cylinder_tank_top", {
|
|||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.7, -.5, -1.7, 1.7, .5, 1.7 },
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.7, -.5, -1.7, 1.7, .5, 1.7 },
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
|
@ -309,31 +420,31 @@ minetest.register_node("bitumen:cylinder_tank_bottom", {
|
|||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.5, .0, -1.5, 1.5, .5, 1.5 },
|
||||
{ -1.7, .0, -1.2, 1.7, .5, 1.2 },
|
||||
{ -1.2, .0, -1.7, 1.2, .5, 1.7 },
|
||||
{ -1.2, -.2, -1.2, 1.2, .1, 1.2 },
|
||||
{ -1.3, .0, -1.3, 1.3, .5, 1.3 },
|
||||
{ -1.5, .0, -1.1, 1.5, .5, 1.1 },
|
||||
{ -1.1, .0, -1.5, 1.1, .5, 1.5 },
|
||||
{ -1.0, -.2, -1.0, 1.0, .1, 1.0 },
|
||||
{ -.7, -.4, -.7, .7, .1, .7 },
|
||||
{ -.1, -.5, -.1, .1, .1, .1 },
|
||||
|
||||
-- legs
|
||||
{ -1.4, -1.55, -1.4, -1.3, 0, -1.3 },
|
||||
{ 1.3, -1.55, -1.4, 1.4, 0, -1.3 },
|
||||
{ -1.4, -1.55, 1.3, -1.3, 0, 1.4 },
|
||||
{ 1.3, -1.55, 1.3, 1.4, 0, 1.4 },
|
||||
{ -1.25, -1.55, -1.25, -1.15, 0, -1.15 },
|
||||
{ 1.15, -1.55, -1.15, 1.25, 0, -1.25 },
|
||||
{ -1.25, -1.55, 1.15, -1.15, 0, 1.25 },
|
||||
{ 1.15, -1.55, 1.15, 1.25, 0, 1.25 },
|
||||
|
||||
},
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.7, -.5, -1.7, 1.7, .5, 1.7 },
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -1.7, -.5, -1.7, 1.7, .5, 1.7 },
|
||||
{ -1.5, -.5, -1.5, 1.5, .5, 1.5 },
|
||||
}
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
|
@ -402,13 +513,47 @@ minetest.register_abm({
|
|||
|
||||
|
||||
|
||||
--[[
|
||||
minetest.register_craft({
|
||||
output = 'bitumen:sphere_tank_constructor',
|
||||
recipe = {
|
||||
{'default:steelblock', 'default:steelblock', 'default:steelblock'},
|
||||
{'default:steelblock', 'vessels:steel_bottle', 'default:steelblock'},
|
||||
{'default:steelblock', 'default:steelblock', 'default:steelblock'},
|
||||
}
|
||||
|
||||
-- leaking
|
||||
minetest.register_abm({
|
||||
nodenames = {"bitumen:cylinder_tank_cracked"},
|
||||
interval = 10,
|
||||
chance = 5,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local p = find_bottom(pos)
|
||||
if p == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(p)
|
||||
local fill = meta:get_int("fill")
|
||||
|
||||
local fillh = math.ceil(fill / (9 * 60))
|
||||
local dh = pos.y - p.y
|
||||
-- fill level is below the crack
|
||||
if fillh < dh then
|
||||
return
|
||||
end
|
||||
|
||||
-- choose a random place to leak
|
||||
local airs = minetest.find_nodes_in_area({x=p.x-2, y=pos.y-1, z=pos.z-2}, {x=p.x+2, y=pos.y, z=pos.z+2}, {"air"})
|
||||
if not airs then
|
||||
return
|
||||
end
|
||||
|
||||
local ap = airs[math.random(#airs)]
|
||||
local l = math.min(fill, math.min(64, math.random(5, 30)))
|
||||
|
||||
local fluid = meta:get_string("fluid")
|
||||
minetest.set_node(ap, {name=fluid})
|
||||
minetest.set_node_level(ap, l)
|
||||
|
||||
meta:set_int("fill", fill - l)
|
||||
|
||||
end,
|
||||
})
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
54
init.lua
54
init.lua
|
@ -41,7 +41,46 @@ end
|
|||
|
||||
|
||||
|
||||
local function vmin(a, b)
|
||||
return {
|
||||
x = math.min(a.x, b.x),
|
||||
y = math.min(a.y, b.y),
|
||||
z = math.min(a.z, b.z),
|
||||
}
|
||||
end
|
||||
local function vmax(a, b)
|
||||
return {
|
||||
x = math.max(a.x, b.x),
|
||||
y = math.max(a.y, b.y),
|
||||
z = math.max(a.z, b.z),
|
||||
}
|
||||
end
|
||||
|
||||
bitumen.check_foundation = function(p1, p2, accept)
|
||||
local low = vmin(p1, p2)
|
||||
local high = vmax(p1, p2)
|
||||
|
||||
--print(dump(low) .. "\n" .. dump(high))
|
||||
for x = low.x, high.x do
|
||||
for y = low.y, high.y do
|
||||
for z = low.z, high.z do
|
||||
local n = minetest.get_node({x=x, y=y, z=z})
|
||||
if accept[n.name] == nil then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- first initialize the internal APIs
|
||||
dofile(modpath.."/craftitems.lua")
|
||||
dofile(modpath.."/magic_nodes.lua")
|
||||
dofile(modpath.."/blueprints.lua")
|
||||
dofile(modpath.."/pipes.lua")
|
||||
|
@ -63,6 +102,13 @@ dofile(modpath.."/cylinder_tank.lua")
|
|||
dofile(modpath.."/sphere_tank.lua")
|
||||
dofile(modpath.."/refinery.lua")
|
||||
|
||||
|
||||
|
||||
-----------------------------------
|
||||
-- --
|
||||
-- * * * * * LOOK HERE * * * * * --
|
||||
-- --
|
||||
-----------------------------------
|
||||
-- where players should look for information
|
||||
dofile(modpath.."/crafts.lua")
|
||||
dofile(modpath.."/ore_gen.lua")
|
||||
|
@ -96,6 +142,14 @@ minetest.register_node("bitumen:glass", {
|
|||
end,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- igore this; test for structure algorithm
|
||||
|
||||
local support = {}
|
||||
|
||||
minetest.register_abm({
|
||||
|
|
|
@ -1,37 +1,6 @@
|
|||
|
||||
|
||||
local function vmin(a, b)
|
||||
return {
|
||||
x = math.min(a.x, b.x),
|
||||
y = math.min(a.y, b.y),
|
||||
z = math.min(a.z, b.z),
|
||||
}
|
||||
end
|
||||
local function vmax(a, b)
|
||||
return {
|
||||
x = math.max(a.x, b.x),
|
||||
y = math.max(a.y, b.y),
|
||||
z = math.max(a.z, b.z),
|
||||
}
|
||||
end
|
||||
|
||||
local function check_foundation(p1, p2, accept)
|
||||
local low = vmin(p1, p2)
|
||||
local high = vmax(p1, p2)
|
||||
print(dump(low) .. "\n" .. dump(high))
|
||||
for x = low.x, high.x do
|
||||
for y = low.y, high.y do
|
||||
for z = low.z, high.z do
|
||||
local n = minetest.get_node({x=x, y=y, z=z})
|
||||
if accept[n.name] == nil then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -74,7 +43,7 @@ minetest.register_node("bitumen:sphere_tank_constructor", {
|
|||
|
||||
if fields.build then
|
||||
-- tanks can only be built on thick foundations
|
||||
local ret = check_foundation(
|
||||
local ret = bitumen.check_foundation(
|
||||
{x = pos.x - 9, y = pos.y - 3, z = pos.z - 9},
|
||||
{x = pos.x + 9, y = pos.y - 1, z = pos.z + 9},
|
||||
{
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 495 B |
Loading…
Reference in New Issue