Some file tree changes
This commit is contained in:
parent
009bde499a
commit
f8e8538b6e
@ -3,6 +3,7 @@
|
|||||||
-- Overrides --
|
-- Overrides --
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
-- Remove iron_lump -> steel_ingot, because dynamics adds iron ingot
|
||||||
minetest.clear_craft({type = "cooking", output = "default:steel_ingot"})
|
minetest.clear_craft({type = "cooking", output = "default:steel_ingot"})
|
||||||
|
|
||||||
-----------
|
-----------
|
||||||
|
@ -40,17 +40,6 @@ minetest.register_ore({
|
|||||||
|
|
||||||
-- Nickel
|
-- Nickel
|
||||||
|
|
||||||
minetest.register_ore({
|
|
||||||
ore_type = "scatter",
|
|
||||||
ore = "elepower_dynamics:stone_with_nickel",
|
|
||||||
wherein = "default:stone",
|
|
||||||
clust_scarcity = 28 * 28 * 28,
|
|
||||||
clust_num_ores = 5,
|
|
||||||
clust_size = 3,
|
|
||||||
y_max = 31000,
|
|
||||||
y_min = -31000,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_ore({
|
minetest.register_ore({
|
||||||
ore_type = "scatter",
|
ore_type = "scatter",
|
||||||
ore = "elepower_dynamics:stone_with_nickel",
|
ore = "elepower_dynamics:stone_with_nickel",
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
-- Network graphs are built eminating from provider nodes.
|
-- Network graphs are built eminating from provider nodes.
|
||||||
|
-- TODO: Caching
|
||||||
-- Network cache
|
|
||||||
elefluid.graphcache = {nodes = {}}
|
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
-- Graph Functions --
|
-- Graph Functions --
|
||||||
@ -14,9 +12,6 @@ end
|
|||||||
|
|
||||||
local function add_node(nodes, pos, pnodeid)
|
local function add_node(nodes, pos, pnodeid)
|
||||||
local node_id = minetest.hash_node_position(pos)
|
local node_id = minetest.hash_node_position(pos)
|
||||||
if elefluid.graphcache.nodes[node_id] == "" then
|
|
||||||
elefluid.graphcache.nodes[node_id] = pnodeid
|
|
||||||
end
|
|
||||||
if nodes[node_id] then
|
if nodes[node_id] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -40,8 +35,7 @@ local function check_node(targets, all_nodes, pos, p_pos, pnodeid, queue)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not ele.helpers.get_item_group(node.name, "fluid_container") and
|
if not ele.helpers.get_item_group(node.name, "fluid_container") then
|
||||||
not ele.helpers.get_item_group(node.name, "fluidity_tank") then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -64,12 +58,7 @@ end
|
|||||||
local function fluid_targets(p_pos, pos)
|
local function fluid_targets(p_pos, pos)
|
||||||
local provider = minetest.get_node(p_pos)
|
local provider = minetest.get_node(p_pos)
|
||||||
local pnodeid = minetest.pos_to_string(p_pos)
|
local pnodeid = minetest.pos_to_string(p_pos)
|
||||||
--[[
|
|
||||||
if elefluid.graphcache[pnodeid] then
|
|
||||||
local cached = elefluid.graphcache[pnodeid]
|
|
||||||
return cached.targets
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
local targets = {}
|
local targets = {}
|
||||||
local queue = {}
|
local queue = {}
|
||||||
local all_nodes = {}
|
local all_nodes = {}
|
||||||
@ -77,8 +66,7 @@ local function fluid_targets(p_pos, pos)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node and ele.helpers.get_item_group(node.name, "elefluid_transport") then
|
if node and ele.helpers.get_item_group(node.name, "elefluid_transport") then
|
||||||
add_duct_node(all_nodes, pos, pnodeid, queue)
|
add_duct_node(all_nodes, pos, pnodeid, queue)
|
||||||
elseif node and (ele.helpers.get_item_group(node.name, "fluid_container") or
|
elseif node and ele.helpers.get_item_group(node.name, "fluid_container") then
|
||||||
ele.helpers.get_item_group(node.name, "fluidity_tank")) then
|
|
||||||
queue = {p_pos}
|
queue = {p_pos}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -90,14 +78,9 @@ local function fluid_targets(p_pos, pos)
|
|||||||
queue = to_visit
|
queue = to_visit
|
||||||
end
|
end
|
||||||
|
|
||||||
local prov_id = minetest.hash_node_position(p_pos)
|
|
||||||
elefluid.graphcache.nodes[prov_id] = pnodeid
|
|
||||||
|
|
||||||
targets = ele.helpers.flatten(targets)
|
targets = ele.helpers.flatten(targets)
|
||||||
all_nodes = ele.helpers.flatten(all_nodes)
|
all_nodes = ele.helpers.flatten(all_nodes)
|
||||||
|
|
||||||
elefluid.graphcache[pnodeid] = {all_nodes = all_nodes, targets = targets}
|
|
||||||
|
|
||||||
return targets
|
return targets
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -107,10 +90,10 @@ end
|
|||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"group:elefluid_transport_source"},
|
nodenames = {"group:elefluid_transport_source"},
|
||||||
label = "elefluidFluidGraphSource",
|
label = "elepower Fluid Transfer Tick",
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local meta1 = nil
|
local meta1 = nil
|
||||||
|
|
||||||
@ -120,7 +103,6 @@ minetest.register_abm({
|
|||||||
local tpos = vector.add(minetest.facedir_to_dir(node.param2), pos)
|
local tpos = vector.add(minetest.facedir_to_dir(node.param2), pos)
|
||||||
local tname = minetest.get_node(tpos).name
|
local tname = minetest.get_node(tpos).name
|
||||||
if not ele.helpers.get_item_group(tname, "elefluid_transport") and
|
if not ele.helpers.get_item_group(tname, "elefluid_transport") and
|
||||||
not ele.helpers.get_item_group(tname, "fluidity_tank") and
|
|
||||||
not ele.helpers.get_item_group(tname, "fluid_container") then
|
not ele.helpers.get_item_group(tname, "fluid_container") then
|
||||||
minetest.forceload_free_block(pos)
|
minetest.forceload_free_block(pos)
|
||||||
return
|
return
|
||||||
@ -145,8 +127,7 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Make sure source node is a registered fluid container
|
-- Make sure source node is a registered fluid container
|
||||||
if not ele.helpers.get_item_group(srcnode.name, "fluid_container") and
|
if not ele.helpers.get_item_group(srcnode.name, "fluid_container") then
|
||||||
not ele.helpers.get_item_group(srcnode.name, "fluidity_tank") then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -201,113 +182,7 @@ minetest.register_abm({
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function check_connections(pos)
|
|
||||||
local connections = {}
|
|
||||||
local positions = {
|
|
||||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
|
||||||
{x=pos.x-1, y=pos.y, z=pos.z},
|
|
||||||
{x=pos.x, y=pos.y+1, z=pos.z},
|
|
||||||
{x=pos.x, y=pos.y-1, z=pos.z},
|
|
||||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
|
||||||
{x=pos.x, y=pos.y, z=pos.z-1}}
|
|
||||||
|
|
||||||
for _,connected_pos in pairs(positions) do
|
|
||||||
local name = minetest.get_node(connected_pos).name
|
|
||||||
if ele.helpers.get_item_group(name, "elefluid_transport") or
|
|
||||||
ele.helpers.get_item_group(name, "elefluid_transport_source") or
|
|
||||||
ele.helpers.get_item_group(name, "fluid_container") or
|
|
||||||
ele.helpers.get_item_group(name, "fluidity_tank") then
|
|
||||||
table.insert(connections, connected_pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return connections
|
|
||||||
end
|
|
||||||
|
|
||||||
function elefluid.clear_networks(pos)
|
function elefluid.clear_networks(pos)
|
||||||
|
-- TODO: Fluid network cache
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
|
||||||
-- Update networks when a node has been placed or removed
|
|
||||||
function elefluid.clear_networks(pos)
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local name = node.name
|
|
||||||
local placed = name ~= "air"
|
|
||||||
local positions = check_connections(pos)
|
|
||||||
if #positions < 1 then return end
|
|
||||||
local dead_end = #positions == 1
|
|
||||||
for _,connected_pos in pairs(positions) do
|
|
||||||
local net = elefluid.graphcache.nodes[minetest.hash_node_position(connected_pos)] or minetest.pos_to_string(connected_pos)
|
|
||||||
if net and elefluid.graphcache[net] then
|
|
||||||
if dead_end and placed then
|
|
||||||
-- Dead end placed, add it to the network
|
|
||||||
-- Get the network
|
|
||||||
local node_at = minetest.get_node(positions[1])
|
|
||||||
local network_id = elefluid.graphcache.nodes[minetest.hash_node_position(positions[1])] or minetest.pos_to_string(positions[1])
|
|
||||||
|
|
||||||
if not network_id or not elefluid.graphcache[network_id] then
|
|
||||||
-- We're evidently not on a network, nothing to add ourselves to
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local c_pos = minetest.string_to_pos(network_id)
|
|
||||||
local network = elefluid.graphcache[network_id]
|
|
||||||
|
|
||||||
-- Actually add it to the (cached) network
|
|
||||||
-- This is similar to check_node_subp
|
|
||||||
elefluid.graphcache.nodes[minetest.hash_node_position(pos)] = network_id
|
|
||||||
pos.visited = 1
|
|
||||||
|
|
||||||
if ele.helpers.get_item_group(name, "elefluid_transport") then
|
|
||||||
table.insert(network.all_nodes, pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
if ele.helpers.get_item_group(name, "fluid_container") or
|
|
||||||
ele.helpers.get_item_group(name, "fluidity_tank") then
|
|
||||||
table.insert(network.targets, pos)
|
|
||||||
end
|
|
||||||
elseif dead_end and not placed then
|
|
||||||
-- Dead end removed, remove it from the network
|
|
||||||
-- Get the network
|
|
||||||
local network_id = elefluid.graphcache.nodes[minetest.hash_node_position(positions[1])] or minetest.pos_to_string(positions[1])
|
|
||||||
if not network_id or not elefluid.graphcache[network_id] then
|
|
||||||
-- We're evidently not on a network, nothing to remove ourselves from
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local network = elefluid.graphcache[network_id]
|
|
||||||
|
|
||||||
-- The network was deleted.
|
|
||||||
if network_id == minetest.pos_to_string(pos) then
|
|
||||||
for _,v in ipairs(network.all_nodes) do
|
|
||||||
local pos1 = minetest.hash_node_position(v)
|
|
||||||
clear_networks_from_node(v)
|
|
||||||
elefluid.graphcache.nodes[pos1] = nil
|
|
||||||
end
|
|
||||||
elefluid.graphcache[network_id] = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Search for and remove device
|
|
||||||
elefluid.graphcache.nodes[minetest.hash_node_position(pos)] = nil
|
|
||||||
for tblname,table in pairs(network) do
|
|
||||||
if type(table) == "table" then
|
|
||||||
for devicenum,device in pairs(table) do
|
|
||||||
if vector.equals(device, pos) then
|
|
||||||
table[devicenum] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- Not a dead end, so the whole network needs to be recalculated
|
|
||||||
for _,v in ipairs(elefluid.graphcache[net].all_nodes) do
|
|
||||||
local pos1 = minetest.hash_node_position(v)
|
|
||||||
clear_networks_from_node(v)
|
|
||||||
elefluid.graphcache.nodes[pos1] = nil
|
|
||||||
end
|
|
||||||
elefluid.graphcache[net] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
dofile(elepm.modpath.."/bases/crafter.lua")
|
|
||||||
dofile(elepm.modpath.."/bases/generator.lua")
|
|
||||||
dofile(elepm.modpath.."/bases/storage.lua")
|
|
@ -1,13 +1,12 @@
|
|||||||
|
|
||||||
|
--*****************--
|
||||||
|
-- MACHINE RECIPES --
|
||||||
|
--*****************--
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
-- Alloying --
|
-- Alloying --
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
elepm.register_craft_type("alloy", {
|
|
||||||
description = "Alloying",
|
|
||||||
inputs = 2,
|
|
||||||
})
|
|
||||||
|
|
||||||
local alloy_recipes = {
|
local alloy_recipes = {
|
||||||
{
|
{
|
||||||
recipe = { "elepower_dynamics:iron_ingot", "elepower_dynamics:coal_dust 4" },
|
recipe = { "elepower_dynamics:iron_ingot", "elepower_dynamics:coal_dust 4" },
|
||||||
@ -21,6 +20,10 @@ local alloy_recipes = {
|
|||||||
{
|
{
|
||||||
recipe = { "default:iron_ingot 3", "elepower_dynamics:nickel_ingot" },
|
recipe = { "default:iron_ingot 3", "elepower_dynamics:nickel_ingot" },
|
||||||
output = "elepower_dynamics:invar_ingot 4",
|
output = "elepower_dynamics:invar_ingot 4",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
recipe = { "default:gold_ingot 2", "elepower_dynamics:invar_ingot" },
|
||||||
|
output = "elepower_dynamics:electrum_ingot 3",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,32 +37,10 @@ for _,i in pairs(alloy_recipes) do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
elepm.register_crafter("elepower_machines:alloy_furnace", {
|
|
||||||
description = "Alloy Furnace",
|
|
||||||
craft_type = "alloy",
|
|
||||||
ele_active_node = true,
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_alloy_furnace.png",
|
|
||||||
},
|
|
||||||
ele_active_nodedef = {
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_alloy_furnace_active.png",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
groups = {oddly_breakable_by_hand = 1}
|
|
||||||
})
|
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
-- Grinding --
|
-- Grinding --
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
elepm.register_craft_type("grind", {
|
|
||||||
description = "Grinding",
|
|
||||||
inputs = 1,
|
|
||||||
})
|
|
||||||
|
|
||||||
local keywords = { _ingot = 1, _lump = 2, _block = 9, block = 9 }
|
local keywords = { _ingot = 1, _lump = 2, _block = 9, block = 9 }
|
||||||
for mat, data in pairs(elepd.registered_dusts) do
|
for mat, data in pairs(elepd.registered_dusts) do
|
||||||
local kwfound = nil
|
local kwfound = nil
|
||||||
@ -90,55 +71,10 @@ for mat, data in pairs(elepd.registered_dusts) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elepm.register_crafter("elepower_machines:pulverizer", {
|
|
||||||
description = "Pulverizer",
|
|
||||||
craft_type = "grind",
|
|
||||||
ele_active_node = true,
|
|
||||||
ele_usage = 32,
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_grinder.png",
|
|
||||||
},
|
|
||||||
ele_active_nodedef = {
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_grinder_active.png",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
groups = {oddly_breakable_by_hand = 1}
|
|
||||||
})
|
|
||||||
|
|
||||||
-------------
|
|
||||||
-- Furnace --
|
|
||||||
-------------
|
|
||||||
|
|
||||||
elepm.register_crafter("elepower_machines:furnace", {
|
|
||||||
description = "Powered Furnace",
|
|
||||||
craft_type = "cooking",
|
|
||||||
ele_active_node = true,
|
|
||||||
ele_usage = 32,
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_furnace.png",
|
|
||||||
},
|
|
||||||
ele_active_nodedef = {
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_furnace_active.png",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
groups = {oddly_breakable_by_hand = 1}
|
|
||||||
})
|
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
-- Sawmill --
|
-- Sawmill --
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
elepm.register_craft_type("saw", {
|
|
||||||
description = "Sawmilling",
|
|
||||||
inputs = 1,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Register all logs as sawable, if we can find a planks version
|
-- Register all logs as sawable, if we can find a planks version
|
||||||
minetest.after(0.2, function ()
|
minetest.after(0.2, function ()
|
||||||
local wood_nodes = {}
|
local wood_nodes = {}
|
||||||
@ -171,56 +107,11 @@ minetest.after(0.2, function ()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
elepm.register_crafter("elepower_machines:sawmill", {
|
|
||||||
description = "Sawmill",
|
|
||||||
craft_type = "saw",
|
|
||||||
ele_usage = 32,
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_sawmill.png",
|
|
||||||
},
|
|
||||||
groups = {oddly_breakable_by_hand = 1}
|
|
||||||
})
|
|
||||||
|
|
||||||
----------------------
|
|
||||||
-- Power Generation --
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
elepm.register_fuel_generator("elepower_machines:generator", {
|
|
||||||
description = "Coal-fired Generator",
|
|
||||||
ele_active_node = true,
|
|
||||||
ele_capacity = 6400,
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_generator.png",
|
|
||||||
},
|
|
||||||
ele_active_nodedef = {
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_generator_active.png",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
groups = {oddly_breakable_by_hand = 1}
|
|
||||||
})
|
|
||||||
|
|
||||||
-------------------
|
|
||||||
-- Power Storage --
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
elepm.register_storage("elepower_machines:power_cell", {
|
|
||||||
description = "Power Cell",
|
|
||||||
ele_capacity = 16000,
|
|
||||||
tiles = {
|
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_power_cell.png",
|
|
||||||
},
|
|
||||||
groups = {oddly_breakable_by_hand = 1}
|
|
||||||
})
|
|
||||||
|
|
||||||
--******************--
|
--******************--
|
||||||
-- CRAFTING RECIPES --
|
-- CRAFTING RECIPES --
|
||||||
--******************--
|
--******************--
|
||||||
|
|
||||||
|
-- Machine block
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "elepower_machines:machine_block",
|
output = "elepower_machines:machine_block",
|
||||||
recipe = {
|
recipe = {
|
@ -6,9 +6,15 @@ local modpath = minetest.get_modpath(minetest.get_current_modname())
|
|||||||
elepm = rawget(_G, "elepm") or {}
|
elepm = rawget(_G, "elepm") or {}
|
||||||
elepm.modpath = modpath
|
elepm.modpath = modpath
|
||||||
|
|
||||||
|
-- Utility
|
||||||
dofile(modpath.."/craft.lua")
|
dofile(modpath.."/craft.lua")
|
||||||
dofile(modpath.."/formspec.lua")
|
dofile(modpath.."/formspec.lua")
|
||||||
dofile(modpath.."/bases/init.lua")
|
|
||||||
|
-- Machines
|
||||||
|
dofile(modpath.."/machines/init.lua")
|
||||||
|
|
||||||
|
-- Other
|
||||||
dofile(modpath.."/nodes.lua")
|
dofile(modpath.."/nodes.lua")
|
||||||
dofile(modpath.."/special/init.lua")
|
|
||||||
dofile(modpath.."/register.lua")
|
-- Crafting recipes
|
||||||
|
dofile(modpath.."/crafting.lua")
|
||||||
|
22
elepower_machines/machines/alloy_furnace.lua
Normal file
22
elepower_machines/machines/alloy_furnace.lua
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
elepm.register_craft_type("alloy", {
|
||||||
|
description = "Alloying",
|
||||||
|
inputs = 2,
|
||||||
|
})
|
||||||
|
|
||||||
|
elepm.register_crafter("elepower_machines:alloy_furnace", {
|
||||||
|
description = "Alloy Furnace",
|
||||||
|
craft_type = "alloy",
|
||||||
|
ele_active_node = true,
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_alloy_furnace.png",
|
||||||
|
},
|
||||||
|
ele_active_nodedef = {
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_alloy_furnace_active.png",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
groups = {oddly_breakable_by_hand = 1}
|
||||||
|
})
|
4
elepower_machines/machines/bases/init.lua
Normal file
4
elepower_machines/machines/bases/init.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
dofile(elepm.modpath.."/machines/bases/crafter.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/bases/generator.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/bases/storage.lua")
|
22
elepower_machines/machines/furnace.lua
Normal file
22
elepower_machines/machines/furnace.lua
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
-------------
|
||||||
|
-- Furnace --
|
||||||
|
-------------
|
||||||
|
|
||||||
|
elepm.register_crafter("elepower_machines:furnace", {
|
||||||
|
description = "Powered Furnace",
|
||||||
|
craft_type = "cooking",
|
||||||
|
ele_active_node = true,
|
||||||
|
ele_usage = 32,
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_furnace.png",
|
||||||
|
},
|
||||||
|
ele_active_nodedef = {
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_furnace_active.png",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
groups = {oddly_breakable_by_hand = 1}
|
||||||
|
})
|
21
elepower_machines/machines/generator.lua
Normal file
21
elepower_machines/machines/generator.lua
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
----------------------
|
||||||
|
-- Power Generation --
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
elepm.register_fuel_generator("elepower_machines:generator", {
|
||||||
|
description = "Coal-fired Generator",
|
||||||
|
ele_active_node = true,
|
||||||
|
ele_capacity = 6400,
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_generator.png",
|
||||||
|
},
|
||||||
|
ele_active_nodedef = {
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_generator_active.png",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
groups = {oddly_breakable_by_hand = 1}
|
||||||
|
})
|
9
elepower_machines/machines/init.lua
Normal file
9
elepower_machines/machines/init.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
dofile(elepm.modpath.."/machines/bases/init.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/accumulator.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/furnace.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/alloy_furnace.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/pulverizer.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/sawmill.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/generator.lua")
|
||||||
|
dofile(elepm.modpath.."/machines/storage.lua")
|
23
elepower_machines/machines/pulverizer.lua
Normal file
23
elepower_machines/machines/pulverizer.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
elepm.register_craft_type("grind", {
|
||||||
|
description = "Grinding",
|
||||||
|
inputs = 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
elepm.register_crafter("elepower_machines:pulverizer", {
|
||||||
|
description = "Pulverizer",
|
||||||
|
craft_type = "grind",
|
||||||
|
ele_active_node = true,
|
||||||
|
ele_usage = 32,
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_grinder.png",
|
||||||
|
},
|
||||||
|
ele_active_nodedef = {
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_grinder_active.png",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
groups = {oddly_breakable_by_hand = 1}
|
||||||
|
})
|
16
elepower_machines/machines/sawmill.lua
Normal file
16
elepower_machines/machines/sawmill.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
elepm.register_craft_type("saw", {
|
||||||
|
description = "Sawmilling",
|
||||||
|
inputs = 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
elepm.register_crafter("elepower_machines:sawmill", {
|
||||||
|
description = "Sawmill",
|
||||||
|
craft_type = "saw",
|
||||||
|
ele_usage = 32,
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_sawmill.png",
|
||||||
|
},
|
||||||
|
groups = {oddly_breakable_by_hand = 1}
|
||||||
|
})
|
14
elepower_machines/machines/storage.lua
Normal file
14
elepower_machines/machines/storage.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
-------------------
|
||||||
|
-- Power Storage --
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
elepm.register_storage("elepower_machines:power_cell", {
|
||||||
|
description = "Power Cell",
|
||||||
|
ele_capacity = 16000,
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_power_cell.png",
|
||||||
|
},
|
||||||
|
groups = {oddly_breakable_by_hand = 1}
|
||||||
|
})
|
@ -1,5 +1,4 @@
|
|||||||
-- Nodes other than machines.
|
-- Nodes other than machines.
|
||||||
-- Machines are registered in `register.lua`!
|
|
||||||
|
|
||||||
minetest.register_node("elepower_machines:machine_block", {
|
minetest.register_node("elepower_machines:machine_block", {
|
||||||
description = "Machine Block\nSafe for decoration",
|
description = "Machine Block\nSafe for decoration",
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
dofile(elepm.modpath.."/special/accumulator.lua")
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 7.0 KiB |
@ -162,28 +162,13 @@ end
|
|||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"group:ele_provider"},
|
nodenames = {"group:ele_provider"},
|
||||||
label = "elepowerPowerGraphSource",
|
label = "elepower Power Transfer Tick",
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local meta1 = nil
|
local meta1 = nil
|
||||||
|
|
||||||
-- Check if a provider is attached to a network.
|
|
||||||
-- If that network has been abolished, we will use this node as the network's root this time.
|
|
||||||
local netwrkto = meta:get_string("ele_network")
|
|
||||||
if netwrkto ~= "" and netwrkto ~= nil then
|
|
||||||
if not ele.helpers.get_item_group(node.name, "ele_storage") then
|
|
||||||
local lpos = minetest.string_to_pos(netwrkto)
|
|
||||||
if ele.helpers.get_item_group(minetest.get_node(lpos).name, "ele_provider") then
|
|
||||||
return
|
|
||||||
else
|
|
||||||
ele.graphcache[netwrkto] = nil
|
|
||||||
end
|
|
||||||
meta:set_string("ele_network", "")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local users = {}
|
local users = {}
|
||||||
local providers = {}
|
local providers = {}
|
||||||
|
|
||||||
@ -200,10 +185,12 @@ minetest.register_abm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
local branches = {}
|
local branches = {}
|
||||||
for _,pos1 in pairs(positions) do
|
for _,pos1 in ipairs(positions) do
|
||||||
local pnode = minetest.get_node(pos1)
|
local pnode = minetest.get_node(pos1)
|
||||||
local name = pnode.name
|
local name = pnode.name
|
||||||
local networked = ele.helpers.get_item_group(name, "ele_machine") or ele.helpers.get_item_group(name, "ele_conductor")
|
local networked = ele.helpers.get_item_group(name, "ele_machine") or
|
||||||
|
ele.helpers.get_item_group(name, "ele_conductor")
|
||||||
|
|
||||||
if networked then
|
if networked then
|
||||||
branches[#branches + 1] = pos1
|
branches[#branches + 1] = pos1
|
||||||
end
|
end
|
||||||
@ -243,14 +230,13 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Sharing: Determine how much each user gets
|
-- Sharing: Determine how much each user gets
|
||||||
local user_supply = (pw_supply - pw_demand) / #users
|
local user_gets, user_storage = give_node_power(ndv, (pw_supply - pw_demand))
|
||||||
local user_gets, user_storage = give_node_power(ndv, user_supply)
|
|
||||||
pw_demand = pw_demand + user_gets
|
pw_demand = pw_demand + user_gets
|
||||||
|
|
||||||
local user_meta = minetest.get_meta(ndv)
|
|
||||||
user_meta:set_int("storage", user_storage + user_gets)
|
|
||||||
|
|
||||||
if user_gets > 0 then
|
if user_gets > 0 then
|
||||||
|
local user_meta = minetest.get_meta(ndv)
|
||||||
|
user_meta:set_int("storage", user_storage + user_gets)
|
||||||
|
|
||||||
-- Set timer on this node
|
-- Set timer on this node
|
||||||
local t = minetest.get_node_timer(ndv)
|
local t = minetest.get_node_timer(ndv)
|
||||||
if not t:is_started() then
|
if not t:is_started() then
|
||||||
@ -289,7 +275,7 @@ local function check_connections(pos)
|
|||||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
{x=pos.x, y=pos.y, z=pos.z+1},
|
||||||
{x=pos.x, y=pos.y, z=pos.z-1}}
|
{x=pos.x, y=pos.y, z=pos.z-1}}
|
||||||
|
|
||||||
for _,connected_pos in pairs(positions) do
|
for _,connected_pos in ipairs(positions) do
|
||||||
local name = minetest.get_node(connected_pos).name
|
local name = minetest.get_node(connected_pos).name
|
||||||
if ele.helpers.get_item_group(name, "ele_conductor") or ele.helpers.get_item_group(name, "ele_machine") then
|
if ele.helpers.get_item_group(name, "ele_conductor") or ele.helpers.get_item_group(name, "ele_machine") then
|
||||||
table.insert(connections, connected_pos)
|
table.insert(connections, connected_pos)
|
||||||
@ -306,8 +292,9 @@ function ele.clear_networks(pos)
|
|||||||
local placed = name ~= "air"
|
local placed = name ~= "air"
|
||||||
local positions = check_connections(pos)
|
local positions = check_connections(pos)
|
||||||
if #positions < 1 then return end
|
if #positions < 1 then return end
|
||||||
|
local hash_pos = minetest.hash_node_position(pos)
|
||||||
local dead_end = #positions == 1
|
local dead_end = #positions == 1
|
||||||
for _,connected_pos in pairs(positions) do
|
for _,connected_pos in ipairs(positions) do
|
||||||
local networks = ele.graphcache.devices[minetest.hash_node_position(connected_pos)] or
|
local networks = ele.graphcache.devices[minetest.hash_node_position(connected_pos)] or
|
||||||
{minetest.pos_to_string(connected_pos)}
|
{minetest.pos_to_string(connected_pos)}
|
||||||
|
|
||||||
@ -328,17 +315,15 @@ function ele.clear_networks(pos)
|
|||||||
|
|
||||||
for _, int_net in ipairs(network_ids) do
|
for _, int_net in ipairs(network_ids) do
|
||||||
if ele.graphcache[int_net] then
|
if ele.graphcache[int_net] then
|
||||||
local c_pos = minetest.string_to_pos(int_net)
|
|
||||||
local network = ele.graphcache[int_net]
|
local network = ele.graphcache[int_net]
|
||||||
|
|
||||||
-- Actually add it to the (cached) network
|
-- Actually add it to the (cached) network
|
||||||
if not ele.graphcache.devices[minetest.hash_node_position(pos)] then
|
if not ele.graphcache.devices[hash_pos] then
|
||||||
ele.graphcache.devices[minetest.hash_node_position(pos)] = {}
|
ele.graphcache.devices[hash_pos] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = ele.graphcache.devices[minetest.hash_node_position(pos)]
|
if not table_has_string(ele.graphcache.devices[hash_pos], int_net) then
|
||||||
if not table_has_string(t, int_net) then
|
table.insert(ele.graphcache.devices[hash_pos], int_net)
|
||||||
table.insert(t, int_net)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ele.helpers.get_item_group(name, "ele_conductor") then
|
if ele.helpers.get_item_group(name, "ele_conductor") then
|
||||||
@ -379,7 +364,7 @@ function ele.clear_networks(pos)
|
|||||||
ele.graphcache[int_net] = nil
|
ele.graphcache[int_net] = nil
|
||||||
else
|
else
|
||||||
-- Search for and remove device
|
-- Search for and remove device
|
||||||
ele.graphcache.devices[minetest.hash_node_position(pos)] = nil
|
ele.graphcache.devices[hash_pos] = nil
|
||||||
for tblname, table in pairs(network) do
|
for tblname, table in pairs(network) do
|
||||||
if type(table) == "table" then
|
if type(table) == "table" then
|
||||||
for devicenum, device in pairs(table) do
|
for devicenum, device in pairs(table) do
|
||||||
|
Loading…
Reference in New Issue
Block a user