mods that hopefully work for a TechAge-based pack

This commit is contained in:
2026-09-09 06:27:51 -06:00
parent 4e6b08d194
commit c27db2a537
6234 changed files with 375578 additions and 0 deletions
@@ -0,0 +1,269 @@
--[[
TechAge
=======
Copyright (C) 2019-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA3 Distillation Tower
]]--
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
local Pipe = techage.LiquidPipe
local liquid = networks.liquid
local function orientation(pos, names)
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
for _,name in ipairs(names) do
if node.name == name then
local param2 = node.param2
node = minetest.get_node(pos)
node.param2 = param2
minetest.swap_node(pos, node)
return
end
end
minetest.remove_node(pos)
return true
end
local function after_place_node(pos, placer)
Pipe:after_place_node(pos)
end
local function after_dig_node(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
end
minetest.register_node("techage:ta3_distiller_base", {
description = S("TA3 Distillation Tower Base"),
tiles = {
-- up, down, right, left, back, front
"techage_concrete.png^techage_appl_arrowXL.png^techage_appl_hole_pipe.png",
"techage_concrete.png",
"techage_concrete.png",
"techage_concrete.png",
"techage_concrete.png^techage_appl_hole_pipe.png",
"techage_concrete.png",
},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {-6/8, -4/8, -6/8, 6/8, 4/8, 6/8},
},
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
collision_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
after_place_node = after_place_node,
after_dig_node = after_dig_node,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
liquid.register_nodes({"techage:ta3_distiller_base"}, Pipe, "pump", {"B"}, {})
minetest.register_node("techage:ta3_distiller1", {
description = S("TA3 Distillation Tower 1"),
tiles = {"techage_distiller1.png"},
drawtype = "mesh",
mesh = "techage_cylinder_14.obj",
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
collision_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
after_place_node = function(pos, placer)
local res = orientation(pos, {"techage:ta3_distiller_base"})
M(pos):set_int("outdir", networks.side_to_outdir(pos, "B"))
after_place_node(pos, placer)
return res
end,
after_dig_node = after_dig_node,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
liquid.register_nodes({"techage:ta3_distiller1"}, Pipe, "pump", {"F"}, {})
minetest.register_node("techage:ta3_distiller2", {
description = S("TA3 Distillation Tower 2"),
tiles = {"techage_distiller2.png"},
drawtype = "mesh",
mesh = "techage_cylinder_14.obj",
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
collision_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
after_place_node = function(pos, placer)
return orientation(pos, {"techage:ta3_distiller1", "techage:ta3_distiller3"})
end,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta3_distiller3", {
description = S("TA3 Distillation Tower 3"),
tiles = {"techage_distiller3.png"},
drawtype = "mesh",
mesh = "techage_cylinder_14.obj",
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
collision_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
after_place_node = function(pos, placer)
local res = orientation(pos, {"techage:ta3_distiller2"})
return res
end,
after_dig_node = after_dig_node,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
liquid.register_nodes({"techage:ta3_distiller3"}, Pipe, "pump", {"B"}, {})
minetest.register_node("techage:ta3_distiller4", {
description = S("TA3 Distillation Tower 4"),
tiles = {"techage_distiller4.png"},
drawtype = "mesh",
mesh = "techage_cylinder_14.obj",
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
collision_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
},
after_place_node = function(pos, placer)
local res = orientation(pos, {"techage:ta3_distiller3"})
after_place_node(pos, placer)
return res
end,
after_dig_node = after_dig_node,
paramtype = "light",
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
liquid.register_nodes({"techage:ta3_distiller4"}, Pipe, "pump", {"U"}, {})
local Liquids = {"techage:bitumen", "techage:fueloil", "techage:naphtha", "techage:gasoline", "techage:gas"}
local YPos = {-1, 2, 4, 6, 7}
techage.register_node({"techage:ta3_distiller1"}, {
on_transfer = function(pos, in_dir, topic, payload)
if topic == "put" then
local nvm = techage.get_nvm(pos)
nvm.idx = nvm.idx or 1
local outdir
if nvm.idx == 5 then
outdir = 6 -- up
else
outdir = M(pos):get_int("outdir")
end
local pos2 = {x = pos.x, y = pos.y + YPos[nvm.idx], z = pos.z}
local leftover = liquid.put(pos2, Pipe, outdir, Liquids[nvm.idx], 1)
if leftover == 0 then
nvm.idx = (nvm.idx % 5) + 1
end
return leftover
end
end,
})
minetest.register_craft({
output = 'techage:ta3_distiller2',
recipe = {
{'default:steel_ingot', 'default:tin_ingot', 'default:steel_ingot'},
{'techage:iron_ingot', 'techage:ta3_barrel_empty', 'techage:iron_ingot'},
{'default:steel_ingot', 'default:tin_ingot', 'default:steel_ingot'},
}
})
minetest.register_craft({
output = 'techage:ta3_distiller1',
recipe = {
{'', '', ''},
{'techage:ta3_pipeS', 'techage:ta3_distiller2', ''},
{'', '', ''},
}
})
minetest.register_craft({
output = 'techage:ta3_distiller3',
recipe = {
{'', '', ''},
{'', 'techage:ta3_distiller2', 'techage:ta3_pipeS'},
{'', '', ''},
}
})
minetest.register_craft({
output = 'techage:ta3_distiller4',
recipe = {
{'', 'techage:ta3_pipeS', ''},
{'', 'techage:ta3_distiller2', ''},
{'', '', ''},
}
})
minetest.register_craft({
output = 'techage:ta3_distiller_base',
recipe = {
{'basic_materials:concrete_block', 'techage:ta3_pipeS', 'basic_materials:concrete_block'},
{'', 'techage:ta3_pipeS', 'techage:ta3_pipeS'},
{'basic_materials:concrete_block', '', 'basic_materials:concrete_block'},
}
})
@@ -0,0 +1,327 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA3 Oil Drill Box
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
local STANDBY_TICKS = 2
local COUNTDOWN_TICKS = 4
local CYCLE_TIME = 16
local formspec0 = "size[5,4]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"image[1,0;3.4,3.4;techage_ta3.png]"..
"button_exit[1,3.2;3,1;build;"..S("Build derrick").."]"
local function play_sound(pos)
local mem = techage.get_mem(pos)
-- Stop any lingering handle first, so newly arrived clients get the fresh sound
if mem.handle then
minetest.sound_stop(mem.handle)
mem.handle = nil
end
mem.handle = minetest.sound_play("techage_oildrill", {
pos = pos,
gain = 1,
max_hear_distance = 15,
loop = true})
if mem.handle == -1 then
mem.handle = nil
minetest.after(1, play_sound, pos)
end
end
local function stop_sound(pos)
local mem = techage.get_mem(pos)
if mem.handle then
minetest.sound_stop(mem.handle)
-- Keep handle: on_node_load can re-send stop to clients that came back in range
end
end
local function formspec(self, pos, nvm)
if not nvm.assemble_build then
return formspec0
end
local depth = M(pos):get_int("depth")
local curr_depth = pos.y - (nvm.drill_pos or pos).y
return "size[8,8]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"list[context;src;1,1;1,1;]"..
"label[1.3,0.5;IN]"..
"item_image[1,1;1,1;techage:oil_drillbit]"..
"label[1,2;"..S("Drill Bit").."]"..
"label[0.5,3;"..S("Depth")..": "..curr_depth.."/"..depth.."]"..
"image[3.5,0;1,1;"..techage.get_power_image(pos, nvm).."]"..
"image[3.5,1;1,1;techage_form_arrow.png]"..
"image_button[3.5,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
"tooltip[3.5,2;1,1;"..self:get_state_tooltip(nvm).."]"..
"label[6.2,0.5;OUT]"..
"list[context;dst;6,1;1,1;]"..
"button_exit[5,3;3,1;remove;"..S("Remove derrick").."]"..
"list[current_player;main;0,4;8,4;]"..
"listring[context;dst]"..
"listring[current_player;main]"..
"listring[context;src]"..
"listring[current_player;main]"..
default.get_hotbar_bg(0, 4)
end
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
local crd = CRD(pos)
if listname == "src" then
crd.State:start_if_standby(pos)
return stack:get_count()
end
return 0
end
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index)
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
end
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
return stack:get_count()
end
local function on_rightclick(pos, node, clicker)
local nvm = techage.get_nvm(pos)
techage.set_activeformspec(pos, clicker)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
end
local function on_node_state_change(pos, old_state, new_state)
if new_state == techage.RUNNING then
play_sound(pos)
else
stop_sound(pos)
end
end
local function drilling(pos, crd, nvm, inv)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
nvm.drill_pos = nvm.drill_pos or {x=pos.x, y=pos.y-1, z=pos.z}
local owner = M(pos):get_string("owner")
local depth = M(pos):get_int("depth")
local curr_depth = pos.y - (nvm.drill_pos or pos).y
local node = techage.get_node_lvm(nvm.drill_pos)
local ndef = minetest.registered_nodes[node.name]
if not inv:contains_item("src", ItemStack("techage:oil_drillbit")) then
crd.State:idle(pos, nvm, S("Drill bits missing"))
elseif curr_depth >= depth then
M(pos):set_string("oil_found", "true")
crd.State:stop(pos, nvm)
elseif node.name == "techage:oilstorage" then -- old oil bubble node?
nvm.drill_pos.y = nvm.drill_pos.y-1
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
elseif minetest.is_protected(nvm.drill_pos, owner) then
crd.State:fault(pos, nvm, S("Drill area is protected"))
elseif node.name == "techage:oil_drillbit2" then
nvm.drill_pos.y = nvm.drill_pos.y-1
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
elseif minetest.get_item_group(node.name, "lava") >= 1 then
minetest.swap_node(nvm.drill_pos, {name = "techage:oil_drillbit2"})
inv:remove_item("src", ItemStack("techage:oil_drillbit"))
nvm.drill_pos.y = nvm.drill_pos.y-1
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
elseif techage.can_dig_node(node.name, ndef) then
local drop_name = techage.dropped_node(node, ndef)
if drop_name then
local item = ItemStack(drop_name)
if not inv:room_for_item("dst", item) then
crd.State:blocked(pos, nvm, S("item output blocked"))
return
end
inv:add_item("dst", item)
end
minetest.swap_node(nvm.drill_pos, {name = "techage:oil_drillbit2"})
inv:remove_item("src", ItemStack("techage:oil_drillbit"))
nvm.drill_pos.y = nvm.drill_pos.y-1
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
elseif node.name == "ignore" then
-- load world and pause the drilling for one step
minetest.emerge_area(nvm.drill_pos, nvm.drill_pos)
else
crd.State:blocked(pos, nvm, S("Cannot drill @1", node.name))
end
end
local function keep_running(pos, elapsed)
local nvm = techage.get_nvm(pos)
local crd = CRD(pos)
local inv = M(pos):get_inventory()
if inv then
drilling(pos, crd, nvm, inv)
end
if techage.is_activeformspec(pos) then
M(pos):set_string("formspec", formspec(crd.State, pos, nvm))
end
end
local function can_dig(pos, player)
if minetest.is_protected(pos, player:get_player_name()) then
return false
end
local nvm = techage.get_nvm(pos)
if nvm.assemble_locked or nvm.assemble_build then
return false
end
local inv = M(pos):get_inventory()
return inv:is_empty("dst") and inv:is_empty("src")
end
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
if fields.build then
techage.oiltower.build(pos, player:get_player_name())
elseif fields.remove then
local inv = M(pos):get_inventory()
if inv:is_empty("dst") and inv:is_empty("src") then
techage.oiltower.remove(pos, player:get_player_name())
end
else
local nvm = techage.get_nvm(pos)
if not nvm.assemble_locked and M(pos):get_string("oil_found") ~= "true" then
local nvm = techage.get_nvm(pos)
CRD(pos).State:state_button_event(pos, nvm, fields)
end
end
end
local tiles = {}
-- '#' will be replaced by the stage number
tiles.pas = {
-- up, down, right, left, back, front
"techage_filling_ta#.png^techage_frame_ta#_top.png",
"techage_filling_ta#.png^techage_frame_ta#.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
"techage_filling_ta#.png^techage_appl_oildrill.png^techage_frame_ta#.png",
"techage_filling_ta#.png^techage_appl_oildrill.png^techage_frame_ta#.png",
}
tiles.act = tiles.pas
local tubing = {
on_pull_item = function(pos, in_dir, num)
local meta = minetest.get_meta(pos)
if meta:get_int("pull_dir") == in_dir then
local inv = M(pos):get_inventory()
return techage.get_items(pos, inv, "dst", num)
end
end,
on_push_item = function(pos, in_dir, stack)
local nvm = techage.get_nvm(pos)
if not nvm.assemble_locked then
local meta = minetest.get_meta(pos)
if meta:get_int("push_dir") == in_dir then
local inv = M(pos):get_inventory()
CRD(pos).State:start_if_standby(pos)
return techage.put_items(inv, "src", stack)
end
end
end,
on_unpull_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos)
if meta:get_int("pull_dir") == in_dir then
local inv = M(pos):get_inventory()
return techage.put_items(inv, "dst", stack)
end
end,
on_recv_message = function(pos, src, topic, payload)
return CRD(pos).State:on_receive_message(pos, topic, payload)
end,
on_beduino_receive_cmnd = function(pos, src, topic, payload)
return CRD(pos).State:on_beduino_receive_cmnd(pos, topic, payload)
end,
on_beduino_request_data = function(pos, src, topic, payload)
return CRD(pos).State:on_beduino_request_data(pos, topic, payload)
end,
on_node_load = function(pos, node)
CRD(pos).State:on_node_load(pos)
local nvm = techage.get_nvm(pos)
nvm.assemble_locked = false
if nvm.techage_state == techage.RUNNING then
play_sound(pos) -- stops lingering handle and restarts fresh
else
stop_sound(pos) -- re-send stop to clients that came back in range
end
end,
}
local _, node_name_ta3, _ =
techage.register_consumer("drillbox", S("Oil Drill Box"), tiles, {
drawtype = "normal",
cycle_time = CYCLE_TIME,
standby_ticks = STANDBY_TICKS,
formspec = formspec,
tubing = tubing,
on_state_change = on_node_state_change,
after_place_node = function(pos, placer)
local inv = M(pos):get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 1)
local info = techage.explore.get_oil_info(pos)
M(pos):set_int("depth", info.depth - 5) -- oil bubble
M(pos):set_int("amount", info.amount)
M(pos):set_string("oil_found", "false")
M(pos):set_string("owner", placer:get_player_name())
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldmetadata.fields.oil_found == "true" then
minetest.set_node(pos, {name = "techage:oil_source"})
end
end,
can_dig = can_dig,
node_timer = keep_running,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
groups = {choppy=2, cracky=2, crumbly=2},
sounds = default.node_sound_wood_defaults(),
num_items = {0,1,1,1},
power_consumption = {0,10,16,24},
tube_sides = {L=1, R=1},
},
{false, false, true, false}) -- TA3 only
minetest.register_craft({
output = node_name_ta3,
recipe = {
{"default:steel_ingot", "default:diamond", "default:steel_ingot"},
{"techage:tubeS", "basic_materials:gear_steel", "techage:tubeS"},
{"default:steel_ingot", "techage:vacuum_tube", "default:steel_ingot"},
},
})
@@ -0,0 +1,350 @@
--[[
TechAge
=======
Copyright (C) 2019-2020 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA3 Oil Explorer
]]--
-- for lazy programmers
local M = minetest.get_meta
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local S = techage.S
local PROBABILITY = 100
local OIL_MIN = 4096
local OIL_MAX = 20000
local DEPTH_MIN = 16
local DEPTH_MAX = 25*16
local DEPTH_STEP = 16
local YPOS_MAX = -6*16 -- oil can't found below this level
local OIL_BUBBLE_SIZE = 4096
local seed = tonumber(minetest.settings:get("techage_oil_exploration_seed")) or 1234 -- confidental!
local InvalidGroundNodes = {
["air"] = true,
}
local ValidGroundNodes = {
["default:cobble"] = true,
["default:mossycobble"] = true,
["default:desert_cobble"] = true,
}
local function oil_amount(pos)
if pos.y > YPOS_MAX then return 0 end
local block_key = seed +
math.floor((pos.z + 32768) / 16) * 4096 * 4096 +
math.floor((pos.y + 32768) / 16) * 4096 +
math.floor((pos.x + 32768) / 16)
math.randomseed(block_key)
math.random(); math.random(); math.random()
local has_oil = math.random(1,PROBABILITY) == 1
if has_oil then
local amount = math.random(OIL_MIN, OIL_MAX)
return amount
end
-- Generate new randomseed after use
math.randomseed(os.time())
return 0
end
local function center(coord)
return (math.floor(coord/16) * 16) + 8
end
local function basis(coord)
return (math.floor(coord/16) * 16)
end
-- determine the mapblock coordinates
local function mapblock_coordinates(pos)
local pos1 = {x = basis(pos.x), y = basis(pos.y), z = basis(pos.z)}
local pos2 = {x = pos1.x + 15, y = pos1.y + 15, z = pos1.z + 15}
return pos1, pos2
end
local function calc_depth(pos, explore_pos)
return pos.y - explore_pos.y + 1
end
-- posC is the center position of the oil bubble
-- idx is the vmdata index
-- function returns the real position {x,y,z}
local function calc_vmdata_pos(posC, idx)
local rest, xoffs, yoffs, zoffs
rest = idx - 1
xoffs = rest % 16
rest = math.floor(rest / 16)
zoffs = rest % 16
rest = math.floor(rest / 16)
yoffs = rest % 16
return {x = basis(posC.x) + xoffs, y = basis(posC.y) + yoffs, z = basis(posC.z) + zoffs}
end
local function calc_vmdata_index(xoffs, yoffs, zoffs)
return (xoffs + (yoffs * 16) + (zoffs * 16 * 16)) + 1
end
-- from/to are x/z-offsets (0..15) for one layer of oil within one mapblock
local function gen_oil_slice(yoffs, from, to, vmdata, id)
for xoffs = from, to do
for zoffs = from, to do
vmdata[calc_vmdata_index(xoffs, yoffs, zoffs)] = id
end
end
end
local function gen_oil_bubble(vmdata)
local id = minetest.get_content_id("techage:oil_source")
gen_oil_slice(1, 3, 12, vmdata, id)
gen_oil_slice(2, 2, 13, vmdata, id)
for offs = 3, 12 do
gen_oil_slice(offs, 1, 14, vmdata, id)
end
gen_oil_slice(13, 2, 13, vmdata, id)
gen_oil_slice(14, 3, 12, vmdata, id)
end
local function useable_stone_block(data)
local valid = {}
for _,id in ipairs(data) do
if not valid[id] then
local itemname = minetest.get_name_from_content_id(id)
if not ValidGroundNodes[itemname] then
local ndef = minetest.registered_nodes[itemname]
if InvalidGroundNodes[itemname] or not ndef or ndef.is_ground_content == false then
return false
end
end
valid[id] = true
end
end
return true
end
local function get_next_explore_pos(pos)
local meta = M(pos)
local ypos = meta:get_int("exploration_ypos")
if ypos == 0 then
ypos = math.min(YPOS_MAX, center(pos.y))
end
local d = calc_depth(pos, {y = ypos})
if d + DEPTH_STEP < DEPTH_MAX then
ypos = ypos - DEPTH_STEP
local posC = {x = center(pos.x), y = center(ypos), z = center(pos.z)}
local node = techage.get_node_lvm(posC)
if node.name ~= "ignore" then
meta:set_int("exploration_ypos", ypos)
else
-- load world and pause for one step
minetest.emerge_area(posC, posC)
end
end
return {x = center(pos.x), y = center(ypos), z = center(pos.z)}
end
local function get_oil_amount(pos)
return M(pos):get_int("oil_amount")
end
local function set_oil_amount(pos, amount)
minetest.set_node(pos, {name = "techage:oilstorage"})
M(pos):set_int("oil_amount", amount)
M(pos):set_int("initial_oil_amount", amount)
end
local function status(pos, player_name, explore_pos, amount)
local depth = calc_depth(pos, explore_pos)
minetest.chat_send_player(player_name,
"[TA Oil] "..P2S(explore_pos).." "..S("depth")..": "..depth..", "..S("Oil")..": "..amount.." ")
end
local function marker(player_name, pos)
local posC = {x = center(pos.x), y = pos.y, z = center(pos.z)}
local pos1 = {x = posC.x - 2, y = posC.y - 2, z = posC.z - 2}
local pos2 = {x = posC.x + 2, y = posC.y + 7, z = posC.z + 2}
techage.switch_region(player_name, pos1, pos2)
end
-- check if oil can be placed and if so, do it and return true
local function generate_oil_bubble(posC, amount)
local pos1, pos2 = mapblock_coordinates(posC)
local vm = minetest.get_voxel_manip(pos1, pos2)
local data = vm:get_data()
if useable_stone_block(data) then
gen_oil_bubble(data)
vm:set_data(data)
vm:write_to_map()
vm:update_map()
set_oil_amount(posC, amount)
return true
end
return false
end
local function explore_area(pos, node, player_name)
if M(pos):get_int("oil_amount") == 0 then -- nothing found so far?
local posC, amount
node.name = "techage:oilexplorer_on"
minetest.swap_node(pos, node)
minetest.get_node_timer(pos):start(2.2)
minetest.sound_play("techage_explore", {
pos = pos,
max_hear_distance = 8})
for i = 1,4 do
posC = get_next_explore_pos(pos)
amount = oil_amount(posC)
if amount > 0 then
break
end
end
if amount > 0 then
if get_oil_amount(posC) == 0 then -- not explored so far?
if generate_oil_bubble(posC, amount) then
marker(player_name, pos)
else
amount = 0
end
end
M(pos):set_int("oil_amount", amount)
end
minetest.after(2, status, pos, player_name, posC, amount)
else
local explore_pos = {x = center(pos.x), y = M(pos):get_int("exploration_ypos"), z = center(pos.z)}
status(pos, player_name, explore_pos, M(pos):get_int("oil_amount"))
marker(player_name, pos)
end
end
-- Used as storage for already explored blocks
minetest.register_node("techage:oilstorage", {
description = S("TA3 Oil Storage"),
tiles = {"default_stone.png"},
groups = {not_in_creative_inventory=1},
diggable = false,
drop = "",
is_ground_content = false,
})
minetest.register_node("techage:oilexplorer", {
description = S("TA3 Oil Explorer"),
tiles = {
"techage_filling_ta3.png^techage_appl_oilexplorer_top.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_oilexplorer.png",
},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
explore_area(pos, node, clicker:get_player_name())
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
techage.unmark_region(digger:get_player_name())
local xpos = (math.floor(pos.x / 16) * 16)
local ypos = (math.floor(pos.y / 16) * 16)
local zpos = (math.floor(pos.z / 16) * 16)
local pos1 = {x=xpos, y=ypos, z=zpos}
local pos2 = {x=xpos+15, y=ypos+15, z=zpos+15}
techage.mark_region(digger:get_player_name(), pos1, pos2, nil, 16)
end,
is_ground_content = false,
groups = {snappy=2,cracky=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("techage:oilexplorer_on", {
description = S("TA3 Oil Explorer"),
tiles = {
{
name = "techage_filling4_ta3.png^techage_appl_oilexplorer_top4.png^techage_frame4_ta3_top.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 1.2,
},
},
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_oilexplorer.png",
},
on_timer = function(pos,elapsed)
local node = minetest.get_node(pos)
node.name = "techage:oilexplorer"
minetest.swap_node(pos, node)
end,
diggable = false,
is_ground_content = false,
paramtype = "light",
light_source = 8,
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "techage:oilexplorer",
recipe = {
{"group:wood", "default:diamond", "group:wood"},
{"techage:baborium_ingot", "basic_materials:gear_steel", "techage:usmium_nuggets"},
{"group:wood", "techage:vacuum_tube", "group:wood"},
},
})
techage.explore = {}
function techage.explore.get_oil_info(pos)
local amount = 0
local depth = DEPTH_MIN
local posC = {x = center(pos.x), y = center(pos.y) - DEPTH_MIN, z = center(pos.z)}
while amount == 0 and depth < DEPTH_MAX do
amount = get_oil_amount(posC)
depth = calc_depth(pos, posC)
posC.y = posC.y - DEPTH_STEP
end
posC.y = posC.y + DEPTH_STEP
return {depth = depth, amount = amount, storage_pos = posC}
end
function techage.explore.get_oil_amount(posC)
local meta = M(posC)
if meta:get_int("initial_oil_amount") == 0 then
meta:set_int("initial_oil_amount", meta:get_int("oil_amount"))
end
return meta:get_int("oil_amount"), meta:get_int("initial_oil_amount")
end
function techage.explore.dec_oil_amount(posC)
local oil_amount, oil_initial = techage.explore.get_oil_amount(posC)
oil_amount = oil_amount - 1
M(posC):set_int("oil_amount", oil_amount)
local idx = math.floor(oil_amount * OIL_BUBBLE_SIZE / oil_initial)
idx = idx + 256 -- last level is stone, so add one level
if idx <= (OIL_BUBBLE_SIZE - 256) then -- first level is stone, too
local pos = calc_vmdata_pos(posC, idx)
local node = techage.get_node_lvm(pos)
if node.name == "techage:oil_source" then
minetest.remove_node(pos)
end
end
return oil_amount
end
@@ -0,0 +1,182 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA3 Gas flare
]]--
local HEIGHT = 7
local function remove_flame(pos)
local idx
for idx=HEIGHT,1,-1 do
pos = {x=pos.x, y=pos.y+1, z=pos.z}
local node = minetest.get_node(pos)
if string.find(node.name, "techage:flame") then
minetest.remove_node(pos)
end
end
end
local function flame(pos)
local idx
for idx=HEIGHT,1,-1 do
pos = {x=pos.x, y=pos.y+1, z=pos.z}
idx = math.min(idx, 12)
local node = minetest.get_node(pos)
if node.name ~= "air" then
return
end
minetest.add_node(pos, {name = "techage:flame"..math.min(idx,7)})
local meta = minetest.get_meta(pos)
end
end
local lRatio = {120, 110, 95, 75, 55, 28, 0}
local lColor = {"400040", "600020", "800000", "800000", "800000", "800000", "800000"}
for idx,ratio in ipairs(lRatio) do
local color = "techage_flame_animated.png^[colorize:#"..lColor[idx].."B0:"..ratio
minetest.register_node("techage:flame"..idx, {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-3/8, -4/8, -2/8, 3/8, 4/8, 2/8},
{-2/8, -4/8, -3/8, 2/8, 4/8, 3/8},
},
},
tiles = {
{
name = color,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1
},
},
},
after_destruct = function(pos, oldnode)
pos.y = pos.y + 1
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "techage_flame") > 0 then
minetest.remove_node(pos)
end
end,
use_texture_alpha = techage.BLEND,
inventory_image = "techage_flame.png",
paramtype = "light",
light_source = 13,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
damage_per_second = 4 + idx,
groups = {igniter = 2, dig_immediate = 3, techage_flame=1, not_in_creative_inventory=1},
drop = "",
})
end
local function start_flarestack(pos, playername)
if minetest.is_protected(
{x=pos.x, y=pos.y+1, z=pos.z},
playername) then
return
end
local meta = minetest.get_meta(pos)
flame({x=pos.x, y=pos.y+1, z=pos.z})
local handle = minetest.sound_play("gasflare", {
pos = pos,
max_hear_distance = 20,
gain = 1,
loop = true})
--print("handle", handle)
meta:set_int("handle", handle)
end
local function stop_flarestack(pos, handle)
remove_flame({x=pos.x, y=pos.y+1, z=pos.z})
minetest.sound_stop(handle)
end
minetest.register_node("techage:gasflare", {
description = "gas flare",
tiles = {
"techage_gasflare.png",
"techage_gasflare.png",
"techage_gasflare.png",
"techage_gasflare.png",
"techage_gasflare.png",
"techage_gasflare.png^techage_appl_hole_pipe.png",
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
if node.name ~= "air" then
return
end
minetest.add_node({x=pos.x, y=pos.y+1, z=pos.z}, {name = "techage:gasflare2"})
end,
on_punch = function(pos, node, puncher)
local meta = minetest.get_meta(pos)
local handle = meta:get_int("handle")
minetest.sound_stop(handle)
start_flarestack(pos, puncher:get_player_name())
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
--print(dump(oldmetadata))
stop_flarestack(pos, oldmetadata.fields.handle)
local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
if node.name == "techage:gasflare2" then
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
end
end,
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("techage:gasflare2", {
description = "",
tiles = {
"techage_gasflare.png^techage_appl_hole_tube.png",
"techage_gasflare.png"
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-1/8, -4/8, -1/8, 1/8, 4/8, 1/8},
{-4/8, 3/8, -4/8, 4/8, 4/8, 4/8},
},
},
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
paramtype2 = "facedir",
diggable = false,
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
})
@@ -0,0 +1,265 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA3 Pumpjack
]]--
-- for lazy programmers
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local M = minetest.get_meta
local P = minetest.string_to_pos
local S = techage.S
local Pipe = techage.LiquidPipe
local liquid = networks.liquid
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
local STANDBY_TICKS = 2
local COUNTDOWN_TICKS = 10
local CYCLE_TIME = 8
local function has_oil(pos, meta)
local storage_pos = meta:get_string("storage_pos")
if storage_pos ~= "" then
local amount, initial_amount = techage.explore.get_oil_amount(P(storage_pos))
if amount > 0 then
return true
end
end
end
local function dec_oil_item(pos, meta)
local storage_pos = meta:get_string("storage_pos")
if storage_pos ~= "" then
techage.explore.dec_oil_amount(P(storage_pos))
end
end
local function formspec(self, pos, nvm)
local amount = 0
local storage_pos = M(pos):get_string("storage_pos")
if storage_pos ~= "" then
amount = techage.explore.get_oil_amount(P(storage_pos))
end
return "size[5,3]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"box[0,-0.1;4.8,0.5;#c6e8ff]"..
"label[1.5,-0.1;"..minetest.colorize( "#000000", S("Pumpjack")).."]"..
"image[0.5,1.5;1,1;techage_liquid2_inv.png^[colorize:#000000^techage_liquid1_inv.png]"..
"image[4,0.8;1,1;"..techage.get_power_image(pos, nvm).."]"..
"tooltip[4,0.8;1,1;"..S("needs power").."]"..
"label[0,0.8;"..S("Oil amount")..": "..amount.."]"..
"image_button[2,2.2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
"tooltip[2,2.2;1,1;"..self:get_state_tooltip(nvm).."]"
end
local function play_sound(pos)
local mem = techage.get_mem(pos)
-- Stop any lingering handle first, so newly arrived clients get the fresh sound
if mem.handle then
minetest.sound_stop(mem.handle)
mem.handle = nil
end
mem.handle = minetest.sound_play("techage_reboiler", {
pos = pos,
gain = 1,
max_hear_distance = 15,
loop = true})
if mem.handle == -1 then
mem.handle = nil
minetest.after(1, play_sound, pos)
end
end
local function stop_sound(pos)
local mem = techage.get_mem(pos)
if mem.handle then
minetest.sound_stop(mem.handle)
-- Keep handle: on_node_load can re-send stop to clients that came back in range
end
end
local function on_node_state_change(pos, old_state, new_state)
if new_state == techage.RUNNING then
play_sound(pos)
else
stop_sound(pos)
end
end
local function on_rightclick(pos, node, clicker)
local nvm = techage.get_nvm(pos)
techage.set_activeformspec(pos, clicker)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
end
local function pumping(pos, crd, meta, nvm)
if has_oil(pos, meta) then
local leftover = liquid.put(pos, Pipe, 6, "techage:oil_source", 1)
if leftover and leftover > 0 then
crd.State:blocked(pos, nvm)
stop_sound(pos)
return
end
dec_oil_item(pos, meta)
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
return
end
crd.State:fault(pos, nvm, S("no oil"))
end
local function keep_running(pos, elapsed)
local nvm = techage.get_nvm(pos)
local crd = CRD(pos)
pumping(pos, crd, M(pos), nvm)
if techage.is_activeformspec(pos) then
M(pos):set_string("formspec", formspec(crd.State, pos, nvm))
end
end
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local nvm = techage.get_nvm(pos)
CRD(pos).State:state_button_event(pos, nvm, fields)
end
local tiles = {}
-- '#' will be replaced by the stage number
tiles.pas = {
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_hole_pipe.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_hole_pipe.png",
"techage_appl_pumpjack.png^techage_frame_ta#.png",
"techage_appl_pumpjack.png^techage_frame_ta#.png",
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png^[transformR90]",
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png^[transformR90]",
}
tiles.act = {
-- up, down, right, left, back, front
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_hole_pipe.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_hole_pipe.png",
{
name = "techage_appl_pumpjack14.png^techage_frame14_ta#.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
{
name = "techage_appl_pumpjack14.png^techage_frame14_ta#.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png^[transformR90]",
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png^[transformR90]",
}
local tubing = {
on_recv_message = function(pos, src, topic, payload)
if topic == "load" then
local storage_pos = M(pos):get_string("storage_pos")
if storage_pos ~= "" then
local amount, capa = techage.explore.get_oil_amount(P(storage_pos))
if amount and capa and capa > 0 then
return techage.power.percent(capa or 0, amount or 0), amount or 0
end
end
else
return CRD(pos).State:on_receive_message(pos, topic, payload)
end
end,
on_beduino_request_data = function(pos, src, topic, payload)
if topic == 134 then -- Load
local storage_pos = M(pos):get_string("storage_pos")
if storage_pos ~= "" then
local amount, capa = techage.explore.get_oil_amount(P(storage_pos))
if amount and capa and capa > 0 then
if payload[1] == 1 then
return 0, {techage.power.percent(capa or 0, amount or 0)}
else
return 0, {math.min(amount or 0, 65535)}
end
end
end
return 2
else
return CRD(pos).State:on_beduino_request_data(pos, topic, payload)
end
end,
on_node_load = function(pos, node)
CRD(pos).State:on_node_load(pos)
if node.name == "techage:ta3_pumpjack_act" then
play_sound(pos) -- stops lingering handle and restarts fresh
else
stop_sound(pos) -- re-send stop to clients that came back in range
end
end,
}
local _, node_name_ta3, _ =
techage.register_consumer("pumpjack", S("Oil Pumpjack"), tiles, {
cycle_time = CYCLE_TIME,
standby_ticks = STANDBY_TICKS,
formspec = formspec,
tubing = tubing,
on_state_change = on_node_state_change,
after_place_node = function(pos, placer)
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
if node.name == "techage:oil_drillbit2" then
local info = techage.explore.get_oil_info(pos)
if info then
M(pos):set_string("storage_pos", P2S(info.storage_pos))
end
end
Pipe:after_place_node(pos)
end,
power_sides = {F=1, B=1, L=1, R=1, D=1},
on_rightclick = on_rightclick,
on_receive_fields = on_receive_fields,
node_timer = keep_running,
on_rotate = screwdriver.disallow,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
end,
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
num_items = {0,1,1,1},
power_consumption = {0,16,16,16},
},
{false, false, true, false}) -- TA3 only
minetest.register_craft({
output = "techage:ta3_pumpjack_pas",
recipe = {
{"", "techage:usmium_nuggets", ""},
{"dye:red", "techage:ta3_pusher_pas", "dye:red"},
{"", "techage:oil_drillbit", ""},
},
})
liquid.register_nodes({"techage:ta3_pumpjack_pas", "techage:ta3_pumpjack_act"}, Pipe, "pump", {"U"}, {})
@@ -0,0 +1,278 @@
--[[
TechAge
=======
Copyright (C) 2019-2022 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA3 Oil Reboiler
]]--
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
local Flip = networks.Flip
local Pipe = techage.LiquidPipe
local Cable = techage.ElectricCable
local liquid = networks.liquid
local power = networks.power
local CYCLE_TIME = 2
local WAITING_CYCLES = 5 -- in case BLOCKED
local PWR_NEEDED = 14
local function play_sound(pos)
local mem = techage.get_mem(pos)
-- Stop any lingering handle first, so newly arrived clients get the fresh sound
if mem.handle then
minetest.sound_stop(mem.handle)
mem.handle = nil
end
mem.handle = minetest.sound_play("techage_reboiler", {
pos = pos,
gain = 1,
max_hear_distance = 15,
loop = true})
if mem.handle == -1 then
mem.handle = nil
minetest.after(1, play_sound, pos)
end
end
local function stop_sound(pos)
local mem = techage.get_mem(pos)
if mem.handle then
minetest.sound_stop(mem.handle)
-- Keep handle: on_node_load can re-send stop to clients that came back in range
end
end
local function swap_node(pos, on)
local nvm = techage.get_nvm(pos)
local node = techage.get_node_lvm(pos)
if on and node.name == "techage:ta3_reboiler" then
node.name = "techage:ta3_reboiler_on"
minetest.swap_node(pos, node)
play_sound(pos)
elseif not on and node.name == "techage:ta3_reboiler_on" then
node.name = "techage:ta3_reboiler"
minetest.swap_node(pos, node)
stop_sound(pos)
end
end
local function pump_cmnd(pos)
local leftover = techage.transfer(
pos,
"R", -- outdir
"put", -- topic
nil, -- payload
Pipe, -- Pipe
{"techage:ta3_distiller1"})
-- number of processed oil items
return 1 - (tonumber(leftover) or 1)
end
local function new_state(pos, nvm, state)
if nvm.state ~= state then
nvm.state = state
M(pos):set_string("infotext", S("TA3 Oil Reboiler") .. ": " .. techage.StateStrings[state])
swap_node(pos, state == techage.RUNNING)
end
end
local function on_timer(pos)
local nvm = techage.get_nvm(pos)
nvm.oil_amount = nvm.oil_amount or 0
-- Power handling
if nvm.state == techage.STOPPED then
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
if consumed == PWR_NEEDED then
new_state(pos, nvm, techage.RUNNING)
return true
end
elseif nvm.state == techage.RUNNING then
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
if consumed < PWR_NEEDED then
local nvm = techage.get_nvm(pos)
new_state(pos, nvm, techage.STOPPED)
return true
end
elseif nvm.state == techage.BLOCKED or nvm.state == techage.STANDBY then
if not power.power_available(pos, Cable) then
local nvm = techage.get_nvm(pos)
new_state(pos, nvm, techage.STOPPED)
return true
end
end
-- Oil handling
if nvm.state == techage.RUNNING then
if nvm.oil_amount >= 1 then
local processed = pump_cmnd(pos)
nvm.oil_amount = nvm.oil_amount - processed
nvm.waiting_cycles = WAITING_CYCLES
if processed == 0 then
new_state(pos, nvm, techage.BLOCKED)
else
new_state(pos, nvm, techage.RUNNING)
end
else
nvm.waiting_cycles = (nvm.waiting_cycles or 0) - 1
if nvm.waiting_cycles <= 0 then
new_state(pos, nvm, techage.STANDBY)
end
end
elseif nvm.state == techage.BLOCKED then
nvm.waiting_cycles = nvm.waiting_cycles - 1
if nvm.waiting_cycles <= 0 then
new_state(pos, nvm, techage.RUNNING)
end
else
-- STANDBY: 'put' will trigger the state change
end
return true
end
local function after_place_node(pos)
local nvm = techage.get_nvm(pos)
new_state(pos, nvm, techage.STOPPED)
Pipe:after_place_node(pos)
Cable:after_place_node(pos)
end
local function after_dig_node(pos, oldnode)
Pipe:after_dig_node(pos)
Cable:after_dig_node(pos)
techage.del_mem(pos)
end
local function on_rightclick(pos, node, clicker)
local nvm = techage.get_nvm(pos)
nvm.oil_amount = 0
new_state(pos, nvm, techage.STOPPED)
minetest.get_node_timer(pos):start(CYCLE_TIME)
end
minetest.register_node("techage:ta3_reboiler", {
description = S("TA3 Oil Reboiler"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_reboiler.png^techage_frame_ta3.png^[transformFX",
"techage_filling_ta3.png^techage_appl_reboiler.png^techage_frame_ta3.png",
},
on_timer = on_timer,
after_place_node = after_place_node,
after_dig_node = after_dig_node,
on_rightclick = on_rightclick,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
groups = {cracky=2},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta3_reboiler_on", {
description = S("TA3 Oil Reboiler"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png^techage_appl_arrow.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_hole_pipe.png^techage_frame_ta3.png",
{
name = "techage_filling4_ta3.png^techage_appl_reboiler4.png^techage_frame4_ta3.png^[transformFX",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
{
name = "techage_filling4_ta3.png^techage_appl_reboiler4.png^techage_frame4_ta3.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
},
on_timer = on_timer,
on_rightclick = on_rightclick,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
diggable = false,
groups = {not_in_creative_inventory=1},
is_ground_content = false,
sounds = default.node_sound_metal_defaults(),
})
local liquid_def = {
peek = function(pos)
local nvm = techage.get_nvm(pos)
return liquid.srv_peek(nvm)
end,
put = function(pos, indir, name, amount)
local nvm = techage.get_nvm(pos)
nvm.oil_amount = nvm.oil_amount or 0
if nvm.state == techage.STANDBY or nvm.state == techage.RUNNING then
if name == "techage:oil_source" and amount > 0 then
if nvm.state == techage.STANDBY then
new_state(pos, nvm, techage.RUNNING)
end
-- Take one oil item every 2 cycles
-- Hint: We have to take two items, because the pump will pause for 4 cycles,
-- if nothing is taken.
nvm.take = nvm.take ~= true
if nvm.take and nvm.oil_amount < 5 then
nvm.oil_amount = nvm.oil_amount + 2
return amount - 2
end
end
end
return amount
end
}
liquid.register_nodes({"techage:ta3_reboiler", "techage:ta3_reboiler_on"}, Pipe, "tank", {"L", "R"}, liquid_def)
power.register_nodes({"techage:ta3_reboiler", "techage:ta3_reboiler_on"}, Cable, "con")
techage.register_node({"techage:ta3_reboiler", "techage:ta3_reboiler_on"}, {
on_node_load = function(pos, node)
if node.name == "techage:ta3_reboiler_on" then
play_sound(pos) -- stops lingering handle and restarts fresh
else
stop_sound(pos) -- re-send stop to clients that came back in range
end
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
})
minetest.register_craft({
output = "techage:ta3_reboiler",
recipe = {
{"", "basic_materials:heating_element", ""},
{"default:mese_crystal_fragment", "techage:t3_pump", "default:mese_crystal_fragment"},
{"", "basic_materials:heating_element", ""},
},
})
+286
View File
@@ -0,0 +1,286 @@
--[[
TechAge
=======
Copyright (C) 2019-2020 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
TA3 Oil Tower
]]--
-- for lazy programmers
local P = minetest.string_to_pos
local M = minetest.get_meta
local S = techage.S
minetest.register_node("techage:oiltower1", {
description = S("TA3 Derrick"),
tiles = {
"techage_oil_tower1.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, -7/16, 8/16, 8/16},
{ 7/16, -8/16, -8/16, 8/16, 8/16, 8/16},
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16},
{-8/16, 7/16, -8/16, 8/16, 8/16, 8/16},
{-8/16, -8/16, -8/16, 8/16, 8/16, -7/16},
{-8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
},
},
drop = "",
diggable = false,
paramtype2 = "facedir",
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
groups = {not_in_creative_inventory = 1},
is_ground_content = false,
})
minetest.register_node("techage:oiltower2", {
description = S("TA3 Derrick"),
tiles = {
-- up, down, right, left, back, front
"techage_oil_tower_top.png^[transformR180",
"techage_oil_tower_top.png^[transformR180",
"techage_oil_tower2.png^[transformFX",
"techage_oil_tower2.png",
"techage_oil_tower2.png",
"techage_oil_tower2.png^[transformFX",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, -7/16, 8/16, 4/16},
{ 3/16, -8/16, -8/16, 4/16, 8/16, 4/16},
{-8/16, -8/16, -8/16, 4/16, -7/16, 4/16},
{-8/16, 7/16, -8/16, 4/16, 8/16, 4/16},
{-8/16, -8/16, -8/16, 4/16, 8/16, -7/16},
{-8/16, -8/16, 3/16, 4/16, 8/16, 4/16},
},
},
drop = "",
diggable = false,
paramtype2 = "facedir",
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
groups = {not_in_creative_inventory = 1},
is_ground_content = false,
})
minetest.register_node("techage:oiltower3", {
description = S("TA3 Derrick"),
tiles = {
-- up, down, right, left, back, front
"techage_oil_tower_top.png^[transformR180",
"techage_oil_tower_top.png^[transformR180",
"techage_oil_tower3.png^[transformFX",
"techage_oil_tower3.png",
"techage_oil_tower3.png",
"techage_oil_tower3.png^[transformFX",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, -7/16, 8/16, 0/16},
{-1/16, -8/16, -8/16, 0/16, 8/16, 0/16},
{-8/16, -8/16, -8/16, 0/16, -7/16, 0/16},
{-8/16, 7/16, -8/16, 0/16, 8/16, 0/16},
{-8/16, -8/16, -8/16, 0/16, 8/16, -7/16},
{-8/16, -8/16, -1/16, 0/16, 8/16, 0/16},
},
},
drop = "",
diggable = false,
paramtype2 = "facedir",
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
groups = {not_in_creative_inventory = 1},
is_ground_content = false,
})
minetest.register_node("techage:oiltower4", {
description = S("TA3 Derrick"),
tiles = {
-- up, down, right, left, back, front
"techage_oil_tower_top.png^[transformR180",
"techage_oil_tower_top.png^[transformR180",
"techage_oil_tower4.png^[transformFX",
"techage_oil_tower4.png",
"techage_oil_tower4.png",
"techage_oil_tower4.png^[transformFX",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, -7/16, 8/16, -4/16},
{-5/16, -8/16, -8/16, -4/16, 8/16, -4/16},
{-8/16, -8/16, -8/16, -4/16, -7/16, -4/16},
{-8/16, 7/16, -8/16, -4/16, 8/16, -4/16},
{-8/16, -8/16, -8/16, -4/16, 8/16, -7/16},
{-8/16, -8/16, -5/16, -4/16, 8/16, -4/16},
},
},
drop = "",
diggable = false,
paramtype2 = "facedir",
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
groups = {not_in_creative_inventory = 1},
is_ground_content = false,
})
minetest.register_node("techage:oiltower5", {
description = S("TA4 Derrick"),
tiles = {
-- up, down, right, left, back, front
"techage_oil_tower1.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, 7/16, 8/16, 8/16, 8/16},
},
},
drop = "",
diggable = false,
paramtype2 = "facedir",
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
groups = {not_in_creative_inventory = 1},
is_ground_content = false,
})
minetest.register_node("techage:oil_drillbit", {
description = S("TA3 Drill Pipe"),
drawtype = "plantlike",
tiles = {"techage_oil_drillbit.png"},
inventory_image = "techage_oil_drillbit_inv.png",
wield_image = "techage_oil_drillbit_inv.png",
visual_scale = 1,
paramtype = "light",
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
groups = {cracky = 1},
is_ground_content = false,
})
minetest.register_node("techage:oil_drillbit2", {
description = S("TA3 Drill Pipe"),
drawtype = "plantlike",
tiles = {"techage_oil_drillbit.png"},
inventory_image = "techage_oil_drillbit_inv.png",
wield_image = "techage_oil_drillbit_inv.png",
visual_scale = 1,
paramtype = "light",
use_texture_alpha = techage.CLIP,
drop = "",
diggable = false,
sunlight_propagates = true,
groups = {not_in_creative_inventory = 1},
is_ground_content = false,
})
local AssemblyPlan = {
-- y-offs, path, facedir-offs, name
-- level 0
{ 0, {0,1}, 0, "techage:oiltower1"},
{ 0, {0,3}, 0, "techage:oiltower1"},
{ 0, {2,1}, 0, "techage:oiltower1"},
{ 0, {2,3}, 0, "techage:oiltower1"},
-- level 1
{ 1, {0,1}, 0, "techage:oiltower1"},
{ 1, {0,3}, 0, "techage:oiltower1"},
{ 1, {2,1}, 0, "techage:oiltower1"},
{ 1, {2,3}, 0, "techage:oiltower1"},
{ 1, {0}, 2, "techage:oiltower5"},
{ 1, {1}, 3, "techage:oiltower5"},
{ 1, {2}, 0, "techage:oiltower5"},
{ 1, {3}, 1, "techage:oiltower5"},
-- level 2
{ 2, {0,1}, 0, "techage:oiltower2"},
{ 2, {0,3}, 3, "techage:oiltower2"},
{ 2, {2,1}, 1, "techage:oiltower2"},
{ 2, {2,3}, 2, "techage:oiltower2"},
{ 2, {0}, 2, "techage:oiltower5"},
{ 2, {1}, 3, "techage:oiltower5"},
{ 2, {2}, 0, "techage:oiltower5"},
{ 2, {3}, 1, "techage:oiltower5"},
-- level 3
{ 3, {0,1}, 0, "techage:oiltower3"},
{ 3, {0,3}, 3, "techage:oiltower3"},
{ 3, {2,1}, 1, "techage:oiltower3"},
{ 3, {2,3}, 2, "techage:oiltower3"},
{ 3, {0}, 2, "techage:oiltower5"},
{ 3, {1}, 3, "techage:oiltower5"},
{ 3, {2}, 0, "techage:oiltower5"},
{ 3, {3}, 1, "techage:oiltower5"},
-- level 4
{ 4, {0,1}, 0, "techage:oiltower4"},
{ 4, {0,3}, 3, "techage:oiltower4"},
{ 4, {2,1}, 1, "techage:oiltower4"},
{ 4, {2,3}, 2, "techage:oiltower4"},
{ 4, {0}, 2, "techage:oiltower5"},
{ 4, {1}, 3, "techage:oiltower5"},
{ 4, {2}, 0, "techage:oiltower5"},
{ 4, {3}, 1, "techage:oiltower5"},
-- level 5
{ 5, {0}, 2, "techage:oiltower5"},
{ 5, {1}, 3, "techage:oiltower5"},
{ 5, {2}, 0, "techage:oiltower5"},
{ 5, {3}, 1, "techage:oiltower5"},
-- level 6
{ 6, {0}, 2, "techage:oiltower5"},
{ 6, {1}, 3, "techage:oiltower5"},
{ 6, {2}, 0, "techage:oiltower5"},
{ 6, {3}, 1, "techage:oiltower5"},
-- level 7
{ 7, {}, 0, "techage:oiltower1"},
-- drill bits
{ 1, {}, 0, "techage:oil_drillbit2"},
{ 2, {}, 0, "techage:oil_drillbit2"},
{ 3, {}, 0, "techage:oil_drillbit2"},
{ 4, {}, 0, "techage:oil_drillbit2"},
{ 5, {}, 0, "techage:oil_drillbit2"},
{ 6, {}, 0, "techage:oil_drillbit2"},
}
minetest.register_craft({
output = "techage:oil_drillbit 12",
recipe = {
{"", "default:steel_ingot", "default:obsidian_shard"},
{"", "default:steel_ingot", ""},
{"default:obsidian_shard", "default:steel_ingot", ""},
},
})
techage.oiltower = {}
-- Two important flags:
-- 1) mem.assemble_locked is true while the tower is being assembled/disassembled
-- 2) mem.assemble_build is true if the tower is assembled
function techage.oiltower.build(pos, player_name)
minetest.chat_send_player(player_name, S("[TA] Derrick is being built!"))
techage.assemble.build(pos, AssemblyPlan, player_name)
end
function techage.oiltower.remove(pos, player_name)
minetest.chat_send_player(player_name, S("[TA] Derrick is being removed!"))
techage.assemble.remove(pos, AssemblyPlan, player_name)
end