forked from Reload/techage_modpack
built on 18/09/2021 13:12:27
This commit is contained in:
parent
404a15e7cd
commit
835138c0f1
@ -53,6 +53,14 @@ Updated Mods:
|
||||
- minecart (bugfix)
|
||||
|
||||
|
||||
#### 2021-09-18
|
||||
|
||||
Updated Mods:
|
||||
- techage (see readme)
|
||||
- signs_bot (see readme)
|
||||
- networks (see readme)
|
||||
|
||||
|
||||
#### 2021-09-03
|
||||
|
||||
Updated Mods:
|
||||
|
@ -122,3 +122,6 @@ Required: tubelib2
|
||||
|
||||
**2021-07-23 V0.09**
|
||||
- bug fixes and improvements
|
||||
|
||||
**2021-09-18 V0.10**
|
||||
- Add support for colored cables (PR #1 by Thomas--S)
|
||||
|
@ -118,7 +118,7 @@ function networks.open_node(pos, node, placer)
|
||||
else
|
||||
param2 = M(pos):get_int("netw_param2_copy")
|
||||
end
|
||||
minetest.swap_node(pos, {name = name, param2 = param2 % 32})
|
||||
minetest.swap_node(pos, {name = name, param2 = param2 % 32 + M(pos):get_int("netw_color_param2")})
|
||||
local meta = M(pos)
|
||||
meta:set_string("netw_name", "")
|
||||
local inv = placer:get_inventory()
|
||||
|
@ -13,7 +13,7 @@
|
||||
networks = {}
|
||||
|
||||
-- Version for compatibility checks, see readme.md/history
|
||||
networks.version = 0.09
|
||||
networks.version = 0.10
|
||||
|
||||
if not minetest.global_exists("tubelib2") or tubelib2.version < 2.1 then
|
||||
minetest.log("error", "[networks] Networks requires tubelib2 version 2.1 or newer!")
|
||||
|
@ -19,6 +19,7 @@ local M = minetest.get_meta
|
||||
local S = signs_bot.S
|
||||
|
||||
local lib = signs_bot.lib
|
||||
local INFO = [[Set the node state: command = 'set', payload = 1..4]]
|
||||
|
||||
local NodeIdx = {
|
||||
["signs_bot:changer1"] = "1",
|
||||
@ -134,6 +135,10 @@ for idx = 1,4 do
|
||||
meta:set_string("formspec", formspec)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("param2", (node.param2 + 2) % 4)
|
||||
if minetest.get_modpath("techage") then
|
||||
techage.logic.after_place_node(pos, placer, node.name, S("Bot Control Unit"))
|
||||
techage.logic.infotext(meta, S("Bot Control Unit"))
|
||||
end
|
||||
end,
|
||||
|
||||
signs_bot_get_signal = signs_bot_get_signal,
|
||||
@ -182,3 +187,22 @@ if minetest.get_modpath("doc") then
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("techage") then
|
||||
techage.register_node({"signs_bot:changer1", "signs_bot:changer2", "signs_bot:changer3", "signs_bot:changer4"}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
if topic == "set" then
|
||||
local idx = tonumber(payload) or 1
|
||||
if idx >= 1 and idx <= 4 then
|
||||
local node = techage.get_node_lvm(pos)
|
||||
signs_bot_on_signal(pos, node, idx)
|
||||
return true
|
||||
end
|
||||
elseif topic == "info" then
|
||||
return INFO
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
@ -30,6 +30,10 @@ function signs_bot.register_flower(name)
|
||||
end
|
||||
end
|
||||
|
||||
signs_bot.register_flower("default:bush_stem")
|
||||
signs_bot.register_flower("default:acacia_bush_stem")
|
||||
signs_bot.register_flower("default:pine_bush_stem")
|
||||
|
||||
minetest.after(1, function()
|
||||
for _,def in pairs(minetest.registered_decorations) do
|
||||
local name = def.decoration
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Tech Age [techage] (Minetest 5.0+)
|
||||
# Tech Age [techage] (Minetest 5.3+)
|
||||
|
||||
Tech Age, a mod to go through 4 tech ages in search of wealth and power.
|
||||
|
||||
@ -81,6 +81,10 @@ Available worlds will be converted to 'lsqlite3', but there is no way back, so:
|
||||
|
||||
### History
|
||||
|
||||
**2021-09-18 V1.02**
|
||||
- TA4 Chest: Fix items disappearing (PR #64 by Thomas--S)
|
||||
- Add support for colored cables (PR #63 by Thomas--S)
|
||||
|
||||
**2021-08-16 V1.01**
|
||||
- Allow singleplayer to place lava on y>0.
|
||||
- Logic block: allow to use output numbers for the expression
|
||||
|
@ -62,7 +62,7 @@ local names = networks.register_junction("techage:concentrator", 2/8, Boxes, Tub
|
||||
techage.register_node(names, {
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
local push_dir = M(pos):get_int("push_dir")
|
||||
return techage.push_items(pos, push_dir, stack)
|
||||
return techage.safe_push_items(pos, push_dir, stack)
|
||||
end,
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
})
|
||||
@ -101,7 +101,7 @@ names = networks.register_junction("techage:ta4_concentrator", 2/8, Boxes, Tube,
|
||||
techage.register_node(names, {
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
local push_dir = M(pos):get_int("push_dir")
|
||||
return techage.push_items(pos, push_dir, stack)
|
||||
return techage.safe_push_items(pos, push_dir, stack)
|
||||
end,
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
})
|
||||
|
@ -234,7 +234,7 @@ tiles.act = {
|
||||
local tubing = {
|
||||
-- push item through the pusher in opposit direction
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
return in_dir == M(pos):get_int("pull_dir") and techage.push_items(pos, in_dir, stack)
|
||||
return in_dir == M(pos):get_int("pull_dir") and techage.safe_push_items(pos, in_dir, stack)
|
||||
end,
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
|
@ -170,7 +170,7 @@ local function take_from_chest(pos, idx, output_stack, max_total_count, keep_ass
|
||||
local nvm_stack = get_stack(nvm, idx)
|
||||
output_stack = output_stack or ItemStack()
|
||||
local assignment_count = keep_assignment and M(pos):get_int("assignment") == 1 and 1 or 0
|
||||
local count = math.min(nvm_stack.count - assignment_count, max_stacksize(nvm_stack.name))
|
||||
local count = math.min(nvm_stack.count - assignment_count, max_stacksize(nvm_stack.name) - output_stack:get_count())
|
||||
if max_total_count then
|
||||
count = math.min(count, max_total_count - output_stack:get_count())
|
||||
end
|
||||
|
@ -235,7 +235,7 @@ tiles.act = {
|
||||
local tubing = {
|
||||
-- push item through the injector in opposit direction
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
return in_dir == M(pos):get_int("pull_dir") and techage.push_items(pos, in_dir, stack)
|
||||
return in_dir == M(pos):get_int("pull_dir") and techage.safe_push_items(pos, in_dir, stack)
|
||||
end,
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
|
@ -405,6 +405,31 @@ function techage.push_items(pos, out_dir, stack, idx)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Check for recursion and too long distances
|
||||
local start_pos
|
||||
function techage.safe_push_items(pos, out_dir, stack, idx)
|
||||
local mem = techage.get_mem(pos)
|
||||
if not mem.pushing then
|
||||
if not start_pos then
|
||||
start_pos = pos
|
||||
mem.pushing = true
|
||||
local res = techage.push_items(pos, out_dir, stack, idx)
|
||||
mem.pushing = nil
|
||||
start_pos = nil
|
||||
return res
|
||||
else
|
||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||
if vector.distance(start_pos, npos) < (Tube.max_tube_length or 100) then
|
||||
mem.pushing = true
|
||||
local res = techage.push_items(pos, out_dir, stack, idx)
|
||||
mem.pushing = nil
|
||||
return res
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function techage.unpull_items(pos, out_dir, stack)
|
||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||
if npos and NodeDef[name] and NodeDef[name].on_unpull_item then
|
||||
|
@ -283,7 +283,8 @@ techage.register_node({"techage:heatexchanger2"}, {
|
||||
return "stopped"
|
||||
end
|
||||
elseif topic == "delivered" then
|
||||
return -math.max(nvm.needed or 0, 0)
|
||||
local data = power.get_network_data(pos, Cable, DOWN)
|
||||
return data.consumed - data.provided
|
||||
elseif topic == "load" then
|
||||
return techage.power.percent(nvm.capa_max, nvm.capa)
|
||||
elseif topic == "on" then
|
||||
|
@ -13,7 +13,7 @@
|
||||
techage = {}
|
||||
|
||||
-- Version for compatibility checks, see readme.md/history
|
||||
techage.version = 1.01
|
||||
techage.version = 1.02
|
||||
|
||||
if minetest.global_exists("tubelib") then
|
||||
minetest.log("error", "[techage] Techage can't be used together with the mod tubelib!")
|
||||
@ -36,8 +36,8 @@ elseif minetest.global_exists("lcdlib") and lcdlib.version < 1.0 then
|
||||
elseif minetest.global_exists("safer_lua") and safer_lua.version < 1.0 then
|
||||
minetest.log("error", "[techage] Techage requires safer_lua version 1.0 or newer!")
|
||||
return
|
||||
elseif minetest.global_exists("networks") and networks.version < 0.08 then
|
||||
minetest.log("error", "[techage] Techage requires networks version 0.08 or newer!")
|
||||
elseif minetest.global_exists("networks") and networks.version < 0.10 then
|
||||
minetest.log("error", "[techage] Techage requires networks version 0.10 or newer!")
|
||||
return
|
||||
end
|
||||
|
||||
@ -342,9 +342,9 @@ dofile(MP.."/items/petroleum.lua")
|
||||
dofile(MP.."/items/bauxit.lua")
|
||||
dofile(MP.."/items/silicon.lua")
|
||||
dofile(MP.."/items/steelmat.lua")
|
||||
dofile(MP.."/items/aluminium.lua")
|
||||
dofile(MP.."/items/powder.lua")
|
||||
dofile(MP.."/items/epoxy.lua")
|
||||
dofile(MP.."/items/aluminium.lua")
|
||||
dofile(MP.."/items/plastic.lua")
|
||||
dofile(MP.."/items/hydrogen.lua")
|
||||
dofile(MP.."/items/electronic.lua")
|
||||
|
@ -203,7 +203,7 @@ minetest.register_craft({
|
||||
|
||||
techage.register_node({"techage:ta3_detector_off", "techage:ta3_detector_on"}, {
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
if techage.push_items(pos, in_dir, stack) then
|
||||
if techage.safe_push_items(pos, in_dir, stack) then
|
||||
switch_on(pos)
|
||||
return true
|
||||
end
|
||||
@ -214,7 +214,7 @@ techage.register_node({"techage:ta3_detector_off", "techage:ta3_detector_on"}, {
|
||||
|
||||
techage.register_node({"techage:ta4_detector_off", "techage:ta4_detector_on"}, {
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
if techage.push_items(pos, in_dir, stack) then
|
||||
if techage.safe_push_items(pos, in_dir, stack) then
|
||||
switch_on(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.counter = (nvm.counter or 0) + stack:get_count()
|
||||
|
@ -60,20 +60,21 @@ local function any_node_changed(pos)
|
||||
nvm.num = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"air"})
|
||||
return false
|
||||
end
|
||||
local num = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"air"})
|
||||
local num1 = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"air"})
|
||||
local num2 = #minetest.find_nodes_in_area(nvm.pos1, nvm.pos2, {"ignore"})
|
||||
|
||||
if nvm.num ~= num then
|
||||
if nvm.mode == 1 and num < nvm.num then
|
||||
nvm.num = num
|
||||
if num2 == 0 and nvm.num ~= num1 then
|
||||
if nvm.mode == 1 and num1 < nvm.num then
|
||||
nvm.num = num1
|
||||
return true
|
||||
elseif nvm.mode == 2 and num > nvm.num then
|
||||
nvm.num = num
|
||||
elseif nvm.mode == 2 and num1 > nvm.num then
|
||||
nvm.num = num1
|
||||
return true
|
||||
elseif nvm.mode == 3 then
|
||||
nvm.num = num
|
||||
nvm.num = num1
|
||||
return true
|
||||
end
|
||||
nvm.num = num
|
||||
nvm.num = num1
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
@ -32,7 +32,9 @@ local Cable = tubelib2.Tube:new({
|
||||
"techage:power_pole2", "techage:powerswitch_box", "techage:powerswitch_box_on"},
|
||||
secondary_node_names = {},
|
||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||
local name = minetest.get_node(pos).name
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
local color_param2 = math.floor(node.param2 / 32) * 32
|
||||
if name == "techage:powerswitch_box" or name == "techage:powerswitch_box_on" or name == "techage:powerswitch_box_off" then
|
||||
minetest.swap_node(pos, {name = name, param2 = param2 % 32})
|
||||
elseif name == "techage:power_line" or name == "techage:power_lineS" or name == "techage:power_lineA" then
|
||||
@ -40,9 +42,10 @@ local Cable = tubelib2.Tube:new({
|
||||
elseif name == "techage:power_pole2" then
|
||||
-- nothing
|
||||
elseif not networks.hidden_name(pos) then
|
||||
minetest.swap_node(pos, {name = "techage:electric_cable"..tube_type, param2 = param2 % 32})
|
||||
minetest.swap_node(pos, {name = "techage:electric_cable"..tube_type, param2 = param2 % 32 + color_param2})
|
||||
end
|
||||
M(pos):set_int("netw_param2", param2)
|
||||
M(pos):set_int("netw_color_param2", color_param2)
|
||||
end,
|
||||
})
|
||||
|
||||
@ -55,6 +58,15 @@ Cable:register_on_tube_update2(function(pos, outdir, tlib2, node)
|
||||
power.update_network(pos, outdir, tlib2, node)
|
||||
end)
|
||||
|
||||
local preserve_metadata = function(pos, oldnode, oldmeta, drops)
|
||||
for _,drop in ipairs(drops) do
|
||||
local meta = drop:get_meta()
|
||||
if meta:get_int("palette_index") == 0 then
|
||||
meta:set_string("palette_index", "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("techage:electric_cableS", {
|
||||
description = S("TA Electric Cable"),
|
||||
tiles = {
|
||||
@ -63,8 +75,16 @@ minetest.register_node("techage:electric_cableS", {
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable_end.png",
|
||||
"techage_electric_cable_end.png",
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable.png",
|
||||
},
|
||||
overlay_tiles = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
@ -79,7 +99,8 @@ minetest.register_node("techage:electric_cableS", {
|
||||
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
paramtype2 = "colorfacedir", -- important!
|
||||
palette = "techage_cable_palette.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -94,6 +115,7 @@ minetest.register_node("techage:electric_cableS", {
|
||||
is_ground_content = false,
|
||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
|
||||
sounds = default.node_sound_defaults(),
|
||||
preserve_metadata = preserve_metadata,
|
||||
})
|
||||
|
||||
minetest.register_node("techage:electric_cableA", {
|
||||
@ -101,18 +123,27 @@ minetest.register_node("techage:electric_cableA", {
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable_end.png",
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable_end.png",
|
||||
"techage_electric_cable.png",
|
||||
"techage_electric_cable.png",
|
||||
},
|
||||
overlay_tiles = {
|
||||
"",
|
||||
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||
},
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
paramtype2 = "colorfacedir", -- important!
|
||||
palette = "techage_cable_palette.png",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -129,7 +160,12 @@ minetest.register_node("techage:electric_cableA", {
|
||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3,
|
||||
techage_trowel = 1, not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_defaults(),
|
||||
drop = "techage:electric_cableS",
|
||||
drop = {
|
||||
items = {
|
||||
{ items = { "techage:electric_cableS" }, inherit_color = true },
|
||||
}
|
||||
},
|
||||
preserve_metadata = preserve_metadata,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
@ -142,4 +178,16 @@ minetest.register_craft({
|
||||
})
|
||||
|
||||
techage.ElectricCable = Cable
|
||||
techage.ELE1_MAX_CABLE_LENGHT = ELE1_MAX_CABLE_LENGHT
|
||||
techage.ELE1_MAX_CABLE_LENGTH = ELE1_MAX_CABLE_LENGTH
|
||||
|
||||
|
||||
for idx, color in ipairs({ "white", "grey", "black", "brown", "yellow", "red", "dark_green", "blue" }) do
|
||||
minetest.register_craft({
|
||||
output = idx == 1 and "techage:electric_cableS 8" or minetest.itemstring_with_palette("techage:electric_cableS 8", (idx-1)*32),
|
||||
recipe = {
|
||||
{ "techage:electric_cableS", "techage:electric_cableS", "techage:electric_cableS", },
|
||||
{ "techage:electric_cableS", "dye:"..color, "techage:electric_cableS", },
|
||||
{ "techage:electric_cableS", "techage:electric_cableS", "techage:electric_cableS", },
|
||||
}
|
||||
})
|
||||
end
|
@ -38,7 +38,7 @@ local function round(val)
|
||||
end
|
||||
|
||||
local function calc_percent(max_val, curr_val)
|
||||
return math.min(((curr_val or 0) * 100) / (max_val or 1.0), 100)
|
||||
return round(math.min(((curr_val or 0) * 100) / (max_val or 1.0), 100))
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -30,6 +30,7 @@ help . . . print this text
|
||||
cls . . . . . clear screen
|
||||
gen . . . . print all generators
|
||||
sto . . . . . print all storage systems
|
||||
con . . . . . print main consumers
|
||||
]])
|
||||
|
||||
local function row(num, label, data)
|
||||
@ -137,6 +138,22 @@ local function storages(pos)
|
||||
return table.concat(tbl, "\n")
|
||||
end
|
||||
|
||||
local function consumers(pos)
|
||||
local tbl = {}
|
||||
local outdir = M(pos):get_int("outdir")
|
||||
local netw = networks.get_network_table(pos, Cable, outdir) or {}
|
||||
for _,item in ipairs(netw.con or {}) do
|
||||
local number = techage.get_node_number(item.pos)
|
||||
if number then
|
||||
local name = techage.get_node_lvm(item.pos).name
|
||||
name = (minetest.registered_nodes[name] or {}).description or "unknown"
|
||||
tbl[#tbl + 1] = name .. " (" .. number .. ")"
|
||||
end
|
||||
end
|
||||
table.sort(tbl)
|
||||
return table.concat(tbl, "\n")
|
||||
end
|
||||
|
||||
local function output(pos, command, text)
|
||||
local meta = M(pos)
|
||||
text = meta:get_string("output") .. "\n$ " .. command .. "\n" .. (text or "")
|
||||
@ -160,6 +177,8 @@ local function command(pos, nvm, command)
|
||||
output(pos, command, generators(pos))
|
||||
elseif cmd == "sto" then
|
||||
output(pos, command, storages(pos))
|
||||
elseif cmd == "con" then
|
||||
output(pos, command, consumers(pos))
|
||||
elseif command ~= "" then
|
||||
output(pos, command, "")
|
||||
end
|
||||
|
BIN
techage/textures/techage_cable_palette.png
Normal file
BIN
techage/textures/techage_cable_palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 B |
Binary file not shown.
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 123 B |
Loading…
Reference in New Issue
Block a user