New everything
@ -1 +0,0 @@
|
|||||||
Machinery! The future of automation mods!
|
|
139
energy/energy-transfer.lua
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
function tech_reborn.getNodeCapacity(pos)
|
||||||
|
if minetest.get_item_group(minetest.get_node(pos).name, "wire") > 0 then
|
||||||
|
local system = minetest.get_meta(pos):get_string("sys_id")
|
||||||
|
if not system or system == "" or not tech_reborn.wire.systems[system] then return false end
|
||||||
|
|
||||||
|
local capacity = tech_reborn.wire.systems[system].capacity - tech_reborn.wire.systems[system].power
|
||||||
|
return capacity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.getNodeEnergy(pos)
|
||||||
|
if minetest.get_item_group(minetest.get_node(pos).name, "wire") > 0 then
|
||||||
|
local system = minetest.get_meta(pos):get_string("sys_id")
|
||||||
|
if not system or system == "" or not tech_reborn.wire.systems[system] then return false end
|
||||||
|
return tech_reborn.wire.systems[system].power
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--Get Node Stored in adjacent Wire Nodes
|
||||||
|
function tech_reborn.getAdjacentEnergy(pos)
|
||||||
|
local adj_nodes = tech_reborn.getAdjacent(pos)
|
||||||
|
local total_power = 0
|
||||||
|
local systems = {}
|
||||||
|
|
||||||
|
for i = 1, #adj_nodes do
|
||||||
|
if minetest.get_item_group(minetest.get_node(adj_nodes[i]).name, "wire") > 0 then
|
||||||
|
local system = minetest.get_meta(adj_nodes[i]):get_string("sys_id")
|
||||||
|
if not system or system == "" or not tech_reborn.wire.systems[system] then return false end
|
||||||
|
|
||||||
|
local found = false
|
||||||
|
for i = 1, #systems do
|
||||||
|
if system == systems[i] then found = true; break end
|
||||||
|
end
|
||||||
|
if not found then
|
||||||
|
table.insert(systems, system)
|
||||||
|
local power = tech_reborn.getNodeEnergy(adj_nodes[i])
|
||||||
|
if power then total_power = total_power + power end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return total_power
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.pushNodeEnergy(pos, amount)
|
||||||
|
if minetest.get_item_group(minetest.get_node(pos).name, "wire") > 0 and
|
||||||
|
minetest.get_item_group(minetest.get_node(pos).name, "import") > 0 then
|
||||||
|
local system = minetest.get_meta(pos):get_string("sys_id")
|
||||||
|
if not system or system == "" or not tech_reborn.wire.systems[system] then return false end
|
||||||
|
|
||||||
|
local capacity = tech_reborn.getNodeCapacity(pos)
|
||||||
|
if (capacity > amount) then
|
||||||
|
tech_reborn.wire.systems[system].power = tech_reborn.wire.systems[system].power + amount
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
tech_reborn.wire.systems[system].power = tech_reborn.wire.systems[system].capacity
|
||||||
|
return amount - capacity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return amount
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.pushAdjacentEnergy(pos, amount)
|
||||||
|
local adj_nodes = tech_reborn.getAdjacent(pos)
|
||||||
|
local systems = {}
|
||||||
|
local count = 0
|
||||||
|
local leftover = 0
|
||||||
|
|
||||||
|
for i = 1, #adj_nodes do
|
||||||
|
if not tech_reborn.getNodeCapacity(adj_nodes[i]) then
|
||||||
|
adj_nodes[i] = false
|
||||||
|
else
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, #adj_nodes do
|
||||||
|
if adj_nodes[i] then
|
||||||
|
leftover = leftover + tech_reborn.pushNodeEnergy(adj_nodes[i], math.floor(amount/count))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if leftover > 0 then
|
||||||
|
for i = 1, #adj_nodes do
|
||||||
|
if adj_nodes[i] then
|
||||||
|
leftover = tech_reborn.pushNodeEnergy(adj_nodes[i], leftover)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return leftover
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.pullNodeEnergy(pos, amount)
|
||||||
|
if minetest.get_item_group(minetest.get_node(pos).name, "wire") > 0 and
|
||||||
|
minetest.get_item_group(minetest.get_node(pos).name, "export") > 0 then
|
||||||
|
local system = minetest.get_meta(pos):get_string("sys_id")
|
||||||
|
if not system or system == "" or not tech_reborn.wire.systems[system] then return false end
|
||||||
|
|
||||||
|
local available = tech_reborn.getNodeEnergy(pos)
|
||||||
|
if (available > amount) then
|
||||||
|
tech_reborn.wire.systems[system].power = tech_reborn.wire.systems[system].power - amount
|
||||||
|
return amount
|
||||||
|
else
|
||||||
|
tech_reborn.wire.systems[system].power = 0
|
||||||
|
return available
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.pullAdjacentEnergy(pos, amount)
|
||||||
|
local adj_nodes = tech_reborn.getAdjacent(pos)
|
||||||
|
local systems = {}
|
||||||
|
local count = 0
|
||||||
|
local got = 0
|
||||||
|
|
||||||
|
for i = 1, #adj_nodes do
|
||||||
|
if not tech_reborn.getNodeCapacity(adj_nodes[i]) then
|
||||||
|
adj_nodes[i] = false
|
||||||
|
else
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, #adj_nodes do
|
||||||
|
if adj_nodes[i] then
|
||||||
|
got = got + tech_reborn.pullNodeEnergy(adj_nodes[i], math.floor(amount/count))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if got < amount then
|
||||||
|
for i = 1, #adj_nodes do
|
||||||
|
if adj_nodes[i] then
|
||||||
|
got = got + tech_reborn.pullNodeEnergy(adj_nodes[i], amount - got)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return got
|
||||||
|
end
|
28
energy/file.lua
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
tech_reborn.wire.systems = {}
|
||||||
|
tech_reborn.wire.systemfile = minetest.get_worldpath() .. "/tech_reborn_systems.mt"
|
||||||
|
|
||||||
|
local input = io.open(tech_reborn.wire.systemfile, "r")
|
||||||
|
local filedata = nil
|
||||||
|
if input then
|
||||||
|
filedata = input:read('*all')
|
||||||
|
end
|
||||||
|
if filedata and filedata ~= "" then
|
||||||
|
tech_reborn.wire.systems = minetest.deserialize(filedata)
|
||||||
|
io.close(input)
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.wire.save_systems()
|
||||||
|
local output = io.open(tech_reborn.wire.systemfile, "w")
|
||||||
|
output:write(minetest.serialize(tech_reborn.wire.systems))
|
||||||
|
io.close(output)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function save_loop()
|
||||||
|
tech_reborn.wire.save_systems()
|
||||||
|
minetest.after(2, save_loop)
|
||||||
|
end
|
||||||
|
minetest.after(0, save_loop)
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
tech_reborn.wire.save_systems()
|
||||||
|
end)
|
128
energy/functions.lua
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
function tech_reborn.wire.changeState(pos, node, clicker, itemstack, pointed_thing)
|
||||||
|
if clicker:get_wielded_item():get_name() == "tech_reborn:wrench" then
|
||||||
|
local def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||||
|
if not def then return false end
|
||||||
|
|
||||||
|
local estate = def._export_state
|
||||||
|
if estate == "none" then mstring = "_import"
|
||||||
|
elseif estate == "import" then mstring = "_export"
|
||||||
|
elseif estate == "export" then mstring = "" end
|
||||||
|
|
||||||
|
minetest.swap_node(pos, {name = def._base_node .. mstring})
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
else
|
||||||
|
minetest.item_place_node(itemstack, clicker, pointed_thing)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.wire.constructWire(pos)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
tech_reborn.wire.createWire(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.wire.consumeSystem(newSys, oldSys)
|
||||||
|
if newSys and newSys ~= "" and oldSys and oldSys ~= "" and
|
||||||
|
tech_reborn.wire.systems[newSys] ~= nil and tech_reborn.wire.systems[oldSys] ~= nil then
|
||||||
|
local children = tech_reborn.wire.systems[oldSys].children
|
||||||
|
local altPower = tech_reborn.wire.systems[oldSys].power
|
||||||
|
tech_reborn.wire.systems[newSys].power = tech_reborn.wire.systems[newSys].power + altPower
|
||||||
|
|
||||||
|
tech_reborn.wire.systems[oldSys] = nil
|
||||||
|
|
||||||
|
for spos,_ in pairs(children) do
|
||||||
|
pos = tech_reborn.deserializepos(spos)
|
||||||
|
tech_reborn.wire.systems[newSys].children[spos] = true
|
||||||
|
minetest.get_meta(pos):set_string("sys_id", newSys)
|
||||||
|
end
|
||||||
|
|
||||||
|
tech_reborn.wire.save_systems()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.wire.createWire(pos)
|
||||||
|
--Check Adjacent Nodes
|
||||||
|
local adjacent = tech_reborn.getAdjacent(pos)
|
||||||
|
local found = false
|
||||||
|
for i = 1, #adjacent do
|
||||||
|
local node = adjacent[i]
|
||||||
|
if minetest.get_item_group(minetest.get_node(node).name, "wire") > 0 then
|
||||||
|
local id = minetest.get_meta(node):get_string("sys_id")
|
||||||
|
if id and id ~= "" then
|
||||||
|
if not found then
|
||||||
|
minetest.get_meta(pos):set_string("sys_id", id)
|
||||||
|
tech_reborn.wire.systems[id].children[tech_reborn.serializepos(pos)] = true
|
||||||
|
tech_reborn.wire.save_systems()
|
||||||
|
found = id
|
||||||
|
else
|
||||||
|
if id ~= found then
|
||||||
|
tech_reborn.wire.consumeSystem(found, id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if found then return true end
|
||||||
|
|
||||||
|
--No Adjacent Nodes to Pair to
|
||||||
|
local id = tostring(minetest.get_us_time())
|
||||||
|
minetest.get_meta(pos):set_string("sys_id", id)
|
||||||
|
tech_reborn.wire.systems[id] = {
|
||||||
|
id = id,
|
||||||
|
children = {},
|
||||||
|
power = 0,
|
||||||
|
capacity = 1000
|
||||||
|
}
|
||||||
|
tech_reborn.wire.systems[id].children[tech_reborn.serializepos(pos)] = true
|
||||||
|
tech_reborn.wire.save_systems()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.wire.removeWire(pos)
|
||||||
|
local id = minetest.get_meta(pos):get_string("sys_id")
|
||||||
|
|
||||||
|
minetest.after(0, function(pos, id)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
|
||||||
|
if id and id ~= "" then
|
||||||
|
if tech_reborn.wire.systems[id] ~= nil then
|
||||||
|
local power = tech_reborn.wire.systems[id].power
|
||||||
|
|
||||||
|
local children = tech_reborn.wire.systems[id].children
|
||||||
|
children[tech_reborn.serializepos(pos)] = nil
|
||||||
|
|
||||||
|
tech_reborn.wire.systems[id] = nil
|
||||||
|
|
||||||
|
for spos,_ in pairs(children) do
|
||||||
|
spos = tech_reborn.deserializepos(spos)
|
||||||
|
minetest.get_meta(spos):set_string("sys_id", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
for spos,_ in pairs(children) do
|
||||||
|
spos = tech_reborn.deserializepos(spos)
|
||||||
|
tech_reborn.wire.createWire(spos)
|
||||||
|
end
|
||||||
|
|
||||||
|
local split = 0
|
||||||
|
local adjacent = tech_reborn.getAdjacent(pos)
|
||||||
|
for i = 1, #adjacent do
|
||||||
|
if minetest.get_item_group(minetest.get_node(adjacent[i]).name, "wire") <= 0 then
|
||||||
|
adjacent[i] = false
|
||||||
|
else
|
||||||
|
split = split + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
power = math.floor(power / split)
|
||||||
|
for i = 1, #adjacent do
|
||||||
|
if adjacent[i] then
|
||||||
|
tech_reborn.wire.systems[minetest.get_meta(adjacent[i]):get_string("sys_id")].power =
|
||||||
|
tech_reborn.wire.systems[minetest.get_meta(adjacent[i]):get_string("sys_id")].power + power
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tech_reborn.wire.save_systems()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, pos, id)
|
||||||
|
end
|
20
energy/init.lua
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
tech_reborn.wire = {};
|
||||||
|
|
||||||
|
local path = minetest.get_modpath("tech_reborn") .. "/energy"
|
||||||
|
dofile(path .. "/model.lua")
|
||||||
|
dofile(path .. "/file.lua")
|
||||||
|
dofile(path .. "/functions.lua")
|
||||||
|
dofile(path .. "/energy-transfer.lua")
|
||||||
|
dofile(path .. "/nodes.lua")
|
||||||
|
|
||||||
|
--DEBUG--
|
||||||
|
--Disable in production
|
||||||
|
-- minetest.register_abm({
|
||||||
|
-- label = "DEBUG - Wires",
|
||||||
|
-- nodenames = {"group:wire"},
|
||||||
|
-- interval = 0.2,
|
||||||
|
-- chance = 1,
|
||||||
|
-- action = function(pos)
|
||||||
|
-- minetest.get_meta(pos):set_string("infotext", minetest.get_meta(pos):get_string("sys_id"))
|
||||||
|
-- end,
|
||||||
|
-- })
|
@ -1,100 +1,109 @@
|
|||||||
function machinery.wire.setModel(pos)
|
function tech_reborn.wire.recalcModels(pos)
|
||||||
|
local update = tech_reborn.getAdjacent(pos)
|
||||||
|
table.insert(update, pos)
|
||||||
|
for i = 1, #update do
|
||||||
|
if minetest.get_item_group(minetest.get_node(update[i]).name, "wire") > 0 then
|
||||||
|
tech_reborn.wire.setModel(update[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function tech_reborn.wire.setModel(pos)
|
||||||
local wires = {}
|
local wires = {}
|
||||||
local adjacent = machinery.getAdjacent(pos)
|
local adjacent = tech_reborn.getAdjacent(pos)
|
||||||
|
|
||||||
|
local def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||||
|
if not def then return false end
|
||||||
|
|
||||||
|
base = def._base_name
|
||||||
|
if not base then return false end
|
||||||
|
|
||||||
for i = 3, #adjacent do
|
for i = 3, #adjacent do
|
||||||
if minetest.get_item_group(minetest.get_node(adjacent[i]).name, "wire") > 0 then
|
if minetest.get_item_group(minetest.get_node(adjacent[i]).name, "wired_node") > 0 then
|
||||||
wires[i - 2] = true
|
wires[i - 2] = true
|
||||||
else wires[i - 2] = false end
|
else wires[i - 2] = false end
|
||||||
end
|
end
|
||||||
|
|
||||||
local suffix = ""
|
local suffix = ""
|
||||||
if minetest.get_item_group(minetest.get_node(adjacent[1]).name, "wire") > 0 then
|
if minetest.get_item_group(minetest.get_node(adjacent[1]).name, "wired_node") > 0 then
|
||||||
if minetest.get_item_group(minetest.get_node(adjacent[2]).name, "wire") > 0 then
|
if minetest.get_item_group(minetest.get_node(adjacent[2]).name, "wired_node") > 0 then
|
||||||
suffix = "_ud"
|
suffix = "_ud"
|
||||||
else suffix = "_u" end
|
else suffix = "_u" end
|
||||||
elseif minetest.get_item_group(minetest.get_node(adjacent[2]).name, "wire") > 0 then
|
elseif minetest.get_item_group(minetest.get_node(adjacent[2]).name, "wired_node") > 0 then
|
||||||
suffix = "_d"
|
suffix = "_d"
|
||||||
end
|
end
|
||||||
|
|
||||||
print(suffix)
|
|
||||||
|
|
||||||
if dump(wires) == dump({false, false, false, false}) then --Dot
|
if dump(wires) == dump({false, false, false, false}) then --Dot
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = "machinery:wire" .. suffix})
|
minetest.swap_node(pos, {name = base .. suffix})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, true, false, false}) then --Line A
|
elseif dump(wires) == dump({true, true, false, false}) then --Line A
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_line" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_line" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({false, false, true, true}) then --Line B
|
elseif dump(wires) == dump({false, false, true, true}) then --Line B
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_line" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_line" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, true, true, true}) then --Cross
|
elseif dump(wires) == dump({true, true, true, true}) then --Cross
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_cross" .. suffix})
|
minetest.swap_node(pos, {name = base .. "_cross" .. suffix})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, true, true, false}) then --Funnel Z-
|
elseif dump(wires) == dump({true, true, true, false}) then --Funnel Z-
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(0, 0, -1))
|
local facedir = minetest.dir_to_facedir(vector.new(0, 0, -1))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_funnel" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_funnel" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, true, false, true}) then --Funnel Z+
|
elseif dump(wires) == dump({true, true, false, true}) then --Funnel Z+
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_funnel" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_funnel" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, false, true, true}) then --Funnel X-
|
elseif dump(wires) == dump({true, false, true, true}) then --Funnel X-
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(-1, 0, 0))
|
local facedir = minetest.dir_to_facedir(vector.new(-1, 0, 0))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_funnel" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_funnel" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({false, true, true, true}) then --Funnel X+
|
elseif dump(wires) == dump({false, true, true, true}) then --Funnel X+
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_funnel" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_funnel" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, false, false, false}) then --End X+
|
elseif dump(wires) == dump({true, false, false, false}) then --End X+
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_end" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_ending" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({false, true, false, false}) then --End X-
|
elseif dump(wires) == dump({false, true, false, false}) then --End X-
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(0, 0, -1))
|
local facedir = minetest.dir_to_facedir(vector.new(0, 0, -1))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_end" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_ending" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({false, false, true, false}) then --End Z+
|
elseif dump(wires) == dump({false, false, true, false}) then --End Z+
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(-1, 0, 0))
|
local facedir = minetest.dir_to_facedir(vector.new(-1, 0, 0))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_end" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_ending" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({false, false, false, true}) then --End Z-
|
elseif dump(wires) == dump({false, false, false, true}) then --End Z-
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_end" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_ending" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, false, true, false}) then --Corner 1
|
elseif dump(wires) == dump({true, false, true, false}) then --Corner 1
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(0, 0, -1))
|
local facedir = minetest.dir_to_facedir(vector.new(0, 0, -1))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_corner_1" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_corner" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({true, false, false, true}) then --Corner 2
|
elseif dump(wires) == dump({true, false, false, true}) then --Corner 2
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(-1, 0, 0))
|
local facedir = minetest.dir_to_facedir(vector.new(-1, 0, 0))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_corner_1" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_corner" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({false, true, true, false}) then --Corner 3
|
elseif dump(wires) == dump({false, true, true, false}) then --Corner 3
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
local facedir = minetest.dir_to_facedir(vector.new(1, 0, 0))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_corner_1" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_corner" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
elseif dump(wires) == dump({false, true, false, true}) then --Corner 4
|
elseif dump(wires) == dump({false, true, false, true}) then --Corner 4
|
||||||
|
|
||||||
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
local facedir = minetest.dir_to_facedir(vector.new(0, 0, 1))
|
||||||
minetest.swap_node(pos, {name = "machinery:wire_corner_1" .. suffix, param2 = facedir})
|
minetest.swap_node(pos, {name = base .. "_corner" .. suffix, param2 = facedir})
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
145
energy/nodes.lua
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
local directions = {
|
||||||
|
_ = {{-1, -1, -1, 1, 1, 1}},
|
||||||
|
_ending = {{-1, -1, -1, 0.5, 1, 1}},
|
||||||
|
_line = {{-0.5, -1, -1, 0.5, 1, 1}},
|
||||||
|
_corner = {
|
||||||
|
{-0.5, -1, -1, 1, 1, 1},
|
||||||
|
{-1, -1, -0.5, 1, 1, 1}},
|
||||||
|
_funnel = {
|
||||||
|
{-0.5, -1, -1, 0.5, 1, 1},
|
||||||
|
{-1, -1, -0.5, 1, 1, 1}},
|
||||||
|
_cross = {
|
||||||
|
{-0.5, -1, -1, 0.5, 1, 1},
|
||||||
|
{-1, -1, -0.5, 1, 1, 0.5}}
|
||||||
|
}
|
||||||
|
local heights = {
|
||||||
|
_ = {},
|
||||||
|
_d = {-1, -0.5, -1, 1, 1, 1},
|
||||||
|
_u = {-1, -1, -1, 1, 0.5, 1},
|
||||||
|
_ud = {-1, -0.5, -1, 1, 0.5, 1}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tech_reborn.register_wires(name, data)
|
||||||
|
|
||||||
|
-- register_wire(name, data, nodebox, visible) -- Base Node
|
||||||
|
|
||||||
|
-- -- Add Nubs
|
||||||
|
-- table.insert(nodebox, {-data.width-0.0625, -data.width-0.0625, -data.width-0.0625,
|
||||||
|
-- data.width+0.0625, data.width+0.0625, data.width+0.0625})
|
||||||
|
|
||||||
|
-- local tex = data.texture
|
||||||
|
-- data.tex_insulated = tex .. "^tech_reborn_import_6"
|
||||||
|
-- register_wire(name .. "_import", data, nodebox, visible)
|
||||||
|
|
||||||
|
-- local tex = data.texture
|
||||||
|
-- data.texture = tex .. "^tech_reborn_export_6"
|
||||||
|
-- register_wire(name .. "_export", data, nodebox, visible)
|
||||||
|
|
||||||
|
for insulated = 0, 1 do
|
||||||
|
|
||||||
|
local tex = data.tex_base
|
||||||
|
if insulated == 1 then
|
||||||
|
name = name .. "_insulated"
|
||||||
|
tex = data.tex_insulated
|
||||||
|
data.size = data.size + 2
|
||||||
|
end
|
||||||
|
|
||||||
|
for hname, hbox in pairs(heights) do
|
||||||
|
for dname, dbox in pairs(directions) do
|
||||||
|
for mode = 0, 2 do
|
||||||
|
local mstring = ""
|
||||||
|
local estate = "none"
|
||||||
|
local inexoverlay = ""
|
||||||
|
|
||||||
|
local nodebox = table.copy(dbox)
|
||||||
|
table.insert(nodebox, table.copy(hbox))
|
||||||
|
|
||||||
|
local groups = {oddly_breakable_by_hand = 1, wire = 1, snappy = 3, wired_node = 1}
|
||||||
|
-- if not visible then
|
||||||
|
-- groups.not_in_creative_inventory = 1
|
||||||
|
-- end
|
||||||
|
groups[data.voltage] = 1
|
||||||
|
if hname == "_" then hname = "" end
|
||||||
|
if dname == "_" then dname = "" end
|
||||||
|
|
||||||
|
if mode > 0 then
|
||||||
|
table.insert(nodebox, {-(data.size+2)/16/2, -(data.size+2)/16/2, -(data.size+2)/16/2,
|
||||||
|
(data.size+2)/16/2, (data.size+2)/16/2, (data.size+2)/16/2})
|
||||||
|
end
|
||||||
|
if mode == 1 then
|
||||||
|
|
||||||
|
mstring = "_import"
|
||||||
|
estate = "import"
|
||||||
|
groups.import = 1
|
||||||
|
inexoverlay = "^tech_reborn_import_" .. (data.size+2) .. ".png"
|
||||||
|
|
||||||
|
elseif mode == 2 then
|
||||||
|
|
||||||
|
mstring = "_export"
|
||||||
|
estate = "export"
|
||||||
|
groups.export = 1
|
||||||
|
inexoverlay = "^tech_reborn_export_" .. (data.size+2) .. ".png"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local cname = name .. mstring .. dname .. hname
|
||||||
|
|
||||||
|
--Replace 1 with width values
|
||||||
|
for i = 1, #nodebox do
|
||||||
|
for j = 1, #nodebox[i] do
|
||||||
|
local val = nodebox[i][j]
|
||||||
|
if val == 1 then val = data.size/16/2
|
||||||
|
elseif val == -1 then val = -data.size/16/2 end
|
||||||
|
nodebox[i][j] = val
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("tech_reborn:" .. cname, {
|
||||||
|
description = data.description,
|
||||||
|
tiles = {tex .. inexoverlay},
|
||||||
|
groups = groups,
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
on_construct = tech_reborn.wire.constructWire,
|
||||||
|
on_destruct = tech_reborn.wire.removeWire,
|
||||||
|
on_rightclick = tech_reborn.wire.changeState,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = nodebox
|
||||||
|
},
|
||||||
|
_base_node = "tech_reborn:" .. name,
|
||||||
|
_base_name = "tech_reborn:" .. name .. mstring,
|
||||||
|
_export_state = estate,
|
||||||
|
_voltage = data.voltage,
|
||||||
|
drop = "tech_reborn:" .. name .. "_line",
|
||||||
|
node_placement_prediction = "tech_reborn:" .. name,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
tech_reborn.register_wires("copper_wire", {
|
||||||
|
description = "Insulated Copper Wire (LV)",
|
||||||
|
base_node = "tech_reborn:insulated_copper_wire",
|
||||||
|
voltage = "lv",
|
||||||
|
tex_insulated = "tech_reborn_lv_wire.png",
|
||||||
|
tex_base = "tech_reborn_copper_wire.png",
|
||||||
|
damage_for_second = 0,
|
||||||
|
size = 2
|
||||||
|
})
|
||||||
|
|
||||||
|
tech_reborn.register_wires("gold_wire", {
|
||||||
|
description = "Insulated Gold Wire (MV)",
|
||||||
|
base_node = "tech_reborn:insulated_gold_wire",
|
||||||
|
voltage = "mv",
|
||||||
|
tex_insulated = "tech_reborn_mv_wire.png",
|
||||||
|
tex_base = "tech_reborn_gold_wire.png",
|
||||||
|
damage_for_second = 0,
|
||||||
|
size = 4
|
||||||
|
})
|
107
helpers.lua
@ -2,14 +2,14 @@
|
|||||||
-- SERIALIZATION FUNCTIONS
|
-- SERIALIZATION FUNCTIONS
|
||||||
-- Turns position vector in string format, eg "10,25,-12" (x = 10, y = 25, z = -12)
|
-- Turns position vector in string format, eg "10,25,-12" (x = 10, y = 25, z = -12)
|
||||||
--
|
--
|
||||||
function machinery.deserializepos(posString)
|
function tech_reborn.deserializepos(posString)
|
||||||
local x = posString:sub(1, posString:find(",", 1, true) - 1)
|
local x = posString:sub(1, posString:find(",", 1, true) - 1)
|
||||||
local y = posString:sub(x:len() + 2, posString:find(",", x:len() + 2) - 1, true)
|
local y = posString:sub(x:len() + 2, posString:find(",", x:len() + 2) - 1, true)
|
||||||
local z = posString:sub(y:len() + 1 + x:len() + 2, posString:find(",", x:len() + 1 + y:len() + 2), true)
|
local z = posString:sub(y:len() + 1 + x:len() + 2, posString:find(",", x:len() + 1 + y:len() + 2), true)
|
||||||
return vector.new(tonumber(x), tonumber(y), tonumber(z))
|
return vector.new(tonumber(x), tonumber(y), tonumber(z))
|
||||||
end
|
end
|
||||||
|
|
||||||
function machinery.serializepos(pos)
|
function tech_reborn.serializepos(pos)
|
||||||
return pos.x..","..pos.y..","..pos.z
|
return pos.x..","..pos.y..","..pos.z
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ end
|
|||||||
-- GET ADJACENT
|
-- GET ADJACENT
|
||||||
-- Return adjacent nodes
|
-- Return adjacent nodes
|
||||||
--
|
--
|
||||||
function machinery.getAdjacent(pos)
|
function tech_reborn.getAdjacent(pos)
|
||||||
return {
|
return {
|
||||||
vector.new(pos.x, pos.y + 1, pos.z),
|
vector.new(pos.x, pos.y + 1, pos.z),
|
||||||
vector.new(pos.x, pos.y - 1, pos.z),
|
vector.new(pos.x, pos.y - 1, pos.z),
|
||||||
@ -26,105 +26,4 @@ function machinery.getAdjacent(pos)
|
|||||||
vector.new(pos.x, pos.y, pos.z + 1),
|
vector.new(pos.x, pos.y, pos.z + 1),
|
||||||
vector.new(pos.x, pos.y, pos.z - 1)
|
vector.new(pos.x, pos.y, pos.z - 1)
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
-- ME Functions
|
|
||||||
-- Functions to modify energy in wires
|
|
||||||
--
|
|
||||||
function machinery.pullAdjacentME(machineNode, amount)
|
|
||||||
local adj_nodes = machinery.getAdjacent(machineNode)
|
|
||||||
local systems = {}
|
|
||||||
|
|
||||||
--Find systems in adjacent nodes
|
|
||||||
for i = 1, #adj_nodes do
|
|
||||||
|
|
||||||
if minetest.get_node(adj_nodes[i]).name == "machinery:wire" or
|
|
||||||
minetest.get_node(adj_nodes[i]).name == "machinery:wire_controller" then
|
|
||||||
|
|
||||||
local system = minetest.get_meta(adj_nodes[i]):get_string("system")
|
|
||||||
if not system or system == "" then return false end
|
|
||||||
local found = false
|
|
||||||
for i = 1, #systems do
|
|
||||||
if machinery.serializepos(systems[i]) == system then found = true end
|
|
||||||
end
|
|
||||||
if not found then table.insert(systems, machinery.deserializepos(system)) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--If system doesn't have the capacity then remove it
|
|
||||||
for i = 1, #systems do
|
|
||||||
if minetest.get_meta(systems[i]):get_int("system_me") < amount then
|
|
||||||
table.remove(systems, i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--Pull power from system and return state
|
|
||||||
if #systems > 0 then
|
|
||||||
for i = 1, #systems do
|
|
||||||
minetest.get_meta(systems[i]):set_int("system_me", minetest.get_meta(systems[i]):get_int("system_me") - amount/#systems)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if amount > 0 then return amount end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- function machinery.pullNodeME
|
|
||||||
|
|
||||||
function machinery.pushAdjacentME(machineNode, amount)
|
|
||||||
local adj_nodes = machinery.getAdjacent(machineNode)
|
|
||||||
local systems = {}
|
|
||||||
|
|
||||||
--Find systems in adjacent nodes
|
|
||||||
for i = 1, #adj_nodes do
|
|
||||||
|
|
||||||
if minetest.get_node(adj_nodes[i]).name == "machinery:wire" or
|
|
||||||
minetest.get_node(adj_nodes[i]).name == "machinery:wire_controller" then
|
|
||||||
|
|
||||||
local system = minetest.get_meta(adj_nodes[i]):get_string("system")
|
|
||||||
if not system or system == "" then return false end
|
|
||||||
local found = false
|
|
||||||
for i = 1, #systems do
|
|
||||||
if machinery.serializepos(systems[i]) == system then found = true end
|
|
||||||
end
|
|
||||||
if not found then table.insert(systems, machinery.deserializepos(system)) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--If system doesn't have the capacity then remove it
|
|
||||||
for i = 1, #systems do
|
|
||||||
if minetest.get_meta(systems[i]):get_int("me_capacity") - minetest.get_meta(systems[i]):get_int("system_me") < amount then
|
|
||||||
table.remove(systems, i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--Push power from system and return state
|
|
||||||
if #systems > 0 then
|
|
||||||
for i = 1, #systems do
|
|
||||||
minetest.get_meta(systems[i]):set_int("system_me", minetest.get_meta(systems[i]):get_int("system_me") + amount/#systems)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if amount > 0 then return amount end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function machinery.checkAdjacentME(machineNode)
|
|
||||||
local adj_nodes = machinery.getAdjacent(machineNode)
|
|
||||||
local systems = {}
|
|
||||||
|
|
||||||
--Find systems in adjacent nodes
|
|
||||||
for i = 1, #adj_nodes do
|
|
||||||
if minetest.get_node(adj_nodes[i]).name == "machinery:wire" or
|
|
||||||
minetest.get_node(adj_nodes[i]).name == "machinery:wire_controller" then
|
|
||||||
local system = minetest.get_meta(adj_nodes[i]):get_string("system")
|
|
||||||
if not system or system == "" then return false end
|
|
||||||
local found = false
|
|
||||||
for i = 1, #systems do
|
|
||||||
if machinery.serializepos(systems[i]) == system then found = true end
|
|
||||||
end
|
|
||||||
if not found then table.insert(systems, machinery.deserializepos(system)) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--Calculate power
|
|
||||||
local power = 0
|
|
||||||
for i = 1, #systems do
|
|
||||||
power = power + minetest.get_meta(systems[i]):get_int("system_me")
|
|
||||||
end
|
|
||||||
return power
|
|
||||||
end
|
end
|
7
init.lua
@ -1,6 +1,7 @@
|
|||||||
machinery = {}
|
tech_reborn = {}
|
||||||
|
|
||||||
local path = minetest.get_modpath('machinery')
|
local path = minetest.get_modpath('tech_reborn')
|
||||||
dofile(path .. "/wires/init.lua")
|
dofile(path .. "/energy/init.lua")
|
||||||
dofile(path .. "/helpers.lua")
|
dofile(path .. "/helpers.lua")
|
||||||
dofile(path .. "/machines/init.lua")
|
dofile(path .. "/machines/init.lua")
|
||||||
|
dofile(path .. "/tool/init.lua")
|
@ -1,18 +1,23 @@
|
|||||||
minetest.register_node("machinery:machinery_battery", {
|
minetest.register_node("tech_reborn:tech_reborn_battery", {
|
||||||
description = "Battery",
|
description = "Battery",
|
||||||
tiles = {
|
tiles = {
|
||||||
"machinery_machine.png",
|
"tech_reborn_machine.png",
|
||||||
"machinery_machine.png",
|
"tech_reborn_machine.png",
|
||||||
"machinery_machine.png^machinery_battery.png",
|
"tech_reborn_machine.png^tech_reborn_battery.png",
|
||||||
"machinery_machine.png^machinery_battery.png",
|
"tech_reborn_machine.png^tech_reborn_battery.png",
|
||||||
"machinery_machine.png^machinery_battery.png",
|
"tech_reborn_machine.png^tech_reborn_battery.png",
|
||||||
"machinery_machine.png^machinery_battery.png",
|
"tech_reborn_machine.png^tech_reborn_battery.png",
|
||||||
},
|
},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = true,
|
on_construct = function(pos)
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, machine = 1},
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
after_destruct = function(pos)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
groups = {cracky = 1, oddly_breakable_by_hand = 1, machine = 1, wired_node = 1},
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
machinery_update = function(pos)
|
machine_update = function(pos)
|
||||||
machinery.pushAdjacentME(pos, 50)
|
tech_reborn.pushAdjacentEnergy(pos, 50)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
35
machines/creative.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
minetest.register_node("tech_reborn:tech_reborn_creative_emitter", {
|
||||||
|
description = "Creative Power Emitter",
|
||||||
|
tiles = {
|
||||||
|
"tech_reborn_machine.png^tech_reborn_creative_emitter.png",
|
||||||
|
},
|
||||||
|
on_construct = function(pos)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
after_destruct = function(pos)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
groups = {cracky = 1, oddly_breakable_by_hand = 1, machine = 1, wired_node = 1, dig_immediate = 3},
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
machine_update = function(pos)
|
||||||
|
tech_reborn.pushAdjacentEnergy(pos, 50)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("tech_reborn:tech_reborn_creative_consumer", {
|
||||||
|
description = "Creative Power Consumer",
|
||||||
|
tiles = {
|
||||||
|
"tech_reborn_machine.png^tech_reborn_creative_consumer.png",
|
||||||
|
},
|
||||||
|
on_construct = function(pos)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
after_destruct = function(pos)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
groups = {cracky = 1, oddly_breakable_by_hand = 1, machine = 1, wired_node = 1, dig_immediate = 3},
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
machine_update = function(pos)
|
||||||
|
tech_reborn.pullAdjacentEnergy(pos, 50)
|
||||||
|
end,
|
||||||
|
})
|
@ -1,13 +1,14 @@
|
|||||||
local path = minetest.get_modpath("machinery") .. "/machines"
|
local path = minetest.get_modpath("tech_reborn") .. "/machines"
|
||||||
|
|
||||||
dofile(path .. "/monitor.lua")
|
dofile(path .. "/monitor.lua")
|
||||||
dofile(path .. "/battery.lua")
|
dofile(path .. "/battery.lua")
|
||||||
|
dofile(path .. "/creative.lua")
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"group:machine"},
|
nodenames = {"group:machine"},
|
||||||
interval = 0.5,
|
interval = 0.1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
minetest.registered_nodes[minetest.get_node(pos).name].machinery_update(pos)
|
minetest.registered_nodes[minetest.get_node(pos).name].machine_update(pos)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
minetest.register_node("machinery:machine_monitor", {
|
minetest.register_node("tech_reborn:machine_monitor", {
|
||||||
description = "Monitor",
|
description = "Monitor",
|
||||||
tiles = {
|
tiles = {
|
||||||
"machinery_machine.png",
|
"tech_reborn_machine.png",
|
||||||
"machinery_machine.png",
|
"tech_reborn_machine.png",
|
||||||
"machinery_machine.png",
|
"tech_reborn_machine.png",
|
||||||
"machinery_machine.png",
|
"tech_reborn_machine.png",
|
||||||
"machinery_machine.png",
|
"tech_reborn_machine.png",
|
||||||
"machinery_machine.png^machinery_monitor.png",
|
"tech_reborn_machine.png^tech_reborn_monitor.png",
|
||||||
},
|
},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = true,
|
on_construct = function(pos)
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, machine = 1},
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
after_destruct = function(pos)
|
||||||
|
tech_reborn.wire.recalcModels(pos)
|
||||||
|
end,
|
||||||
|
groups = {cracky = 1, oddly_breakable_by_hand = 1, machine = 1, wired_node = 1},
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
machinery_update = function(pos)
|
machine_update = function(pos)
|
||||||
local power = machinery.checkAdjacentME(pos)
|
local power = tech_reborn.getAdjacentEnergy(pos)
|
||||||
if power == false then power = 0 end
|
if power == false then power = 0 end
|
||||||
minetest.get_meta(pos):set_string("infotext", "System Power: " .. power .. " ME")
|
minetest.get_meta(pos):set_string("infotext", "System Power: " .. power .. " ME")
|
||||||
end,
|
end,
|
||||||
|
Before Width: | Height: | Size: 652 B |
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |
BIN
textures/tech_reborn_copper_wire.png
Normal file
After Width: | Height: | Size: 648 B |
BIN
textures/tech_reborn_creative_consumer.png
Normal file
After Width: | Height: | Size: 528 B |
BIN
textures/tech_reborn_creative_emitter.png
Normal file
After Width: | Height: | Size: 614 B |
BIN
textures/tech_reborn_export_4.png
Normal file
After Width: | Height: | Size: 377 B |
BIN
textures/tech_reborn_export_6.png
Normal file
After Width: | Height: | Size: 322 B |
BIN
textures/tech_reborn_export_8.png
Normal file
After Width: | Height: | Size: 385 B |
BIN
textures/tech_reborn_gold_wire.png
Normal file
After Width: | Height: | Size: 620 B |
BIN
textures/tech_reborn_import_4.png
Normal file
After Width: | Height: | Size: 378 B |
BIN
textures/tech_reborn_import_6.png
Normal file
After Width: | Height: | Size: 408 B |
BIN
textures/tech_reborn_import_8.png
Normal file
After Width: | Height: | Size: 474 B |
BIN
textures/tech_reborn_large_panel.png
Normal file
After Width: | Height: | Size: 384 B |
BIN
textures/tech_reborn_large_panel_off.png
Normal file
After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 481 B |
BIN
textures/tech_reborn_machine.png
Normal file
After Width: | Height: | Size: 644 B |
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
BIN
textures/tech_reborn_mv_wire.png
Normal file
After Width: | Height: | Size: 483 B |
BIN
textures/tech_reborn_wrench.png
Normal file
After Width: | Height: | Size: 320 B |
15
tool/init.lua
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
minetest.register_tool("tech_reborn:wrench", {
|
||||||
|
inventory_image = "tech_reborn_wrench.png",
|
||||||
|
tooel_capabilities = {
|
||||||
|
full_punch_interval = 0.2,
|
||||||
|
max_drop_level = 1,
|
||||||
|
groupcaps = {
|
||||||
|
snappy = {maxlevel = 1, uses = 250, times = {
|
||||||
|
[0] = 0.1,
|
||||||
|
[1] = 0.1,
|
||||||
|
[2] = 0.1,
|
||||||
|
[3] = 0.1
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -1,28 +0,0 @@
|
|||||||
machinery.wire.systems = {}
|
|
||||||
machinery.wire.systemfile = minetest.get_worldpath() .. "/machinery_systems.mt"
|
|
||||||
|
|
||||||
local input = io.open(machinery.wire.systemfile, "r")
|
|
||||||
local filedata = nil
|
|
||||||
if input then
|
|
||||||
filedata = input:read('*all')
|
|
||||||
end
|
|
||||||
if filedata and filedata ~= "" then
|
|
||||||
machinery.wire.systems = minetest.deserialize(filedata)
|
|
||||||
io.close(input)
|
|
||||||
end
|
|
||||||
|
|
||||||
function machinery.wire.save_systems()
|
|
||||||
local output = io.open(machinery.wire.systemfile, "w")
|
|
||||||
output:write(minetest.serialize(machinery.wire.systems))
|
|
||||||
io.close(output)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function save_loop()
|
|
||||||
machinery.wire.save_systems()
|
|
||||||
minetest.after(2, save_loop)
|
|
||||||
end
|
|
||||||
minetest.after(0, save_loop)
|
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
|
||||||
machinery.wire.save_systems()
|
|
||||||
end)
|
|
@ -1,19 +0,0 @@
|
|||||||
machinery.wire = {};
|
|
||||||
|
|
||||||
local path = minetest.get_modpath("machinery") .. "/wires"
|
|
||||||
dofile(path .. "/model.lua")
|
|
||||||
dofile(path .. "/atomic.lua")
|
|
||||||
dofile(path .. "/logic.lua")
|
|
||||||
dofile(path .. "/nodes.lua")
|
|
||||||
|
|
||||||
--DEBUG--
|
|
||||||
--Disable in production
|
|
||||||
minetest.register_abm({
|
|
||||||
label = "DEBUG - Wires",
|
|
||||||
nodenames = {"group:wire"},
|
|
||||||
interval = 0.2,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos)
|
|
||||||
minetest.get_meta(pos):set_string("infotext", minetest.get_meta(pos):get_string("sys_id"))
|
|
||||||
end,
|
|
||||||
})
|
|
103
wires/logic.lua
@ -1,103 +0,0 @@
|
|||||||
function machinery.wire.constructWire(pos)
|
|
||||||
local update = machinery.getAdjacent(pos)
|
|
||||||
table.insert(update, pos)
|
|
||||||
for i = 1, #update do
|
|
||||||
if minetest.get_item_group(minetest.get_node(update[i]).name, "wire") > 0 then
|
|
||||||
machinery.wire.setModel(update[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
machinery.wire.createWire(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
function machinery.wire.consumeSystem(newSys, oldSys)
|
|
||||||
if newSys and newSys ~= "" and oldSys and oldSys ~= "" and
|
|
||||||
machinery.wire.systems[newSys] ~= nil and machinery.wire.systems[oldSys] ~= nil then
|
|
||||||
local children = machinery.wire.systems[oldSys].children
|
|
||||||
machinery.wire.systems[oldSys] = nil
|
|
||||||
|
|
||||||
for spos,_ in pairs(children) do
|
|
||||||
pos = machinery.deserializepos(spos)
|
|
||||||
machinery.wire.systems[newSys].children[spos] = true
|
|
||||||
minetest.get_meta(pos):set_string("sys_id", newSys)
|
|
||||||
end
|
|
||||||
|
|
||||||
machinery.wire.save_systems()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function machinery.wire.createWire(pos)
|
|
||||||
--Check Adjacent Nodes
|
|
||||||
local adjacent = machinery.getAdjacent(pos)
|
|
||||||
local found = false
|
|
||||||
for i = 1, #adjacent do
|
|
||||||
local node = adjacent[i]
|
|
||||||
if minetest.get_item_group(minetest.get_node(node).name, "wire") > 0 then
|
|
||||||
local id = minetest.get_meta(node):get_string("sys_id")
|
|
||||||
if id and id ~= "" then
|
|
||||||
if not found then
|
|
||||||
print("the id that I JUST FOUND is " .. id)
|
|
||||||
minetest.get_meta(pos):set_string("sys_id", id)
|
|
||||||
machinery.wire.systems[id].children[machinery.serializepos(pos)] = true
|
|
||||||
machinery.wire.save_systems()
|
|
||||||
found = id
|
|
||||||
else
|
|
||||||
if id ~= found then
|
|
||||||
machinery.wire.consumeSystem(found, id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if found then return true end
|
|
||||||
|
|
||||||
--No Adjacent Nodes to Pair to
|
|
||||||
local id = tostring(minetest.get_us_time())
|
|
||||||
minetest.get_meta(pos):set_string("sys_id", id)
|
|
||||||
machinery.wire.systems[id] = {
|
|
||||||
id = id,
|
|
||||||
children = {},
|
|
||||||
power = 0
|
|
||||||
}
|
|
||||||
machinery.wire.systems[id].children[machinery.serializepos(pos)] = true
|
|
||||||
machinery.wire.save_systems()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function machinery.wire.removeWire(pos)
|
|
||||||
local id = minetest.get_meta(pos):get_string("sys_id")
|
|
||||||
|
|
||||||
minetest.after(0, function(pos, id)
|
|
||||||
|
|
||||||
local update = machinery.getAdjacent(pos)
|
|
||||||
for i = 1, #update do
|
|
||||||
if minetest.get_item_group(minetest.get_node(update[i]).name, "wire") > 0 then
|
|
||||||
machinery.wire.setModel(update[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if id and id ~= "" then
|
|
||||||
if machinery.wire.systems[id] ~= nil then
|
|
||||||
|
|
||||||
local children = machinery.wire.systems[id].children
|
|
||||||
children[machinery.serializepos(pos)] = nil
|
|
||||||
|
|
||||||
machinery.wire.systems[id] = nil
|
|
||||||
|
|
||||||
for spos,_ in pairs(children) do
|
|
||||||
pos = machinery.deserializepos(spos)
|
|
||||||
minetest.get_meta(pos):set_string("sys_id", "")
|
|
||||||
end
|
|
||||||
|
|
||||||
for spos,_ in pairs(children) do
|
|
||||||
pos = machinery.deserializepos(spos)
|
|
||||||
machinery.wire.createWire(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
machinery.wire.save_systems()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end, pos, id)
|
|
||||||
end
|
|
598
wires/nodes.lua
@ -1,598 +0,0 @@
|
|||||||
function machinery.register_wire(name, description)
|
|
||||||
--Inventory Node
|
|
||||||
minetest.register_node(name, {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.125, 0.125},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_end", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_line", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_1", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_2", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_funnel", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_cross", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_d", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_end_d", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_line_d", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_1_d", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.125, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_2_d", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.125, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_funnel_d", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.125, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_cross_d", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.125, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_u", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.5, 0.125}, -- NodeBox1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_end_u", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.5, 0.125}, -- NodeBox1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_line_u", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.5, 0.125}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_1_u", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_2_u", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_funnel_u", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_cross_u", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_ud", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_end_ud", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.125, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_line_ud", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_1_ud", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_corner_2_ud", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.125, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.125, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_funnel_ud", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.125}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node(name .. "_cross_ud", {
|
|
||||||
description = description,
|
|
||||||
tiles = {"machinery_wire.png"},
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {dig_immediate = 3, oddly_breakable_by_hand = 1, wire = 1},
|
|
||||||
sounds = default.node_sound_metal_defaults(),
|
|
||||||
on_construct = machinery.wire.constructWire,
|
|
||||||
on_destruct = machinery.wire.removeWire,
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.125, -0.125, 0.5, 0.125, 0.125}, -- NodeBox1
|
|
||||||
{-0.125, -0.125, -0.5, 0.125, 0.125, 0.5}, -- NodeBox2
|
|
||||||
{-0.125, -0.5, -0.125, 0.125, 0.5, 0.125}, -- NodeBox3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drop = name
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
machinery.register_wire("machinery:wire", "Wire")
|
|