icta controller, wall pipe improved, red stone added

This commit is contained in:
Joachim Stolberg 2020-03-02 21:51:18 +01:00
parent 1ba43d2ef4
commit 108c06d1d2
29 changed files with 249 additions and 32 deletions

View File

@ -13,9 +13,9 @@ Textures: CC BY-SA 3.0
### Dependencies
Required: default, doors, tubelib2, basic_materials, bucket, stairs, lcdlib
Optional: unified_inventory, wielded_light, minecart
Highly recommended: signs_bot, minecart
Required: default, doors, tubelib2, basic_materials, bucket, stairs, screwdriver, minecart, lcdlib, safer_lua
Optional: unified_inventory,wielded_light,unifieddyes
Highly recommended: signs_bot, hyperloop
### History

View File

@ -222,7 +222,7 @@ techage.register_node({"techage:generator", "techage:generator_on"}, {
end,
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "power" then
if topic == "delivered" then
return math.floor((nvm.provided or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)

View File

@ -226,7 +226,7 @@ techage.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
end,
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "power" then
if topic == "delivered" then
return math.floor((nvm.provided or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)

View File

@ -261,8 +261,8 @@ techage.register_node({"techage:heatexchanger1"}, {
else
return "stopped"
end
elseif topic == "power" then
return math.max(nvm.needed or 0, 0)
elseif topic == "delivered" then
return -math.max(nvm.needed or 0, 0)
elseif topic == "load" then
return techage.power.percent(nvm.capa_max, nvm.capa)
elseif topic == "on" then

View File

@ -29,6 +29,26 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger)
Pipe:after_dig_node(pos)
end
local function tubelib2_on_update2(pos, outdir, tlib2, node)
techage.liquid.update_network(pos, outdir)
local conn = M(pos):get_int("pipe2_conn")
if conn == 20 or conn == 40 then
-- replace node by tube
minetest.remove_node(pos)
Pipe:after_dig_node(pos)
node.name = "techage:ta4_wall_pipe"
minetest.set_node(pos, node)
Pipe:after_place_tube(pos)
end
end
local networks_def = {
pipe2 = {
sides = {F=1, B=1},
ntype = "tank",
},
}
minetest.register_node("techage:ta4_pipe_inlet", {
description = S("TA4 Pipe Inlet"),
tiles = {
@ -43,6 +63,8 @@ minetest.register_node("techage:ta4_pipe_inlet", {
after_place_node = after_place_node,
after_dig_node = after_dig_node,
tubelib2_on_update2 = tubelib2_on_update2,
networks = networks_def,
paramtype2 = "facedir", -- important!
on_rotate = screwdriver.disallow, -- important!
@ -51,6 +73,41 @@ minetest.register_node("techage:ta4_pipe_inlet", {
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("techage:ta4_wall_pipe", {
description = S("TA4 Wall Pipe"),
tiles = {
-- up, down, right, left, back, front
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png",
"basic_materials_concrete_block.png^techage_tes_inlet.png",
"basic_materials_concrete_block.png^techage_tes_inlet.png",
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
if not Pipe:after_place_tube(pos, placer, pointed_thing) then
minetest.remove_node(pos)
return true
end
return false
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
oldnode.param2 = oldmetadata.fields.tl2_param2
Pipe:after_dig_tube(pos, oldnode)
end
end,
paramtype2 = "facedir", -- important!
on_rotate = screwdriver.disallow, -- important!
groups = {crumbly = 2, cracky = 2, snappy = 2, not_in_creative_inventory = 1},
is_ground_content = false,
drop = "techage:ta4_pipe_inlet",
sounds = default.node_sound_metal_defaults(),
})
Pipe:add_secondary_node_names({"techage:ta4_pipe_inlet"})
local Numbers = {

View File

@ -285,8 +285,8 @@ techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"
local nvm = techage.get_nvm(pos)
if topic == "load" then
return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0)
elseif topic == "power" then
return math.floor((nvm.taken or 0) + 0.5)
elseif topic == "delivered" then
return -math.floor((nvm.taken or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)
end

View File

@ -276,7 +276,7 @@ techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, {
local nvm = techage.get_nvm(pos)
if topic == "load" then
return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0)
elseif topic == "power" then
elseif topic == "delivered" then
return math.floor((nvm.given or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)

View File

@ -160,7 +160,7 @@ techage.icta_register_condition("input", {
})
techage.icta_register_condition("state", {
title = "block state request",
title = "read block state",
formspec = {
{
type = "number",
@ -198,7 +198,7 @@ techage.icta_register_condition("state", {
})
techage.icta_register_condition("fuel", {
title = "fuel request",
title = "read amount of fuel",
formspec = {
{
type = "number",
@ -235,7 +235,7 @@ techage.icta_register_condition("fuel", {
})
techage.icta_register_condition("load", {
title = "load request",
title = "read power/liquid load",
formspec = {
{
type = "number",
@ -271,8 +271,45 @@ techage.icta_register_condition("load", {
end,
})
techage.icta_register_condition("delivered", {
title = "read delivered power",
formspec = {
{
type = "number",
name = "number",
label = "block number",
default = "",
},
{
type = "textlist",
name = "operand",
label = "",
choices = "greater,less",
default = "greater",
},
{
type = "digits",
name = "value",
label = "than",
default = ""
},
{
type = "label",
name = "lbl",
label = "Read and evaluate the delivered\npower from a generator block.\nPower consuming blocks like accus\ncould also provide a negative value.",
},
},
button = function(data, environ)
return 'deliv('..techage.fmt_number(data.number)..","..data.operand..' '..data.value..')'
end,
code = function(data, environ)
return send_single_string(environ, data.number, "delivered"),
techage.operand(data.operand)..tonumber(data.value)
end,
})
techage.icta_register_condition("chest", {
title = "chest state request",
title = "read chest state",
formspec = {
{
type = "number",
@ -311,7 +348,7 @@ techage.icta_register_condition("chest", {
})
techage.icta_register_condition("signaltower", {
title = "Signal Tower state request",
title = "read Signal Tower state",
formspec = {
{
type = "number",
@ -347,7 +384,7 @@ techage.icta_register_condition("signaltower", {
})
techage.icta_register_action("signaltower", {
title = "Signal Tower command",
title = "send Signal Tower command",
formspec = {
{
type = "numbers",
@ -464,7 +501,7 @@ techage.icta_register_action("cleardisplay", {
})
techage.icta_register_action("chat", {
title = "chat send",
title = "send chat message",
formspec = {
{
type = "ascii",
@ -505,7 +542,7 @@ function techage.icta_door_toggle(pos, owner, state)
end
techage.icta_register_action("door", {
title = "doors open/close",
title = "open/close door",
formspec = {
{
type = "digits",
@ -548,7 +585,7 @@ function techage.icta_player_detect(own_num, number, name)
end
techage.icta_register_condition("playerdetector", {
title = "Player Detector name request",
title = "read Player Detector",
formspec = {
{
type = "number",

View File

@ -34,7 +34,7 @@ local function add_controls_to_table(tbl, kvDefinition, kvSelect)
tbl[#tbl+1] = "label[0,"..offs..";"..elem.label..":]"
offs = offs + 0.4
end
if elem.type == "numbers" or elem.type == "digits" or elem.type == "letters"
if elem.type == "numbers" or elem.type == "number" or elem.type == "digits" or elem.type == "letters"
or elem.type == "ascii" then
val = kvSelect[elem.name] or elem.default
tbl[#tbl+1] = "field[0.3,"..(offs+0.2)..";8,1;"..elem.name..";;"..val.."]"
@ -76,6 +76,15 @@ local function field_to_kvSelect(kvDefinition, kvSelect, fields)
error = true
end
end
elseif elem.type == "number" then
if fields[elem.name] then
if fields[elem.name]:find("^[%d ]+$") then
kvSelect[elem.name] = fields[elem.name]
else
kvSelect[elem.name] = elem.default
error = true
end
end
elseif elem.type == "digits" then -- including positions
if fields[elem.name] then
if fields[elem.name]:find("^[+%%-,%d]+$") then

View File

@ -223,6 +223,11 @@ else
dofile(MP.."/icta_controller/display.lua")
dofile(MP.."/icta_controller/signaltower.lua")
-- Lua Controller
-- dofile(MP.."/lua_controller/controller.lua")
-- dofile(MP.."/lua_controller/commands.lua")
-- dofile(MP.."/lua_controller/server.lua")
-- Items
dofile(MP.."/items/barrel.lua")
dofile(MP.."/items/baborium.lua")
@ -239,6 +244,7 @@ else
dofile(MP.."/items/plastic.lua")
dofile(MP.."/items/hydrogen.lua")
dofile(MP.."/items/electronic.lua")
dofile(MP.."/items/redstone.lua")
if techage.basalt_stone_enabled then
dofile(MP.."/items/basalt.lua")

103
items/redstone.lua Normal file
View File

@ -0,0 +1,103 @@
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Redstone as result from the redmud/sand
]]--
local S = techage.S
minetest.register_node("techage:red_stone", {
description = S("Red Stone"),
tiles = {"default_stone.png^[colorize:#ff4538:110"},
groups = {cracky = 3, stone = 1},
drop = 'techage:basalt_cobble',
sounds = default.node_sound_stone_defaults(),
})
stairs.register_stair_and_slab(
"red_stone",
"techage:red_stone",
{cracky = 3, stone = 1},
{"default_stone.png^[colorize:#ff4538:110"},
"Red Stone Stair",
"Red Stone Slab",
default.node_sound_stone_defaults(),
false
)
minetest.register_node("techage:red_stone_brick", {
description = S("Red Stone Brick"),
paramtype2 = "facedir",
place_param2 = 0,
tiles = {"default_stone_brick.png^[colorize:#ff4538:110"},
is_ground_content = false,
groups = {cracky = 2, stone = 1},
sounds = default.node_sound_stone_defaults(),
})
stairs.register_stair_and_slab(
"red_stone_brick",
"techage:red_stone_brick",
{cracky = 2, stone = 1},
{"default_stone_brick.png^[colorize:#ff4538:110"},
"Red Brick Stair",
"Red Brick Slab",
default.node_sound_stone_defaults(),
false
)
minetest.register_node("techage:red_stone_block", {
description = S("Red Stone Block"),
tiles = {"default_stone_block.png^[colorize:#ff4538:110"},
is_ground_content = false,
groups = {cracky = 2, stone = 1},
sounds = default.node_sound_stone_defaults(),
})
stairs.register_stair_and_slab(
"red_stone_block",
"techage:red_stone_block",
{cracky = 2, stone = 1},
{"default_stone_block.png^[colorize:#ff4538:110"},
"Red Stone Block Stair",
"Red Stone Block Slab",
default.node_sound_stone_defaults(),
false
)
minetest.register_craft({
output = "techage:red_stone_brick 4",
recipe = {
{"techage:red_stone", "techage:red_stone"},
{"techage:red_stone", "techage:red_stone"},
}
})
minetest.register_craft({
output = "techage:red_stone_block 9",
recipe = {
{"techage:red_stone", "techage:red_stone", "techage:red_stone"},
{"techage:red_stone", "techage:red_stone", "techage:red_stone"},
{"techage:red_stone", "techage:red_stone", "techage:red_stone"},
}
})
techage.furnace.register_recipe({
output = "techage:red_stone",
recipe = {
"techage:redmud",
"default:sand",
},
time = 4,
})

View File

@ -27,10 +27,15 @@ local Pipe = tubelib2.Tube:new({
show_infotext = false,
force_to_use_tubes = true,
tube_type = "pipe2",
primary_node_names = {"techage:ta3_pipeS", "techage:ta3_pipeA"},
primary_node_names = {"techage:ta3_pipeS", "techage:ta3_pipeA", "techage:ta4_wall_pipe"},
secondary_node_names = {},
after_place_tube = function(pos, param2, tube_type, num_tubes)
minetest.swap_node(pos, {name = "techage:ta3_pipe"..tube_type, param2 = param2})
local name = minetest.get_node(pos).name
if name == "techage:ta4_wall_pipe" then
minetest.swap_node(pos, {name = "techage:ta4_wall_pipe", param2 = param2})
else
minetest.swap_node(pos, {name = "techage:ta3_pipe"..tube_type, param2 = param2})
end
end,
})

View File

@ -1,4 +1,4 @@
name = techage
depends = default,doors,tubelib2,basic_materials,bucket,stairs,screwdriver,minecart,lcdlib
depends = default,doors,tubelib2,basic_materials,bucket,stairs,screwdriver,minecart,lcdlib,safer_lua
optional_depends = unified_inventory,wielded_light,unifieddyes
description = Techage, go through 4 tech ages in search of wealth and power!

View File

@ -201,7 +201,7 @@ Solar:add_secondary_node_names({"techage:ta4_solar_inverter"})
techage.register_node({"techage:ta4_solar_inverter"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "power" then
if topic == "delivered" then
return math.floor((nvm.delivered or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)

View File

@ -205,8 +205,8 @@ techage.register_node({"techage:ta3_akku"}, {
local nvm = techage.get_nvm(pos)
if topic == "load" then
return techage.power.percent(PWR_CAPA, nvm.capa)
elseif topic == "power" then
return nvm.needed or 0
elseif topic == "delivered" then
return -(nvm.needed or 0)
else
return State:on_receive_message(pos, topic, payload)
end

View File

@ -283,7 +283,7 @@ Cable:add_secondary_node_names({"techage:tiny_generator", "techage:tiny_generato
techage.register_node({"techage:tiny_generator", "techage:tiny_generator_on"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "power" then
if topic == "delivered" then
return nvm.provided or 0
elseif topic == "fuel" then
return techage.fuel.get_fuel_amount(nvm)

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 811 B

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

View File

@ -242,10 +242,10 @@ local function read_state(itemstack, user, pointed_thing)
load = dump(load)
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ")
end
local power = techage.send_single("0", number, "power", nil)
if power and power ~= "" and power ~= "unsupported" then
power = dump(power)
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": power = "..power.." ku ")
local delivered = techage.send_single("0", number, "delivered", nil)
if delivered and delivered ~= "" and delivered ~= "unsupported" then
delivered = dump(delivered)
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": delivered = "..delivered.." ku ")
end
local owner = M(pos):get_string("owner") or ""
if owner ~= "" then

View File

@ -261,7 +261,7 @@ techage.register_node({"techage:ta4_wind_turbine"}, {
else
return "stopped"
end
elseif topic == "power" then
elseif topic == "delivered" then
return nvm.delivered or 0
elseif topic == "on" then
nvm.running = true