mods that hopefully work for a TechAge-based pack
This commit is contained in:
1 parent
4e6b08d194
commit
c27db2a537
6234 files changed
+375578
No files matched your search
@@ -0,0 +1,432 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019-2022 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Doser
|
||||
|
||||
]]--
|
||||
|
||||
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 recipes = techage.recipes
|
||||
|
||||
local Liquids = {} -- {hash(pos) = {name = outdir},...}
|
||||
|
||||
local STANDBY_TICKS = 2
|
||||
local COUNTDOWN_TICKS = 3
|
||||
local CYCLE_TIME = 10
|
||||
|
||||
local function formspec(self, pos, nvm)
|
||||
return "size[6,3.6]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"box[0,-0.1;5.8,0.5;#c6e8ff]"..
|
||||
"label[2.5,-0.1;"..minetest.colorize( "#000000", S("Doser")).."]"..
|
||||
recipes.formspec(0.1, 0.8, "ta4_doser", nvm)..
|
||||
"image_button[5,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
|
||||
"tooltip[5,2;1,1;"..self:get_state_tooltip(nvm).."]"
|
||||
end
|
||||
|
||||
local function get_liquids(pos)
|
||||
local hash = minetest.hash_node_position(pos)
|
||||
if Liquids[hash] then
|
||||
return Liquids[hash]
|
||||
end
|
||||
-- determine the available input liquids
|
||||
local tbl = {}
|
||||
for outdir = 1,4 do
|
||||
local name, num = liquid.peek(pos, Pipe, outdir)
|
||||
if name then
|
||||
tbl[name] = outdir
|
||||
end
|
||||
end
|
||||
Liquids[hash] = tbl
|
||||
return Liquids[hash]
|
||||
end
|
||||
|
||||
local function del_liquids(pos)
|
||||
local hash = minetest.hash_node_position(pos)
|
||||
Liquids[hash] = nil
|
||||
end
|
||||
|
||||
-- if liquids are missing, update the cached liquid table
|
||||
local function reload_liquids(pos)
|
||||
local hash = minetest.hash_node_position(pos)
|
||||
-- determine the available input liquids
|
||||
local tbl = {}
|
||||
for outdir = 1,4 do
|
||||
local name, num = liquid.peek(pos, Pipe, outdir)
|
||||
if name then
|
||||
tbl[name] = outdir
|
||||
end
|
||||
end
|
||||
Liquids[hash] = tbl
|
||||
return Liquids[hash]
|
||||
end
|
||||
|
||||
local function reactor_cmnd(pos, cmnd, payload)
|
||||
return techage.transfer(
|
||||
pos,
|
||||
6, -- outdir
|
||||
cmnd, -- topic
|
||||
payload, -- payload
|
||||
Pipe, -- network
|
||||
{"techage:ta4_reactor_fillerpipe"})
|
||||
end
|
||||
|
||||
|
||||
local function can_start(pos, nvm, state)
|
||||
-- check reactor
|
||||
local res = reactor_cmnd(pos, "check")
|
||||
if not res then
|
||||
return S("reactor defect")
|
||||
end
|
||||
res = reactor_cmnd(pos, "can_start")
|
||||
if not res then
|
||||
return S("reactor defect or no power")
|
||||
end
|
||||
local recipe = recipes.get(nvm, "ta4_doser")
|
||||
if recipe.catalyst then
|
||||
res = reactor_cmnd(pos, "catalyst")
|
||||
if not res or res == "" then
|
||||
return S("catalyst missing")
|
||||
end
|
||||
if res ~= recipe.catalyst then
|
||||
return S("wrong catalyst")
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local test_setup = nil
|
||||
|
||||
local function start_node(pos, nvm, state)
|
||||
reactor_cmnd(pos, "start")
|
||||
del_liquids(pos)
|
||||
nvm.running = true
|
||||
test_setup(pos, nvm)
|
||||
end
|
||||
|
||||
local function stop_node(pos, nvm, state)
|
||||
reactor_cmnd(pos, "stop")
|
||||
nvm.running = false
|
||||
end
|
||||
|
||||
local State = techage.NodeStates:new({
|
||||
node_name_passive = "techage:ta4_doser",
|
||||
node_name_active = "techage:ta4_doser_on",
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
formspec_func = formspec,
|
||||
infotext_name = "TA4 Doser",
|
||||
can_start = can_start,
|
||||
start_node = start_node,
|
||||
stop_node = stop_node,
|
||||
})
|
||||
|
||||
local function untake(pos, taken)
|
||||
for _,item in pairs(taken) do
|
||||
liquid.untake(pos, Pipe, item.outdir, item.name, item.num)
|
||||
end
|
||||
end
|
||||
|
||||
test_setup = function(pos, nvm)
|
||||
local recipe = recipes.get(nvm, "ta4_doser")
|
||||
local ndef = minetest.registered_craftitems[recipe.output.name] or minetest.registered_items[recipe.output.name]
|
||||
nvm.fault = nil
|
||||
|
||||
if not ndef then
|
||||
nvm.fault = S("output: Invalid recipe")
|
||||
return
|
||||
end
|
||||
|
||||
local desc = ndef.description
|
||||
if not reactor_cmnd(pos, "test_output_container", recipe.output.name) then
|
||||
local container = ndef.groups and ndef.groups.powder == 1 and S("silo") or S("tank")
|
||||
nvm.fault = S("output: A @1 is required for @2", container, desc)
|
||||
return
|
||||
end
|
||||
|
||||
if recipe.waste.name == "" then
|
||||
return
|
||||
end
|
||||
|
||||
ndef = minetest.registered_craftitems[recipe.waste.name] or minetest.registered_items[recipe.output.name]
|
||||
desc = ndef.description
|
||||
if not reactor_cmnd(pos, "test_waste_container", recipe.waste.name) then
|
||||
local container = ndef.groups and ndef.groups.powder == 1 and "silo" or "tank"
|
||||
nvm.fault = S("output: A @1 is required for @2", container, desc)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function dosing(pos, nvm, elapsed)
|
||||
if nvm.fault then
|
||||
reactor_cmnd(pos, "stop")
|
||||
State:fault(pos, nvm, nvm.fault)
|
||||
return
|
||||
end
|
||||
-- trigger reactor (power)
|
||||
if not reactor_cmnd(pos, "power") then
|
||||
if not nvm.techage_countdown or nvm.techage_countdown < 3 then
|
||||
reactor_cmnd(pos, "stop")
|
||||
State:nopower(pos, nvm, S("reactor has no power"))
|
||||
return
|
||||
end
|
||||
State:idle(pos, nvm)
|
||||
return
|
||||
end
|
||||
-- available liquids
|
||||
local liquids = get_liquids(pos)
|
||||
local recipe = recipes.get(nvm, "ta4_doser")
|
||||
if not liquids or not recipe then return end
|
||||
-- check from time to time
|
||||
nvm.check_cnt = (nvm.check_cnt or 0) + 1
|
||||
if nvm.check_cnt >= 4 then
|
||||
nvm.check_cnt = 0
|
||||
local res = reactor_cmnd(pos, "check")
|
||||
if not res then
|
||||
State:fault(pos, nvm, S("reactor defect"))
|
||||
reactor_cmnd(pos, "stop")
|
||||
return
|
||||
end
|
||||
if recipe.catalyst then
|
||||
res = reactor_cmnd(pos, "catalyst")
|
||||
if not res then
|
||||
State:fault(pos, nvm, S("catalyst missing"))
|
||||
reactor_cmnd(pos, "stop")
|
||||
return
|
||||
end
|
||||
if res ~= recipe.catalyst then
|
||||
State:fault(pos, nvm, S("wrong catalyst"))
|
||||
reactor_cmnd(pos, "stop")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- check leftover
|
||||
local leftover
|
||||
local mem = techage.get_mem(pos)
|
||||
if mem.waste_leftover then
|
||||
leftover = reactor_cmnd(pos, "waste", {
|
||||
name = mem.waste_leftover.name,
|
||||
amount = mem.waste_leftover.num}) or mem.waste_leftover.num
|
||||
if leftover > 0 then
|
||||
mem.waste_leftover.num = leftover
|
||||
State:blocked(pos, nvm)
|
||||
return
|
||||
end
|
||||
mem.waste_leftover = nil
|
||||
end
|
||||
if mem.output_leftover then
|
||||
leftover = reactor_cmnd(pos, "output", {
|
||||
name = mem.output_leftover.name,
|
||||
amount = mem.output_leftover.num}) or mem.output_leftover.num
|
||||
if leftover > 0 then
|
||||
mem.output_leftover.num = leftover
|
||||
State:blocked(pos, nvm)
|
||||
return
|
||||
end
|
||||
mem.output_leftover = nil
|
||||
end
|
||||
|
||||
-- inputs
|
||||
local taken = {}
|
||||
mem.dbg_cycles = (mem.dbg_cycles or 0) - 1
|
||||
|
||||
for _,item in pairs(recipe.input) do
|
||||
if item.name ~= "" then
|
||||
local outdir = liquids[item.name] or reload_liquids(pos)[item.name]
|
||||
if not outdir then
|
||||
State:standby(pos, nvm)
|
||||
reactor_cmnd(pos, "stop")
|
||||
untake(pos, taken)
|
||||
return
|
||||
end
|
||||
local num = liquid.take(pos, Pipe, outdir, item.name, item.num, mem.dbg_cycles > 0)
|
||||
if num < item.num then
|
||||
taken[#taken + 1] = {outdir = outdir, name = item.name, num = num}
|
||||
State:standby(pos, nvm)
|
||||
reactor_cmnd(pos, "stop")
|
||||
untake(pos, taken)
|
||||
return
|
||||
end
|
||||
taken[#taken + 1] = {outdir = outdir, name = item.name, num = item.num}
|
||||
end
|
||||
end
|
||||
-- waste
|
||||
if recipe.waste.name ~= "" then
|
||||
leftover = reactor_cmnd(pos, "waste", {
|
||||
name = recipe.waste.name,
|
||||
amount = recipe.waste.num}) or recipe.waste.num
|
||||
if leftover > 0 then
|
||||
mem.waste_leftover = {name = recipe.waste.name, num = leftover}
|
||||
mem.output_leftover = {name = recipe.output.name, num = recipe.output.num}
|
||||
State:blocked(pos, nvm)
|
||||
reactor_cmnd(pos, "stop")
|
||||
return
|
||||
end
|
||||
end
|
||||
-- output
|
||||
leftover = reactor_cmnd(pos, "output", {
|
||||
name = recipe.output.name,
|
||||
amount = recipe.output.num}) or recipe.output.num
|
||||
if leftover > 0 then
|
||||
mem.output_leftover = {name = recipe.output.name, num = leftover}
|
||||
State:blocked(pos, nvm)
|
||||
reactor_cmnd(pos, "stop")
|
||||
return
|
||||
end
|
||||
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||
end
|
||||
|
||||
local function node_timer(pos, elapsed)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
dosing(pos, nvm, elapsed)
|
||||
return State:is_active(nvm)
|
||||
end
|
||||
|
||||
local function on_rightclick(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||
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)
|
||||
if not nvm.running then
|
||||
if recipes.on_receive_fields(pos, formname, fields, player) then
|
||||
local mem = techage.get_mem(pos)
|
||||
mem.waste_leftover = nil
|
||||
mem.output_leftover = nil
|
||||
end
|
||||
end
|
||||
local mem = techage.get_mem(pos)
|
||||
mem.dbg_cycles = 5
|
||||
State:state_button_event(pos, nvm, fields)
|
||||
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta4_doser", {
|
||||
description = S("TA4 Doser"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_pump_up.png",
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local number = techage.add_node(pos, "techage:ta4_doser")
|
||||
meta:set_string("node_number", number)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("formspec", formspec(State, pos, nvm))
|
||||
meta:set_string("infotext", S("TA4 Doser").." "..number)
|
||||
State:node_init(pos, nvm, number)
|
||||
Pipe:after_place_node(pos)
|
||||
end,
|
||||
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
||||
liquid.update_network(pos, dir, tlib2, node)
|
||||
del_liquids(pos)
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
techage.remove_node(pos, oldnode, oldmetadata)
|
||||
Pipe:after_dig_node(pos)
|
||||
techage.del_mem(pos)
|
||||
end,
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick,
|
||||
on_timer = node_timer,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta4_doser_on", {
|
||||
description = S("TA4 Doser"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_pipe.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
{
|
||||
name = "techage_filling8_ta4.png^techage_frame8_ta4.png^techage_appl_pump_up8.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 32,
|
||||
aspect_h = 32,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
||||
liquid.update_network(pos, dir, tlib2, node)
|
||||
del_liquids(pos)
|
||||
end,
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick,
|
||||
on_timer = node_timer,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
diggable = false,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
liquid.register_nodes({"techage:ta4_doser", "techage:ta4_doser_on"}, Pipe, "pump", nil, {})
|
||||
|
||||
techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
if topic == "recipe" then
|
||||
techage.recipes.set_recipe(pos, "ta4_doser", payload)
|
||||
return true
|
||||
else
|
||||
return State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
on_beduino_receive_cmnd = function(pos, src, topic, payload)
|
||||
return State:on_beduino_receive_cmnd(pos, topic, payload)
|
||||
end,
|
||||
on_beduino_request_data = function(pos, src, topic, payload)
|
||||
return State:on_beduino_request_data(pos, topic, payload)
|
||||
end,
|
||||
})
|
||||
|
||||
techage.recipes.register_craft_type("ta4_doser", {
|
||||
description = S("TA4 Reactor"),
|
||||
icon = 'techage_reactor_filler_plan.png',
|
||||
width = 2,
|
||||
height = 2,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:ta4_doser",
|
||||
recipe = {
|
||||
{"", "techage:ta3_pipeS", ""},
|
||||
{"techage:ta3_pipeS", "techage:t4_pump", "techage:ta3_pipeS"},
|
||||
{"", "techage:ta4_wlanchip", ""},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,209 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
Copyright (C) 2020 Thomas S.
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Liquid Filter
|
||||
|
||||
]]--
|
||||
|
||||
-- For now, the Red Mud -> Lye/Desert Cobble recipe is hardcoded.
|
||||
-- If necessary, this can be adjusted later.
|
||||
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
local Pipe = techage.LiquidPipe
|
||||
local liquid = networks.liquid
|
||||
|
||||
-- Checks if the filter structure is ok and returns the amount of gravel
|
||||
local function checkStructure(pos)
|
||||
local pos1_outer = {x=pos.x-2,y=pos.y-7,z=pos.z-2}
|
||||
local pos2_outer = {x=pos.x+2,y=pos.y,z=pos.z+2}
|
||||
local pos1_inner = {x=pos.x-1,y=pos.y-1,z=pos.z-1}
|
||||
local pos2_inner = {x=pos.x+1,y=pos.y-7,z=pos.z+1}
|
||||
local pos1_top = {x=pos.x-1,y=pos.y,z=pos.z-1}
|
||||
local pos2_top = {x=pos.x+1,y=pos.y,z=pos.z+1}
|
||||
local pos1_bottom = {x=pos.x-2,y=pos.y-8,z=pos.z-2}
|
||||
local pos2_bottom = {x=pos.x+2,y=pos.y-8,z=pos.z+2}
|
||||
|
||||
|
||||
local gravel = minetest.find_nodes_in_area(pos1_inner, pos2_inner, {"default:gravel"})
|
||||
|
||||
local _, inner = minetest.find_nodes_in_area(pos1_inner, pos2_inner, {
|
||||
"default:desert_cobble"
|
||||
})
|
||||
if #gravel + (inner["default:desert_cobble"] or 0) ~= 63 then -- 7x3x3=63
|
||||
return false, gravel
|
||||
end
|
||||
|
||||
local _, outer = minetest.find_nodes_in_area(pos1_outer, pos2_outer, {
|
||||
"basic_materials:concrete_block",
|
||||
"default:obsidian_glass"
|
||||
})
|
||||
|
||||
-- + 4x7=28 (corners)
|
||||
-- + 5x5-3x3=16 (top ring)
|
||||
-- ------------------------------
|
||||
-- = 44 (total concrete)
|
||||
if outer["basic_materials:concrete_block"] ~= 44 then
|
||||
return false, gravel
|
||||
end
|
||||
if outer["default:obsidian_glass"] ~= 84 then -- 4x7x3=84
|
||||
return false, gravel
|
||||
end
|
||||
|
||||
local _,top = minetest.find_nodes_in_area(pos1_top, pos2_top, {"air"})
|
||||
if top["air"] ~= 8 then
|
||||
return false, gravel
|
||||
end
|
||||
|
||||
local _,bottom = minetest.find_nodes_in_area(pos1_bottom, pos2_bottom, {
|
||||
"basic_materials:concrete_block",
|
||||
"techage:ta3_pipe_wall_entry"
|
||||
})
|
||||
if bottom["basic_materials:concrete_block"] ~= 22 or bottom["techage:ta3_pipe_wall_entry"] ~= 2 then
|
||||
return false, gravel
|
||||
end
|
||||
|
||||
if minetest.get_node({x=pos.x,y=pos.y-8,z=pos.z}).name ~= "techage:ta4_liquid_filter_sink" then
|
||||
return false, gravel
|
||||
end
|
||||
|
||||
return true, gravel
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta4_liquid_filter_filler", {
|
||||
description = S("TA4 Liquid Filter Filler"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"basic_materials_concrete_block.png^techage_gaspipe_hole.png",
|
||||
"basic_materials_concrete_block.png^techage_liquid_filter_filler_bottom.png",
|
||||
"basic_materials_concrete_block.png^techage_liquid_filter_filler.png",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-6/8, -0.5, -6/8, 6/8, -0.25, 6/8},
|
||||
{-7/16, -0.25, -7/16, 7/16, 0, 7/16},
|
||||
{-1/8, 0, -1/8, 1/8, 13/32, 1/8},
|
||||
{-2/8, 13/32, -2/8, 2/8, 0.5, 2/8},
|
||||
},
|
||||
},
|
||||
after_place_node = function(pos)
|
||||
Pipe:after_place_node(pos)
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Pipe:after_dig_node(pos)
|
||||
techage.del_mem(pos)
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
use_texture_alpha = techage.CLIP,
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
liquid.register_nodes({"techage:ta4_liquid_filter_filler"},
|
||||
Pipe, "tank", {"U"}, {
|
||||
capa = 1,
|
||||
peek = function(...) return nil end,
|
||||
put = function(pos, indir, name, amount)
|
||||
local structure_ok, gravel = checkStructure(pos)
|
||||
if name ~= "techage:redmud" then
|
||||
return amount
|
||||
end
|
||||
if not structure_ok then
|
||||
return amount
|
||||
end
|
||||
if #gravel < 33 then
|
||||
return amount
|
||||
end
|
||||
if math.random() < 0.5 then
|
||||
local out_pos = {x=pos.x,y=pos.y-8,z=pos.z}
|
||||
local leftover = liquid.put(out_pos, Pipe, networks.side_to_outdir(out_pos, "R"), "techage:lye", 1)
|
||||
if leftover > 0 then
|
||||
return amount
|
||||
end
|
||||
else
|
||||
minetest.swap_node(gravel[math.random(#gravel)], {name = "default:desert_cobble"})
|
||||
end
|
||||
return amount - 1
|
||||
end,
|
||||
take = function(...) return 0 end,
|
||||
untake = function(pos, outdir, name, amount, player_name)
|
||||
return amount
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
minetest.register_node("techage:ta4_liquid_filter_sink", {
|
||||
description = S("TA4 Liquid Filter Sink"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"basic_materials_concrete_block.png^techage_appl_arrow.png",
|
||||
"basic_materials_concrete_block.png",
|
||||
"basic_materials_concrete_block.png^techage_appl_hole_pipe.png",
|
||||
"basic_materials_concrete_block.png",
|
||||
"basic_materials_concrete_block.png",
|
||||
"basic_materials_concrete_block.png",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 3/16, 0.5},
|
||||
{-0.5, 3/16, -0.5, 0.5, 5/16, -0.25},
|
||||
{0.25, 3/16, -0.5, 0.5, 5/16, 0.5},
|
||||
{-0.5, 3/16, 0.25, 0.5, 5/16, 0.5},
|
||||
{-0.5, 3/16, -0.5, -0.25, 5/16, 0.5}
|
||||
},
|
||||
},
|
||||
after_place_node = function(pos)
|
||||
Pipe:after_place_node(pos)
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Pipe:after_dig_node(pos)
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
use_texture_alpha = techage.CLIP,
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
liquid.register_nodes({"techage:ta4_liquid_filter_sink"},
|
||||
Pipe, "pump", {"R"}, {}
|
||||
)
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'techage:ta4_liquid_filter_filler',
|
||||
recipe = {
|
||||
{'', 'techage:ta3_pipeS', ''},
|
||||
{'basic_materials:concrete_block', 'basic_materials:concrete_block', 'basic_materials:concrete_block'},
|
||||
{'', 'default:steel_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'techage:ta4_liquid_filter_sink 2',
|
||||
recipe = {
|
||||
{'basic_materials:concrete_block', '', 'basic_materials:concrete_block'},
|
||||
{'basic_materials:concrete_block', 'techage:ta3_pipeS', 'techage:ta3_pipeS'},
|
||||
{'basic_materials:concrete_block', 'basic_materials:concrete_block', 'basic_materials:concrete_block'},
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,239 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Reactor
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
local M = minetest.get_meta
|
||||
local Pipe = techage.LiquidPipe
|
||||
local Cable = techage.ElectricCable
|
||||
local liquid = networks.liquid
|
||||
|
||||
minetest.register_node("techage:ta4_reactor_fillerpipe", {
|
||||
description = S("TA4 Reactor Filler Pipe"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_reactor_filler_top.png",
|
||||
"techage_reactor_filler_top.png",
|
||||
"techage_reactor_filler_side.png",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-2/8, 13/32, -2/8, 2/8, 4/8, 2/8},
|
||||
{-1/8, 0/8, -1/8, 1/8, 4/8, 1/8},
|
||||
{-5/16, 0/8, -5/16, 5/16, 2/8, 5/16},
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-2/8, 0/8, -2/8, 2/8, 4/8, 2/8},
|
||||
},
|
||||
after_place_node = function(pos)
|
||||
local pos1 = {x = pos.x, y = pos.y-1, z = pos.z}
|
||||
if minetest.get_node(pos1).name == "air" then
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
minetest.set_node(pos1, node)
|
||||
Pipe:after_place_node(pos1)
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Pipe:after_dig_node(pos)
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
use_texture_alpha = techage.CLIP,
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
local function stand_cmnd(pos, cmnd, payload)
|
||||
return techage.transfer(
|
||||
{x = pos.x, y = pos.y-1, z = pos.z},
|
||||
5, -- outdir
|
||||
cmnd, -- topic
|
||||
payload, -- payload
|
||||
nil, -- network
|
||||
{"techage:ta4_reactor_stand"})
|
||||
end
|
||||
|
||||
local function base_waste(pos, payload)
|
||||
local pos2 = {x = pos.x, y = pos.y-3, z = pos.z}
|
||||
local outdir = M(pos2):get_int("outdir")
|
||||
return liquid.put(pos2, Pipe, outdir, payload.name, payload.amount, payload.player_name)
|
||||
end
|
||||
|
||||
local function connection_test(pos, item)
|
||||
local outdir = M(pos):get_int("outdir")
|
||||
if liquid.put(pos, Pipe, outdir, item, 1, nil) == 0 then
|
||||
liquid.take(pos, Pipe, outdir, item, 1, false)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- controlled by the doser
|
||||
techage.register_node({"techage:ta4_reactor_fillerpipe"}, {
|
||||
on_transfer = function(pos, in_dir, topic, payload)
|
||||
if topic == "check" then
|
||||
local pos2,node = Pipe:get_node(pos, 5)
|
||||
if not node or node.name ~= "techage:ta4_reactor" then
|
||||
return false
|
||||
end
|
||||
pos2,node = Pipe:get_node(pos2, 5)
|
||||
if not node or node.name ~= "techage:ta4_reactor_stand" then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
elseif topic == "test_output_container" then
|
||||
return connection_test({x = pos.x, y = pos.y-2, z = pos.z}, payload)
|
||||
elseif topic == "test_waste_container" then
|
||||
return connection_test({x = pos.x, y = pos.y-3, z = pos.z}, payload)
|
||||
elseif topic == "waste" then
|
||||
return base_waste(pos, payload or {})
|
||||
elseif topic == "catalyst" then
|
||||
local pos2,node = Pipe:get_node(pos, 5)
|
||||
if not node or node.name ~= "techage:ta4_reactor" then
|
||||
return
|
||||
end
|
||||
local inv = M(pos2):get_inventory()
|
||||
local stack = inv:get_stack("main", 1)
|
||||
return stack and stack:get_name()
|
||||
else
|
||||
return stand_cmnd(pos, topic, payload or {})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
liquid.register_nodes({"techage:ta4_reactor_fillerpipe"}, Pipe, "tank", {"U"}, {})
|
||||
|
||||
local function formspec()
|
||||
local title = S("TA4 Reactor")
|
||||
return "size[8,6]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"box[0,-0.1;7.8,0.5;#c6e8ff]"..
|
||||
"label[3,-0.1;"..minetest.colorize("#000000", title).."]"..
|
||||
"label[4.5,1.2;"..S("Catalyst").."]"..
|
||||
"list[context;main;3.5,1;1,1;]"..
|
||||
"list[current_player;main;0,2.3;8,4;]"..
|
||||
"listring[context;main]"..
|
||||
"listring[current_player;main]"
|
||||
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
|
||||
return 1
|
||||
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
|
||||
|
||||
minetest.register_node("techage:ta4_reactor", {
|
||||
description = S("TA4 Reactor"),
|
||||
tiles = {"techage_reactor_side.png"},
|
||||
drawtype = "mesh",
|
||||
mesh = "techage_cylinder_12h.obj",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -23/32, -1/2, 1/2, 32/32, 1/2},
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -23/32, -1/2, 1/2, 32/32, 1/2},
|
||||
},
|
||||
after_place_node = function(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_size('main', 1)
|
||||
M(pos):set_string("formspec", formspec())
|
||||
end,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
paramtype = "light",
|
||||
use_texture_alpha = techage.CLIP,
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
techage.register_node({"techage:ta4_reactor"}, {
|
||||
on_inv_request = function(pos, in_dir, access_type)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return meta:get_inventory(), "main"
|
||||
end,
|
||||
on_pull_item = function(pos, in_dir, num, item_name)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.get_items(pos, inv, "main", num)
|
||||
end,
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.put_items(inv, "main", stack)
|
||||
end,
|
||||
on_unpull_item = function(pos, in_dir, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.put_items(inv, "main", stack)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'techage:ta4_reactor',
|
||||
recipe = {
|
||||
{'default:steel_ingot', 'techage:ta3_pipeS', 'default:steel_ingot'},
|
||||
{'techage:iron_ingot', '', 'techage:iron_ingot'},
|
||||
{'default:steel_ingot', 'techage:ta3_pipeS', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'techage:ta4_reactor_fillerpipe',
|
||||
recipe = {
|
||||
{'', '', ''},
|
||||
{'', 'techage:ta3_pipeS', ''},
|
||||
{'default:steel_ingot', 'basic_materials:motor', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "Upgrade reactor",
|
||||
name = "techage:update_reactor",
|
||||
|
||||
nodenames = {
|
||||
"techage:ta4_reactor",
|
||||
},
|
||||
|
||||
run_at_every_load = true,
|
||||
|
||||
action = function(pos, node)
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_size('main', 1)
|
||||
M(pos):set_string("formspec", formspec())
|
||||
end,
|
||||
})
|
||||
@@ -0,0 +1,209 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019-2021 Joachim Stolberg
|
||||
|
||||
AGPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Reactor Stand and Base
|
||||
|
||||
]]--
|
||||
|
||||
local S = techage.S
|
||||
local M = minetest.get_meta
|
||||
local Cable = techage.ElectricCable
|
||||
local Pipe = techage.LiquidPipe
|
||||
local power = networks.power
|
||||
local liquid = networks.liquid
|
||||
|
||||
local PWR_NEEDED = 8
|
||||
local CYCLE_TIME = 2
|
||||
|
||||
local function play_sound(pos)
|
||||
local mem = techage.get_mem(pos)
|
||||
if not mem.handle or mem.handle == -1 then
|
||||
mem.handle = minetest.sound_play("techage_reactor", {
|
||||
pos = pos,
|
||||
gain = 0.5,
|
||||
max_hear_distance = 10,
|
||||
loop = true})
|
||||
if mem.handle == -1 then
|
||||
minetest.after(1, play_sound, pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function stop_sound(pos)
|
||||
local mem = techage.get_mem(pos)
|
||||
if mem.handle then
|
||||
minetest.sound_stop(mem.handle)
|
||||
mem.handle = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function on_power(pos)
|
||||
M(pos):set_string("infotext", S("on"))
|
||||
play_sound(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.running = true
|
||||
end
|
||||
|
||||
local function on_nopower(pos)
|
||||
M(pos):set_string("infotext", S("no power"))
|
||||
stop_sound(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.running = false
|
||||
end
|
||||
|
||||
local function is_running(pos, nvm)
|
||||
return nvm.running
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta4_reactor_stand", {
|
||||
description = S("TA4 Reactor Stand"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_reactor_stand_top.png^[transformR90",
|
||||
"techage_reactor_stand_bottom.png^[transformFY^[transformR270",
|
||||
"techage_reactor_stand_front.png",
|
||||
"techage_reactor_stand_back.png",
|
||||
"techage_reactor_stand_side.png^[transformFX",
|
||||
"techage_reactor_stand_side.png",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, 2/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
|
||||
{ -8/16, -8/16, -8/16, -6/16, 8/16, -6/16 },
|
||||
{ 6/16, -8/16, -8/16, 8/16, 8/16, -6/16 },
|
||||
{ -8/16, -8/16, 6/16, -6/16, 8/16, 8/16 },
|
||||
{ 6/16, -8/16, 6/16, 8/16, 8/16, 8/16 },
|
||||
|
||||
{-1/8, -4/8, -1/8, 1/8, 4/8, 1/8},
|
||||
{-4/8, -1/8, -1/8, 4/8, 1/8, 1/8},
|
||||
{-4/8, -1/8, -3/8, -3/8, 1/8, 3/8},
|
||||
{ 3/8, -1/8, -3/8, 4/8, 1/8, 3/8},
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -1/2, -1/2, 1/2, 1/2, 1/2},
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
M(pos):set_string("infotext", S("off"))
|
||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
||||
Pipe:after_place_node(pos)
|
||||
Cable:after_place_node(pos)
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
|
||||
if not nvm.running and consumed == PWR_NEEDED then
|
||||
on_power(pos)
|
||||
elseif nvm.running and consumed < PWR_NEEDED then
|
||||
on_nopower(pos)
|
||||
end
|
||||
return true
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode)
|
||||
Pipe:after_dig_node(pos)
|
||||
Cable:after_dig_node(pos)
|
||||
techage.del_mem(pos)
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
use_texture_alpha = techage.CLIP,
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
-- controlled by the fillerpipe
|
||||
techage.register_node({"techage:ta4_reactor_stand"}, {
|
||||
on_transfer = function(pos, in_dir, topic, payload)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if topic == "power" then
|
||||
return nvm.running or power.power_available(pos, Cable)
|
||||
elseif topic == "output" then
|
||||
local outdir = M(pos):get_int("outdir")
|
||||
return liquid.put(pos, Pipe, outdir, payload.name, payload.amount, payload.player_name)
|
||||
elseif topic == "can_start" then
|
||||
return power.power_available(pos, Cable)
|
||||
elseif topic == "start" then
|
||||
nvm.running = false
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
M(pos):set_string("infotext", "...")
|
||||
return true
|
||||
elseif topic == "stop" then
|
||||
nvm.has_power = false
|
||||
stop_sound(pos)
|
||||
minetest.get_node_timer(pos):stop()
|
||||
M(pos):set_string("infotext", S("off"))
|
||||
return true
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos, node)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if nvm.has_power then
|
||||
play_sound(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta4_reactor_base", {
|
||||
description = S("TA4 Reactor Base"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_concrete.png^techage_appl_arrowXL.png^techage_appl_hole_pipe.png^[transformR270",
|
||||
"techage_concrete.png",
|
||||
"techage_concrete.png^techage_appl_hole_pipe.png",
|
||||
"techage_concrete.png",
|
||||
"techage_concrete.png",
|
||||
"techage_concrete.png",
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
||||
Pipe:after_place_node(pos)
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Pipe:after_dig_node(pos)
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
on_rotate = screwdriver.disallow,
|
||||
groups = {cracky=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
liquid.register_nodes({"techage:ta4_reactor_base"}, Pipe, "pump", {"R"}, {})
|
||||
liquid.register_nodes({"techage:ta4_reactor_stand"}, Pipe, "pump", {"R"}, {})
|
||||
power.register_nodes({"techage:ta4_reactor_stand"}, Cable, "con", {"L"})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'techage:ta4_reactor_stand',
|
||||
recipe = {
|
||||
{'', 'dye:blue', ''},
|
||||
{'basic_materials:steel_bar', 'techage:ta3_pipeS', 'basic_materials:steel_bar'},
|
||||
{'basic_materials:steel_bar', '', 'basic_materials:steel_bar'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'techage:ta4_reactor_base',
|
||||
recipe = {
|
||||
{'basic_materials:concrete_block', '', ''},
|
||||
{'techage:ta3_pipeS', '', ''},
|
||||
{'', '', ''},
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user