furnace bug, pipe recipes, concrete block repice, steel mat added

This commit is contained in:
Joachim Stolberg 2019-09-09 22:04:16 +02:00
parent 19fbdbec87
commit 232f41d2dd
11 changed files with 109 additions and 30 deletions

View File

@ -147,11 +147,11 @@ end
-- consumes power
function techage.needs_power(mem)
local state = mem.techage_state or STOPPED
return state < STANDBY
return state < BLOCKED
end
function techage.needs_power2(state)
return state < STANDBY
return state < BLOCKED
end
function techage.get_state_string(mem)
@ -403,7 +403,7 @@ function NodeStates:state_button_event(pos, mem, fields)
if fields.state_button ~= nil then
local state = mem.techage_state or STOPPED
if state == STOPPED or state == STANDBY or state == BLOCKED then
if not self:start(pos, mem) and state == STANDBY then
if not self:start(pos, mem) and (state == STANDBY or state == BLOCKED) then
self:stop(pos, mem)
end
elseif state == RUNNING or state == FAULT or state == NOPOWER then

View File

@ -46,40 +46,73 @@ techage.power.register_node({"techage:ta4_pipe_inlet"}, {
power_network = Pipe,
})
local function volume(pos, in_dir)
local mem = tubelib2.get_mem(pos)
if not mem.pos1 or not mem.pos2 or not mem.volume then
local Numbers = {
shell = {
[2] = 96, -- 5x5x2 + 3x5x2 + 3x3x2 - 2
[3] = 216, -- 7x7x2 + 5x7x2 + 5x5x2 - 2
[4] = 384, -- 9x9x2 + 7x9x2 + 7x7x2 - 2
},
filling = {
[2] = 27, -- 3x3x3
[3] = 125, -- 5x5x5
[4] = 343, -- 7x7x7
}
}
local function chat(owner, text)
if owner ~= nil then
minetest.chat_send_player(owner, string.char(0x1b).."(c@#ff0000)".."[Techage] Error: "..text.."!")
end
end
local function get_radius(pos, in_dir)
local dir = tubelib2.Dir6dToVector[in_dir]
local pos2 = vector.add(pos, vector.multiply(dir, 8))
local poses = minetest.find_nodes_in_area(pos, pos2, {"techage:ta4_pipe_inlet"})
if #poses == 2 then
local radius = vector.distance(poses[1], poses[2]) / 2
if radius == 2 or radius == 3 or radius == 4 then
return radius
end
end
end
local function check_volume(pos, in_dir, owner)
local radius = get_radius(pos, in_dir)
if radius then
local dir = tubelib2.Dir6dToVector[in_dir]
local pos2 = vector.add(pos, vector.multiply(dir, 8))
local poses = minetest.find_nodes_in_area(pos, pos2, {"techage:ta4_pipe_inlet"})
if #poses == 2 then
mem.pos1 = poses[1]
mem.pos2 = poses[2]
local _, node_tbl = minetest.find_nodes_in_area(mem.pos1, mem.pos2,
local cpos = vector.add(pos, vector.multiply(dir, radius))
-- calculate size
local pos1 = {x = cpos.x - radius, y = cpos.y - radius, z = cpos.z - radius}
local pos2 = {x = cpos.x + radius, y = cpos.y + radius, z = cpos.z + radius}
local _, node_tbl = minetest.find_nodes_in_area(pos1, pos2,
{"default:gravel", "techage:ta4_pipe_inlet",
"basic_materials:concrete_block", "default:obsidian_glass",
"techage:glow_gravel"})
print(dump(node_tbl))
return true
if node_tbl["default:obsidian_glass"] > 1 then
chat(owner, "one window maximum")
return false
elseif node_tbl["default:obsidian_glass"] + node_tbl["basic_materials:concrete_block"] ~= Numbers.shell[radius] then
chat(owner, "wrong numbers of shell nodes")
return false
elseif node_tbl["default:gravel"] + node_tbl["techage:glow_gravel"] ~= Numbers.filling[radius] then
chat(owner, "wrong numbers of gravel nodes")
return false
end
else
chat(owner, "wrong diameter (should be 5, 7, or 9)")
return false
end
return false
return true
end
-- for logical communication
techage.register_node({"techage:ta4_pipe_inlet"}, {
on_transfer = function(pos, in_dir, topic, payload)
print(P2S(pos), in_dir, topic, payload)
if topic == "increment" then
if transfer(pos, in_dir, topic, nil) then
swap_node(pos, "techage:cooler_on")
return true
end
elseif topic == "decrement" then
swap_node(pos, "techage:cooler")
return transfer(pos, in_dir, topic, nil)
if topic == "radius" then
return get_radius(pos, in_dir)
elseif topic == "volume" then
return volume(pos, in_dir)
return check_volume(pos, in_dir, payload)
end
return false
end

View File

@ -130,3 +130,14 @@ techage.furnace.register_recipe({
},
time = 4,
})
techage.furnace.register_recipe({
output = "basic_materials:concrete_block 4",
recipe = {
"basic_materials:wet_cement",
"group:sand",
"default:gravel",
"techage:steelmat",
},
time = 4,
})

View File

@ -160,6 +160,7 @@ else
end
dofile(MP.."/nodes/gateblock.lua")
dofile(MP.."/nodes/doorblock.lua")
dofile(MP.."/nodes/steelmat.lua")
-- Logic
dofile(MP.."/logic/lib.lua")

View File

@ -158,6 +158,10 @@ local function command(pos, command, player)
local cmnd, payload = command:match('^pipe%s+(%w+)%s*(.*)$')
if cmnd then
if not minetest.check_player_privs(player, "server") then
output(pos, "server privs missing")
return
end
local resp = techage.transfer(
pos,
"B", -- outdir

29
nodes/steelmat.lua Normal file
View File

@ -0,0 +1,29 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
pillar
]]--
local S = techage.S
minetest.register_craftitem("techage:steelmat", {
description = S("Techage Steel Mat"),
inventory_image = "techage_steelmat.png",
})
minetest.register_craft({
output = 'techage:steelmat 16',
recipe = {
{"", "techage:iron_ingot", ""},
{"default:steel_ingot", "techage:iron_ingot", "default:steel_ingot"},
{"", "techage:iron_ingot", ""},
},
})

View File

@ -50,10 +50,11 @@ end
-- 'boxes' is a table with 6 table elements for the 6 possible connection arms
-- 'network' is the tubelib2 instance
-- 'node' is the node definition with tiles, callback functions, and so on
function techage.register_junction(name, size, boxes, network, node)
-- 'index' number for the inventory node (default 0)
function techage.register_junction(name, size, boxes, network, node, index)
for idx = 0,63 do
local ndef = table.copy(node)
if idx == 0 then
if idx == (index or 0) then
ndef.groups.not_in_creative_inventory = 0
else
ndef.groups.not_in_creative_inventory = 1

View File

@ -65,10 +65,10 @@ techage.register_junction("techage:ta4_junctionpipe", 1/8, Boxes, Pipe, {
is_power_available = function(pos)
return techage.power.power_accounting(pos, tubelib2.get_mem(pos))
end,
})
}, 25)
minetest.register_craft({
output = "techage:ta4_junctionpipe0 2",
output = "techage:ta4_junctionpipe25 2",
recipe = {
{"", "techage:ta4_pipeS", ""},
{"techage:ta4_pipeS", "", "techage:ta4_pipeS"},

View File

@ -113,7 +113,7 @@ minetest.register_node("techage:ta4_pipeA", {
minetest.register_craft({
output = "techage:ta4_pipeS 3",
output = "techage:ta4_pipeS 6",
recipe = {
{'', '', "default:steel_ingot"},
{'dye:yellow', 'techage:meridium_ingot', ''},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B