WLAN chip recipe bug fixed

hidden secondary nodes bug fixed
power distribution bug fixed
This commit is contained in:
Joachim Stolberg 2019-07-12 23:27:29 +02:00
parent ca413a4976
commit 7db45b187c
5 changed files with 60 additions and 10 deletions

View File

@ -50,7 +50,7 @@ local Input = {
local Output = {
"", -- 1
"techage:vacuum_tube 2", -- 2
"techage:wlanchip 8", -- 3
"techage:ta4_wlanchip 8", -- 3
"", -- 4
}
@ -60,7 +60,7 @@ local function formspec(self, pos, mem)
if crd.stage == 2 then
icon = "techage:vacuum_tube"
elseif crd.stage == 3 then
icon = "techage:wlanchip"
icon = "techage:ta4_wlanchip"
else
icon = ""
end
@ -281,6 +281,11 @@ minetest.register_craftitem("techage:ta4_wlanchip", {
inventory_image = "techage_wlanchip.png",
})
minetest.register_craftitem("techage:wlanchip", {
description = S("WLAN Chip"),
inventory_image = "techage_wlanchip.png",
})
if minetest.global_exists("unified_inventory") then
unified_inventory.register_craft_type("electronic_fab", {
@ -295,7 +300,7 @@ if minetest.global_exists("unified_inventory") then
type = "electronic_fab",
})
unified_inventory.register_craft({
output = "techage:wlanchip 8",
output = "techage:ta4_wlanchip 8",
items = {"default:mese_crystal", "default:copper_ingot", "default:gold_ingot", "basic_materials:silicon"},
type = "electronic_fab",
})

View File

@ -5,8 +5,8 @@ elseif minetest.global_exists("ironage") then
minetest.log("error", "[techage] Techage can't be used together with the mod ironage!")
elseif minetest.global_exists("techpack") then
minetest.log("error", "[techage] Techage can't be used together with the modpack techpack!")
elseif minetest.global_exists("tubelib2") and tubelib2.version < 1.4 then
minetest.log("error", "[techage] Techage requires tubelib2 version 1.4 or newer!")
elseif minetest.global_exists("tubelib2") and tubelib2.version < 1.5 then
minetest.log("error", "[techage] Techage requires tubelib2 version 1.5 or newer!")
else
techage = {
NodeDef = {}, -- node registration info

View File

@ -70,7 +70,7 @@ local function start_smoke(pos)
maxpos = {x=pos.x+0.25, y=pos.y+5, z=pos.z+0.25},
minvel = {x=-0.2, y=0.3, z=-0.2}, maxvel = {x=0.2, y=1, z=0.2},
minacc = {x=0,y=0,z=0}, maxacc = {x=0,y=0.5,z=0},
minexptime = 1, maxexptime = 3,
minexptime = 2, maxexptime = 4,
minsize = 6, maxsize = 12,
texture = "techage_smoke.png",
})

View File

@ -13,7 +13,8 @@
]]--
-- for lazy programmers
local P = minetest.string_to_pos
local S2P = minetest.string_to_pos
local P2S = minetest.pos_to_string
local M = minetest.get_meta
local S = techage.S
@ -52,6 +53,21 @@ function Cable:is_primary_node(pos, dir)
return techage.is_primary_node(pos, dir)
end
function Cable:get_secondary_node(pos, dir)
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
local node = self:get_node_lvm(npos)
if self.secondary_node_names[node.name] or
self.secondary_node_names[M(npos):get_string("techage_hidden_nodename")] then
return node, npos
end
end
function Cable:is_secondary_node(pos, dir)
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
local node = self:get_node_lvm(npos)
return self.secondary_node_names[node.name] or
self.secondary_node_names[M(npos):get_string("techage_hidden_nodename")]
end
minetest.register_node("techage:electric_cableS", {
description = S("TA Electric Cable"),
@ -135,7 +151,11 @@ minetest.register_node("techage:electric_cableA", {
})
Cable:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir)
minetest.registered_nodes[node.name].after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
if minetest.registered_nodes[node.name].after_tube_update then
minetest.registered_nodes[node.name].after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
else
techage.power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir, Cable)
end
end)
minetest.register_craft({

View File

@ -294,6 +294,23 @@ function techage.power.register_node(names, pwr_def)
end
end
function techage.power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir, power)
local mem = tubelib2.get_mem(pos)
mem.connections = mem.connections or {}
if not peer_pos or not valid_indir(peer_pos, peer_in_dir)
or not valid_outdir(pos, out_dir)
or not matching_nodes(pos, peer_pos) then
mem.connections[out_dir] = nil -- del connection
else
mem.connections[out_dir] = {pos = peer_pos, in_dir = peer_in_dir}
end
-- To be called delayed, so that all network connections have been established
minetest.after(0.2, on_power_switch, pos)
if power.after_tube_update then
return power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
end
end
function techage.power.consume_power(pos, needed)
local master_pos = tubelib2.get_mem(pos).master_pos
if master_pos then
@ -325,6 +342,8 @@ function techage.power.provide_power(pos, provide)
accounting(mem)
trigger_lamps(pos, mem)
mem.next_cycle = minetest.get_us_time() + 2000000 -- 2s
elseif (mem.next_cycle or 0) > minetest.get_us_time() + 2000000 then
mem.next_cycle = minetest.get_us_time()
end
-- for next cycle
mem.available1 = (mem.available1 or 0) + provide
@ -338,13 +357,19 @@ end
function techage.power.secondary_power(pos, provide, needed)
local mem = tubelib2.get_mem(pos)
if mem.is_master then
accounting(mem)
trigger_lamps(pos, mem)
--nothing todo
elseif mem.master_pos then
mem = tubelib2.get_mem(mem.master_pos)
else
return 0
end
if (mem.next_cycle or 0) < minetest.get_us_time() then
accounting(mem)
trigger_lamps(pos, mem)
mem.next_cycle = minetest.get_us_time() + 2000000 -- 2s
elseif (mem.next_cycle or 0) > minetest.get_us_time() + 2000000 then
mem.next_cycle = minetest.get_us_time()
end
-- for next cycle
mem.available2 = (mem.available2 or 0) + provide
mem.needed2 = (mem.needed2 or 0) + needed