forked from minetest-mods/technic
Make switching station run all machines it is connected to, including those in unloaded blocks.
This commit is contained in:
parent
871ded6e6a
commit
563a4c071d
@ -43,6 +43,7 @@ Inventory move disallowed due to protection =
|
|||||||
%s Unpowered =
|
%s Unpowered =
|
||||||
%s Out Of Fuel =
|
%s Out Of Fuel =
|
||||||
%s Has Bad Cabling =
|
%s Has Bad Cabling =
|
||||||
|
%s (Slave) =
|
||||||
%s Has No Network =
|
%s Has No Network =
|
||||||
%s Finished =
|
%s Finished =
|
||||||
Enable/Disable =
|
Enable/Disable =
|
||||||
|
@ -103,71 +103,12 @@ local mesecons = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_node("technic:forcefield_emitter_off", {
|
local run = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
description = S("%s Forcefield Emitter"):format("HV"),
|
|
||||||
tiles = {"technic_forcefield_emitter_off.png"},
|
|
||||||
groups = {cracky = 1},
|
|
||||||
on_receive_fields = forcefield_receive_fields,
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_int("HV_EU_input", 0)
|
|
||||||
meta:set_int("HV_EU_demand", 0)
|
|
||||||
meta:set_int("range", 10)
|
|
||||||
meta:set_int("enabled", 0)
|
|
||||||
meta:set_string("infotext", S("%s Forcefield Emitter"):format("HV"))
|
|
||||||
set_forcefield_formspec(meta)
|
|
||||||
end,
|
|
||||||
mesecons = mesecons
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:forcefield_emitter_on", {
|
|
||||||
description = S("%s Forcefield Emitter"):format("HV"),
|
|
||||||
tiles = {"technic_forcefield_emitter_on.png"},
|
|
||||||
groups = {cracky = 1, not_in_creative_inventory=1},
|
|
||||||
drop = "technic:forcefield_emitter_off",
|
|
||||||
on_receive_fields = forcefield_receive_fields,
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local range = meta:get_int("range")
|
|
||||||
meta:set_string("formspec", get_forcefield_formspec(range))
|
|
||||||
end,
|
|
||||||
on_destruct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
update_forcefield(pos, meta:get_int("range"), false)
|
|
||||||
end,
|
|
||||||
mesecons = mesecons
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:forcefield", {
|
|
||||||
description = S("%s Forcefield"):format("HV"),
|
|
||||||
sunlight_propagates = true,
|
|
||||||
drawtype = "glasslike",
|
|
||||||
groups = {not_in_creative_inventory=1, unbreakable=1},
|
|
||||||
paramtype = "light",
|
|
||||||
light_source = 15,
|
|
||||||
drop = '',
|
|
||||||
tiles = {{
|
|
||||||
name = "technic_forcefield_animated.png",
|
|
||||||
animation = {
|
|
||||||
type = "vertical_frames",
|
|
||||||
aspect_w = 16,
|
|
||||||
aspect_h = 16,
|
|
||||||
length = 1.0,
|
|
||||||
},
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:forcefield_emitter_on", "technic:forcefield_emitter_off"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local eu_input = meta:get_int("HV_EU_input")
|
local eu_input = meta:get_int("HV_EU_input")
|
||||||
local eu_demand = meta:get_int("HV_EU_demand")
|
local eu_demand = meta:get_int("HV_EU_demand")
|
||||||
local enabled = meta:get_int("enabled")
|
local enabled = meta:get_int("enabled")
|
||||||
local machine_name = S("%s Forcefield Emitter"):format("HV")
|
local machine_name = S("%s Forcefield Emitter"):format("HV")
|
||||||
-- Power off automatically if no longer connected to a switching station
|
|
||||||
technic.switching_station_timeout_count(pos, "HV")
|
|
||||||
|
|
||||||
local power_requirement = math.floor(
|
local power_requirement = math.floor(
|
||||||
4 * math.pi * math.pow(meta:get_int("range"), 2)
|
4 * math.pi * math.pow(meta:get_int("range"), 2)
|
||||||
@ -195,13 +136,69 @@ minetest.register_abm({
|
|||||||
update_forcefield(pos, meta:get_int("range"), true)
|
update_forcefield(pos, meta:get_int("range"), true)
|
||||||
end
|
end
|
||||||
meta:set_int("HV_EU_demand", power_requirement)
|
meta:set_int("HV_EU_demand", power_requirement)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:forcefield_emitter_off", {
|
||||||
|
description = S("%s Forcefield Emitter"):format("HV"),
|
||||||
|
tiles = {"technic_forcefield_emitter_off.png"},
|
||||||
|
groups = {cracky = 1, technic_machine = 1},
|
||||||
|
on_receive_fields = forcefield_receive_fields,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_int("HV_EU_input", 0)
|
||||||
|
meta:set_int("HV_EU_demand", 0)
|
||||||
|
meta:set_int("range", 10)
|
||||||
|
meta:set_int("enabled", 0)
|
||||||
|
meta:set_string("infotext", S("%s Forcefield Emitter"):format("HV"))
|
||||||
|
set_forcefield_formspec(meta)
|
||||||
|
end,
|
||||||
|
mesecons = mesecons,
|
||||||
|
technic_run = run,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:forcefield_emitter_on", {
|
||||||
|
description = S("%s Forcefield Emitter"):format("HV"),
|
||||||
|
tiles = {"technic_forcefield_emitter_on.png"},
|
||||||
|
groups = {cracky = 1, technic_machine = 1, not_in_creative_inventory=1},
|
||||||
|
drop = "technic:forcefield_emitter_off",
|
||||||
|
on_receive_fields = forcefield_receive_fields,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local range = meta:get_int("range")
|
||||||
|
meta:set_string("formspec", get_forcefield_formspec(range))
|
||||||
|
end,
|
||||||
|
on_destruct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
update_forcefield(pos, meta:get_int("range"), false)
|
||||||
|
end,
|
||||||
|
mesecons = mesecons,
|
||||||
|
technic_run = run,
|
||||||
|
technic_disabled_machine_name = "technic:forcefield_emitter",
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:forcefield", {
|
||||||
|
description = S("%s Forcefield"):format("HV"),
|
||||||
|
sunlight_propagates = true,
|
||||||
|
drawtype = "glasslike",
|
||||||
|
groups = {not_in_creative_inventory=1, unbreakable=1},
|
||||||
|
paramtype = "light",
|
||||||
|
light_source = 15,
|
||||||
|
drop = '',
|
||||||
|
tiles = {{
|
||||||
|
name = "technic_forcefield_animated.png",
|
||||||
|
animation = {
|
||||||
|
type = "vertical_frames",
|
||||||
|
aspect_w = 16,
|
||||||
|
aspect_h = 16,
|
||||||
|
length = 1.0,
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
if minetest.get_modpath("mesecons_mvps") then
|
if minetest.get_modpath("mesecons_mvps") then
|
||||||
mesecon:register_mvps_stopper("technic:forcefield")
|
mesecon:register_mvps_stopper("technic:forcefield")
|
||||||
end
|
end
|
||||||
-- TODO: Register a stopper for frames
|
|
||||||
|
|
||||||
technic.register_machine("HV", "technic:forcefield_emitter_on", technic.receiver)
|
technic.register_machine("HV", "technic:forcefield_emitter_on", technic.receiver)
|
||||||
technic.register_machine("HV", "technic:forcefield_emitter_off", technic.receiver)
|
technic.register_machine("HV", "technic:forcefield_emitter_off", technic.receiver)
|
||||||
|
@ -48,60 +48,6 @@ local nodebox = {
|
|||||||
{ -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 },
|
{ -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 },
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_node("technic:hv_nuclear_reactor_core", {
|
|
||||||
description = S("Nuclear %s Generator Core"):format("HV"),
|
|
||||||
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
|
||||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
|
||||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
drawtype="nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
stack_max = 1,
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = nodebox
|
|
||||||
},
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("Nuclear %s Generator Core"):format("HV"))
|
|
||||||
meta:set_int("HV_EU_supply", 0)
|
|
||||||
-- Signal to the switching station that this device burns some
|
|
||||||
-- sort of fuel and needs special handling
|
|
||||||
meta:set_int("HV_EU_from_fuel", 1)
|
|
||||||
meta:set_int("burn_time", 0)
|
|
||||||
meta:set_string("formspec", generator_formspec)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("src", 6)
|
|
||||||
end,
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
|
||||||
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
|
||||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
|
||||||
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
drop="technic:hv_nuclear_reactor_core",
|
|
||||||
drawtype="nodebox",
|
|
||||||
light_source = 15,
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = nodebox
|
|
||||||
},
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
})
|
|
||||||
|
|
||||||
local check_reactor_structure = function(pos)
|
local check_reactor_structure = function(pos)
|
||||||
-- The reactor consists of a 9x9x9 cube structure
|
-- The reactor consists of a 9x9x9 cube structure
|
||||||
-- A cross section through the middle:
|
-- A cross section through the middle:
|
||||||
@ -188,11 +134,7 @@ local function damage_nearby_players(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm({
|
local run = function(pos, node)
|
||||||
nodenames = {"technic:hv_nuclear_reactor_core", "technic:hv_nuclear_reactor_core_active"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local machine_name = S("Nuclear %s Generator Core"):format("HV")
|
local machine_name = S("Nuclear %s Generator Core"):format("HV")
|
||||||
local burn_time = meta:get_int("burn_time") or 0
|
local burn_time = meta:get_int("burn_time") or 0
|
||||||
@ -238,7 +180,63 @@ minetest.register_abm({
|
|||||||
meta:set_string("infotext", machine_name.." ("..percent.."%)")
|
meta:set_string("infotext", machine_name.." ("..percent.."%)")
|
||||||
meta:set_int("HV_EU_supply", power_supply)
|
meta:set_int("HV_EU_supply", power_supply)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:hv_nuclear_reactor_core", {
|
||||||
|
description = S("Nuclear %s Generator Core"):format("HV"),
|
||||||
|
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||||
|
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||||
|
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drawtype="nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
stack_max = 1,
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = nodebox
|
||||||
|
},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("Nuclear %s Generator Core"):format("HV"))
|
||||||
|
meta:set_int("HV_EU_supply", 0)
|
||||||
|
-- Signal to the switching station that this device burns some
|
||||||
|
-- sort of fuel and needs special handling
|
||||||
|
meta:set_int("HV_EU_from_fuel", 1)
|
||||||
|
meta:set_int("burn_time", 0)
|
||||||
|
meta:set_string("formspec", generator_formspec)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("src", 6)
|
||||||
|
end,
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
|
||||||
|
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||||
|
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
|
||||||
|
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, not_in_creative_inventory=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drop="technic:hv_nuclear_reactor_core",
|
||||||
|
drawtype="nodebox",
|
||||||
|
light_source = 15,
|
||||||
|
paramtype = "light",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = nodebox
|
||||||
|
},
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
technic_run = run,
|
||||||
|
technic_disabled_machine_name = "technic:hv_nuclear_reactor_core",
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("HV", "technic:hv_nuclear_reactor_core", technic.producer)
|
technic.register_machine("HV", "technic:hv_nuclear_reactor_core", technic.producer)
|
||||||
|
@ -126,37 +126,7 @@ local function send_items(items, pos, node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:quarry", {
|
local run = function(pos, node)
|
||||||
description = S("%s Quarry"):format("HV"),
|
|
||||||
tiles = {"technic_carbon_steel_block.png", "technic_carbon_steel_block.png",
|
|
||||||
"technic_carbon_steel_block.png", "technic_carbon_steel_block.png",
|
|
||||||
"technic_carbon_steel_block.png^default_tool_mesepick.png", "technic_carbon_steel_block.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {cracky=2, tubedevice=1},
|
|
||||||
tube = {
|
|
||||||
connect_sides = {top = 1},
|
|
||||||
},
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("%s Quarry"):format("HV"))
|
|
||||||
meta:set_int("size", 4)
|
|
||||||
set_quarry_formspec(meta)
|
|
||||||
meta:set_int("dig_y", pos.y)
|
|
||||||
end,
|
|
||||||
after_place_node = function(pos, placer, itemstack)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("owner", placer:get_player_name())
|
|
||||||
pipeworks.scan_for_tube_objects(pos)
|
|
||||||
end,
|
|
||||||
after_dig_node = pipeworks.scan_for_tube_objects,
|
|
||||||
on_receive_fields = quarry_receive_fields,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:quarry"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local size = meta:get_int("size")
|
local size = meta:get_int("size")
|
||||||
local eu_input = meta:get_int("HV_EU_input")
|
local eu_input = meta:get_int("HV_EU_input")
|
||||||
@ -165,8 +135,6 @@ minetest.register_abm({
|
|||||||
local dig_y = meta:get_int("dig_y")
|
local dig_y = meta:get_int("dig_y")
|
||||||
local machine_name = S("%s Quarry"):format("HV")
|
local machine_name = S("%s Quarry"):format("HV")
|
||||||
|
|
||||||
technic.switching_station_timeout_count(pos, "HV")
|
|
||||||
|
|
||||||
if meta:get_int("enabled") == 0 then
|
if meta:get_int("enabled") == 0 then
|
||||||
meta:set_string("infotext", S("%s Disabled"):format(machine_name))
|
meta:set_string("infotext", S("%s Disabled"):format(machine_name))
|
||||||
meta:set_int("HV_EU_demand", 0)
|
meta:set_int("HV_EU_demand", 0)
|
||||||
@ -186,7 +154,33 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
meta:set_int("HV_EU_demand", demand)
|
meta:set_int("HV_EU_demand", demand)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:quarry", {
|
||||||
|
description = S("%s Quarry"):format("HV"),
|
||||||
|
tiles = {"technic_carbon_steel_block.png", "technic_carbon_steel_block.png",
|
||||||
|
"technic_carbon_steel_block.png", "technic_carbon_steel_block.png",
|
||||||
|
"technic_carbon_steel_block.png^default_tool_mesepick.png", "technic_carbon_steel_block.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=2, tubedevice=1, technic_machine = 1},
|
||||||
|
tube = {
|
||||||
|
connect_sides = {top = 1},
|
||||||
|
},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("%s Quarry"):format("HV"))
|
||||||
|
meta:set_int("size", 4)
|
||||||
|
set_quarry_formspec(meta)
|
||||||
|
meta:set_int("dig_y", pos.y)
|
||||||
|
end,
|
||||||
|
after_place_node = function(pos, placer, itemstack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
|
pipeworks.scan_for_tube_objects(pos)
|
||||||
|
end,
|
||||||
|
after_dig_node = pipeworks.scan_for_tube_objects,
|
||||||
|
on_receive_fields = quarry_receive_fields,
|
||||||
|
technic_run = run,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("HV", "technic:quarry", technic.receiver)
|
technic.register_machine("HV", "technic:quarry", technic.receiver)
|
||||||
|
@ -125,60 +125,8 @@ local function form_handler(pos, formname, fields, sender)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The actual block inactive state
|
|
||||||
minetest.register_node("technic:cnc", {
|
|
||||||
description = S("%s CNC Machine"):format("LV"),
|
|
||||||
tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
|
||||||
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
groups = {cracky=2},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("%s CNC Machine"):format("LV"))
|
|
||||||
meta:set_float("technic_power_machine", 1)
|
|
||||||
meta:set_string("formspec", cnc_formspec)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("src", 1)
|
|
||||||
inv:set_size("dst", 4)
|
|
||||||
end,
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
on_receive_fields = form_handler,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Active state block
|
|
||||||
minetest.register_node("technic:cnc_active", {
|
|
||||||
description = S("%s CNC Machine"):format("LV"),
|
|
||||||
tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
|
||||||
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drop = "technic:cnc",
|
|
||||||
groups = {cracky=2, not_in_creative_inventory=1},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
on_receive_fields = form_handler,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Action code performing the transformation
|
-- Action code performing the transformation
|
||||||
minetest.register_abm({
|
local run = function(pos, node)
|
||||||
nodenames = {"technic:cnc","technic:cnc_active"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local eu_input = meta:get_int("LV_EU_input")
|
local eu_input = meta:get_int("LV_EU_input")
|
||||||
@ -186,9 +134,6 @@ minetest.register_abm({
|
|||||||
local machine_node = "technic:cnc"
|
local machine_node = "technic:cnc"
|
||||||
local demand = 450
|
local demand = 450
|
||||||
|
|
||||||
-- Power off automatically if no longer connected to a switching station
|
|
||||||
technic.switching_station_timeout_count(pos, "LV")
|
|
||||||
|
|
||||||
local result = meta:get_string("cnc_product")
|
local result = meta:get_string("cnc_product")
|
||||||
if inv:is_empty("src") or
|
if inv:is_empty("src") or
|
||||||
(not minetest.registered_nodes[result]) or
|
(not minetest.registered_nodes[result]) or
|
||||||
@ -216,7 +161,57 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
meta:set_int("LV_EU_demand", demand)
|
meta:set_int("LV_EU_demand", demand)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- The actual block inactive state
|
||||||
|
minetest.register_node("technic:cnc", {
|
||||||
|
description = S("%s CNC Machine"):format("LV"),
|
||||||
|
tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
||||||
|
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
groups = {cracky=2, technic_machine=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("%s CNC Machine"):format("LV"))
|
||||||
|
meta:set_float("technic_power_machine", 1)
|
||||||
|
meta:set_string("formspec", cnc_formspec)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("src", 1)
|
||||||
|
inv:set_size("dst", 4)
|
||||||
|
end,
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
on_receive_fields = form_handler,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Active state block
|
||||||
|
minetest.register_node("technic:cnc_active", {
|
||||||
|
description = S("%s CNC Machine"):format("LV"),
|
||||||
|
tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
|
||||||
|
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drop = "technic:cnc",
|
||||||
|
groups = {cracky=2, technic_machine=1, not_in_creative_inventory=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
on_receive_fields = form_handler,
|
||||||
|
technic_run = run,
|
||||||
|
technic_disabled_machine_name = "technic:cnc",
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:cnc", technic.receiver)
|
technic.register_machine("LV", "technic:cnc", technic.receiver)
|
||||||
|
@ -20,32 +20,6 @@ minetest.register_craftitem("technic:geothermal", {
|
|||||||
description = S("Geothermal %s Generator"):format("LV"),
|
description = S("Geothermal %s Generator"):format("LV"),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:geothermal", {
|
|
||||||
description = S("Geothermal %s Generator"):format("LV"),
|
|
||||||
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
|
||||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("Geothermal %s Generator"):format("LV"))
|
|
||||||
meta:set_int("LV_EU_supply", 0)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:geothermal_active", {
|
|
||||||
description = S("Geothermal %s Generator"):format("LV"),
|
|
||||||
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
|
||||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
drop = "technic:geothermal",
|
|
||||||
})
|
|
||||||
|
|
||||||
local check_node_around = function(pos)
|
local check_node_around = function(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end
|
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end
|
||||||
@ -53,11 +27,7 @@ local check_node_around = function(pos)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm({
|
local run = function(pos, node)
|
||||||
nodenames = {"technic:geothermal","technic:geothermal_active"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local water_nodes = 0
|
local water_nodes = 0
|
||||||
local lava_nodes = 0
|
local lava_nodes = 0
|
||||||
@ -106,7 +76,34 @@ minetest.register_abm({
|
|||||||
technic.swap_node(pos, "technic:geothermal")
|
technic.swap_node(pos, "technic:geothermal")
|
||||||
meta:set_int("LV_EU_supply", 0)
|
meta:set_int("LV_EU_supply", 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:geothermal", {
|
||||||
|
description = S("Geothermal %s Generator"):format("LV"),
|
||||||
|
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
||||||
|
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("Geothermal %s Generator"):format("LV"))
|
||||||
|
meta:set_int("LV_EU_supply", 0)
|
||||||
|
end,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:geothermal_active", {
|
||||||
|
description = S("Geothermal %s Generator"):format("LV"),
|
||||||
|
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
||||||
|
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drop = "technic:geothermal",
|
||||||
|
technic_run = run,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:geothermal", technic.producer)
|
technic.register_machine("LV", "technic:geothermal", technic.producer)
|
||||||
|
@ -36,11 +36,51 @@ local function play_track(pos, track)
|
|||||||
{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
|
{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local run = function(pos, node)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local eu_input = meta:get_int("LV_EU_input")
|
||||||
|
local machine_name = S("%s Music Player"):format("LV")
|
||||||
|
local machine_node = "technic:music_player"
|
||||||
|
local demand = 150
|
||||||
|
|
||||||
|
local current_track = meta:get_int("current_track")
|
||||||
|
local pos_hash = minetest.hash_node_position(pos)
|
||||||
|
local music_handle = music_handles[pos_hash]
|
||||||
|
|
||||||
|
-- Setup meta data if it does not exist.
|
||||||
|
if not eu_input then
|
||||||
|
meta:set_int("LV_EU_demand", demand)
|
||||||
|
meta:set_int("LV_EU_input", 0)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if meta:get_int("active") == 0 then
|
||||||
|
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||||
|
meta:set_int("LV_EU_demand", 0)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if eu_input < demand then
|
||||||
|
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||||
|
if music_handle then
|
||||||
|
minetest.sound_stop(music_handle)
|
||||||
|
music_handle = nil
|
||||||
|
end
|
||||||
|
elseif eu_input >= demand then
|
||||||
|
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||||
|
if not music_handle then
|
||||||
|
music_handle = play_track(pos, current_track)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
music_handles[pos_hash] = music_handle
|
||||||
|
meta:set_int("LV_EU_demand", demand)
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:music_player", {
|
minetest.register_node("technic:music_player", {
|
||||||
description = S("%s Music Player"):format("LV"),
|
description = S("%s Music Player"):format("LV"),
|
||||||
tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png",
|
tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png",
|
||||||
"technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"},
|
"technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -95,54 +135,7 @@ minetest.register_node("technic:music_player", {
|
|||||||
end
|
end
|
||||||
music_handles[pos_hash] = music_handle
|
music_handles[pos_hash] = music_handle
|
||||||
end,
|
end,
|
||||||
})
|
technic_run = run,
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:music_player"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local eu_input = meta:get_int("LV_EU_input")
|
|
||||||
local machine_name = S("%s Music Player"):format("LV")
|
|
||||||
local machine_node = "technic:music_player"
|
|
||||||
local demand = 150
|
|
||||||
|
|
||||||
local current_track = meta:get_int("current_track")
|
|
||||||
local pos_hash = minetest.hash_node_position(pos)
|
|
||||||
local music_handle = music_handles[pos_hash]
|
|
||||||
|
|
||||||
-- Setup meta data if it does not exist.
|
|
||||||
if not eu_input then
|
|
||||||
meta:set_int("LV_EU_demand", demand)
|
|
||||||
meta:set_int("LV_EU_input", 0)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Power off automatically if no longer connected to a switching station
|
|
||||||
technic.switching_station_timeout_count(pos, "LV")
|
|
||||||
|
|
||||||
if meta:get_int("active") == 0 then
|
|
||||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
|
||||||
meta:set_int("LV_EU_demand", 0)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if eu_input < demand then
|
|
||||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
|
||||||
if music_handle then
|
|
||||||
minetest.sound_stop(music_handle)
|
|
||||||
music_handle = nil
|
|
||||||
end
|
|
||||||
elseif eu_input >= demand then
|
|
||||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
|
||||||
if not music_handle then
|
|
||||||
music_handle = play_track(pos, current_track)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
music_handles[pos_hash] = music_handle
|
|
||||||
meta:set_int("LV_EU_demand", demand)
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:music_player", technic.receiver)
|
technic.register_machine("LV", "technic:music_player", technic.receiver)
|
||||||
|
@ -4,49 +4,13 @@
|
|||||||
|
|
||||||
local S = technic.getter
|
local S = technic.getter
|
||||||
|
|
||||||
minetest.register_node("technic:solar_panel", {
|
local run = function(pos, node)
|
||||||
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png",
|
|
||||||
"technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
|
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
description = S("Small Solar %s Generator"):format("LV"),
|
|
||||||
active = false,
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
is_ground_content = true,
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
|
||||||
},
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_int("LV_EU_supply", 0)
|
|
||||||
meta:set_string("infotext", S("Small Solar %s Generator"):format("LV"))
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'technic:solar_panel',
|
|
||||||
recipe = {
|
|
||||||
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'},
|
|
||||||
{'technic:fine_silver_wire', 'technic:lv_cable0', 'mesecons_materials:glue'},
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:solar_panel"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
-- The action here is to make the solar panel prodice power
|
-- The action here is to make the solar panel prodice power
|
||||||
-- Power is dependent on the light level and the height above ground
|
-- Power is dependent on the light level and the height above ground
|
||||||
-- 130m and above is optimal as it would be above cloud level.
|
|
||||||
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 26EU.
|
|
||||||
-- There are many ways to cheat by using other light sources like lamps.
|
-- There are many ways to cheat by using other light sources like lamps.
|
||||||
-- As there is no way to determine if light is sunlight that is just a shame.
|
-- As there is no way to determine if light is sunlight that is just a shame.
|
||||||
-- To take care of some of it solar panels do not work outside daylight hours or if
|
-- To take care of some of it solar panels do not work outside daylight hours or if
|
||||||
-- built below -10m
|
-- built below 0m
|
||||||
local pos1 = {x=pos.x, y=pos.y+1, z=pos.z}
|
local pos1 = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
local machine_name = S("Small Solar %s Generator"):format("LV")
|
local machine_name = S("Small Solar %s Generator"):format("LV")
|
||||||
|
|
||||||
@ -66,7 +30,37 @@ minetest.register_abm({
|
|||||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||||
meta:set_int("LV_EU_supply", 0)
|
meta:set_int("LV_EU_supply", 0)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:solar_panel", {
|
||||||
|
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png",
|
||||||
|
"technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
description = S("Small Solar %s Generator"):format("LV"),
|
||||||
|
active = false,
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
is_ground_content = true,
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||||
|
},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_int("LV_EU_supply", 0)
|
||||||
|
meta:set_string("infotext", S("Small Solar %s Generator"):format("LV"))
|
||||||
end,
|
end,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:solar_panel',
|
||||||
|
recipe = {
|
||||||
|
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'},
|
||||||
|
{'technic:fine_silver_wire', 'technic:lv_cable0', 'mesecons_materials:glue'},
|
||||||
|
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:solar_panel", technic.producer)
|
technic.register_machine("LV", "technic:solar_panel", technic.producer)
|
||||||
|
@ -15,34 +15,6 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("technic:water_mill", {
|
|
||||||
description = S("Hydro %s Generator"):format("LV"),
|
|
||||||
tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png",
|
|
||||||
"technic_water_mill_side.png", "technic_water_mill_side.png",
|
|
||||||
"technic_water_mill_side.png", "technic_water_mill_side.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("Hydro %s Generator"):format("LV"))
|
|
||||||
meta:set_int("LV_EU_supply", 0)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:water_mill_active", {
|
|
||||||
description = S("Hydro %s Generator"):format("LV"),
|
|
||||||
tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png",
|
|
||||||
"technic_water_mill_side.png", "technic_water_mill_side.png",
|
|
||||||
"technic_water_mill_side.png", "technic_water_mill_side.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
drop = "technic:water_mill",
|
|
||||||
})
|
|
||||||
|
|
||||||
local function check_node_around_mill(pos)
|
local function check_node_around_mill(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name == "default:water_flowing" or
|
if node.name == "default:water_flowing" or
|
||||||
@ -52,11 +24,7 @@ local function check_node_around_mill(pos)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm({
|
local run = function(pos, node)
|
||||||
nodenames = {"technic:water_mill", "technic:water_mill_active"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local water_nodes = 0
|
local water_nodes = 0
|
||||||
local lava_nodes = 0
|
local lava_nodes = 0
|
||||||
@ -96,7 +64,37 @@ minetest.register_abm({
|
|||||||
if production_level == 0 then
|
if production_level == 0 then
|
||||||
technic.swap_node(pos, "technic:water_mill")
|
technic.swap_node(pos, "technic:water_mill")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:water_mill", {
|
||||||
|
description = S("Hydro %s Generator"):format("LV"),
|
||||||
|
tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png",
|
||||||
|
"technic_water_mill_side.png", "technic_water_mill_side.png",
|
||||||
|
"technic_water_mill_side.png", "technic_water_mill_side.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("Hydro %s Generator"):format("LV"))
|
||||||
|
meta:set_int("LV_EU_supply", 0)
|
||||||
|
end,
|
||||||
|
technic_run,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:water_mill_active", {
|
||||||
|
description = S("Hydro %s Generator"):format("LV"),
|
||||||
|
tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png",
|
||||||
|
"technic_water_mill_side.png", "technic_water_mill_side.png",
|
||||||
|
"technic_water_mill_side.png", "technic_water_mill_side.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, not_in_creative_inventory=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drop = "technic:water_mill",
|
||||||
|
technic_run,
|
||||||
|
technic_disabled_machine_name = "technic:water_mill",
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:water_mill", technic.producer)
|
technic.register_machine("LV", "technic:water_mill", technic.producer)
|
||||||
|
@ -20,29 +20,7 @@ local workshop_formspec =
|
|||||||
"label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
|
"label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
|
||||||
"list[current_player;main;0,5;8,4;]"
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
|
||||||
minetest.register_node("technic:tool_workshop", {
|
local run = function(pos, node)
|
||||||
description = S("%s Tool Workshop"):format("MV"),
|
|
||||||
tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
|
|
||||||
"technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
|
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("%s Tool Workshop"):format("MV"))
|
|
||||||
meta:set_string("formspec", workshop_formspec)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("src", 1)
|
|
||||||
end,
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:tool_workshop"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local eu_input = meta:get_int("MV_EU_input")
|
local eu_input = meta:get_int("MV_EU_input")
|
||||||
@ -57,9 +35,6 @@ minetest.register_abm({
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Power off automatically if no longer connected to a switching station
|
|
||||||
technic.switching_station_timeout_count(pos, "MV")
|
|
||||||
|
|
||||||
local repairable = false
|
local repairable = false
|
||||||
local srcstack = inv:get_stack("src", 1)
|
local srcstack = inv:get_stack("src", 1)
|
||||||
if not srcstack:is_empty() then
|
if not srcstack:is_empty() then
|
||||||
@ -85,7 +60,25 @@ minetest.register_abm({
|
|||||||
inv:set_stack("src", 1, srcstack)
|
inv:set_stack("src", 1, srcstack)
|
||||||
end
|
end
|
||||||
meta:set_int("MV_EU_demand", demand)
|
meta:set_int("MV_EU_demand", demand)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:tool_workshop", {
|
||||||
|
description = S("%s Tool Workshop"):format("MV"),
|
||||||
|
tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
|
||||||
|
"technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("%s Tool Workshop"):format("MV"))
|
||||||
|
meta:set_string("formspec", workshop_formspec)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("src", 1)
|
||||||
|
end,
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
technic_run = run,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
|
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
|
||||||
|
@ -29,11 +29,40 @@ minetest.register_node("technic:wind_mill_frame", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local function check_wind_mill(pos)
|
||||||
|
if pos.y < 30 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
for i = 1, 20 do
|
||||||
|
local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z})
|
||||||
|
if node.name ~= "technic:wind_mill_frame" then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local run = function(pos, node)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local machine_name = S("Wind %s Generator"):format("MV")
|
||||||
|
local power = math.min(pos.y * 100, 5000)
|
||||||
|
|
||||||
|
if not check_wind_mill(pos) then
|
||||||
|
meta:set_int("MV_EU_supply", 0)
|
||||||
|
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
|
||||||
|
return
|
||||||
|
else
|
||||||
|
meta:set_int("MV_EU_supply", power)
|
||||||
|
end
|
||||||
|
|
||||||
|
meta:set_string("infotext", machine_name.." ("..power.."EU)")
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:wind_mill", {
|
minetest.register_node("technic:wind_mill", {
|
||||||
description = S("Wind %s Generator"):format("MV"),
|
description = S("Wind %s Generator"):format("MV"),
|
||||||
tiles = {"technic_carbon_steel_block.png"},
|
tiles = {"technic_carbon_steel_block.png"},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=1},
|
groups = {cracky=1, technic_machine=1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -51,40 +80,7 @@ minetest.register_node("technic:wind_mill", {
|
|||||||
meta:set_string("infotext", S("Wind %s Generator"):format("MV"))
|
meta:set_string("infotext", S("Wind %s Generator"):format("MV"))
|
||||||
meta:set_int("MV_EU_supply", 0)
|
meta:set_int("MV_EU_supply", 0)
|
||||||
end,
|
end,
|
||||||
})
|
technic_run = run,
|
||||||
|
|
||||||
local function check_wind_mill(pos)
|
|
||||||
if pos.y < 30 then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
for i = 1, 20 do
|
|
||||||
local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z})
|
|
||||||
if node.name ~= "technic:wind_mill_frame" then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:wind_mill"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local machine_name = S("Wind %s Generator"):format("MV")
|
|
||||||
local power = math.min(pos.y * 100, 5000)
|
|
||||||
|
|
||||||
if not check_wind_mill(pos) then
|
|
||||||
meta:set_int("MV_EU_supply", 0)
|
|
||||||
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
|
|
||||||
return
|
|
||||||
else
|
|
||||||
meta:set_int("MV_EU_supply", power)
|
|
||||||
end
|
|
||||||
|
|
||||||
meta:set_string("infotext", machine_name.." ("..power.."EU)")
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine("MV", "technic:wind_mill", technic.producer)
|
technic.register_machine("MV", "technic:wind_mill", technic.producer)
|
||||||
|
@ -80,8 +80,78 @@ function technic.register_battery_box(data)
|
|||||||
"label[3.5,4;"..S("Upgrade Slots").."]"
|
"label[3.5,4;"..S("Upgrade Slots").."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local run = function(pos, node)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local eu_input = meta:get_int(tier.."_EU_input")
|
||||||
|
local current_charge = meta:get_int("internal_EU_charge")
|
||||||
|
|
||||||
|
local EU_upgrade, tube_upgrade = 0, 0
|
||||||
|
if data.upgrade then
|
||||||
|
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||||
|
end
|
||||||
|
local max_charge = data.max_charge * (1 + EU_upgrade / 10)
|
||||||
|
|
||||||
|
-- Charge/discharge the battery with the input EUs
|
||||||
|
if eu_input >= 0 then
|
||||||
|
current_charge = math.min(current_charge + eu_input, max_charge)
|
||||||
|
else
|
||||||
|
current_charge = math.max(current_charge + eu_input, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Charging/discharging tools here
|
||||||
|
local tool_full, tool_empty
|
||||||
|
current_charge, tool_full = technic.charge_tools(meta,
|
||||||
|
current_charge, data.charge_step)
|
||||||
|
current_charge, tool_empty = technic.discharge_tools(meta,
|
||||||
|
current_charge, data.discharge_step,
|
||||||
|
max_charge)
|
||||||
|
|
||||||
|
if data.tube then
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
technic.handle_machine_pipeworks(pos, tube_upgrade,
|
||||||
|
function(pos, x_velocity, z_velocity)
|
||||||
|
if tool_full and not inv:is_empty("src") then
|
||||||
|
technic.send_items(pos, x_velocity, z_velocity, "src")
|
||||||
|
elseif tool_empty and not inv:is_empty("dst") then
|
||||||
|
technic.send_items(pos, x_velocity, z_velocity, "dst")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- We allow batteries to charge on less than the demand
|
||||||
|
meta:set_int(tier.."_EU_demand",
|
||||||
|
math.min(data.charge_rate, max_charge - current_charge))
|
||||||
|
meta:set_int(tier.."_EU_supply",
|
||||||
|
math.min(data.discharge_rate, current_charge))
|
||||||
|
meta:set_int("internal_EU_charge", current_charge)
|
||||||
|
|
||||||
|
-- Select node textures
|
||||||
|
local charge_count = math.ceil((current_charge / max_charge) * 8)
|
||||||
|
charge_count = math.min(charge_count, 8)
|
||||||
|
charge_count = math.max(charge_count, 0)
|
||||||
|
local last_count = meta:get_float("last_side_shown")
|
||||||
|
if charge_count ~= last_count then
|
||||||
|
technic.swap_node(pos,"technic:"..ltier.."_battery_box"..charge_count)
|
||||||
|
meta:set_float("last_side_shown", charge_count)
|
||||||
|
end
|
||||||
|
|
||||||
|
local charge_percent = math.floor(current_charge / max_charge * 100)
|
||||||
|
meta:set_string("formspec",
|
||||||
|
formspec..
|
||||||
|
"image[1,1;1,2;technic_power_meter_bg.png"
|
||||||
|
.."^[lowpart:"..charge_percent
|
||||||
|
..":technic_power_meter_fg.png]")
|
||||||
|
|
||||||
|
local infotext = S("%s Battery Box: %d/%d"):format(tier,
|
||||||
|
current_charge, max_charge)
|
||||||
|
if eu_input == 0 then
|
||||||
|
infotext = S("%s Idle"):format(infotext)
|
||||||
|
end
|
||||||
|
meta:set_string("infotext", infotext)
|
||||||
|
end
|
||||||
|
|
||||||
for i = 0, 8 do
|
for i = 0, 8 do
|
||||||
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
|
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}
|
||||||
if i ~= 0 then
|
if i ~= 0 then
|
||||||
groups.not_in_creative_inventory = 1
|
groups.not_in_creative_inventory = 1
|
||||||
end
|
end
|
||||||
@ -124,93 +194,10 @@ function technic.register_battery_box(data)
|
|||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
technic_run = run,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:"..ltier.."_battery_box0", "technic:"..ltier.."_battery_box1",
|
|
||||||
"technic:"..ltier.."_battery_box2", "technic:"..ltier.."_battery_box3",
|
|
||||||
"technic:"..ltier.."_battery_box4", "technic:"..ltier.."_battery_box5",
|
|
||||||
"technic:"..ltier.."_battery_box6", "technic:"..ltier.."_battery_box7",
|
|
||||||
"technic:"..ltier.."_battery_box8"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local eu_input = meta:get_int(tier.."_EU_input")
|
|
||||||
local current_charge = meta:get_int("internal_EU_charge")
|
|
||||||
|
|
||||||
-- Power off automatically if no longer connected to a switching station
|
|
||||||
technic.switching_station_timeout_count(pos, tier)
|
|
||||||
|
|
||||||
local EU_upgrade, tube_upgrade = 0, 0
|
|
||||||
if data.upgrade then
|
|
||||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
|
||||||
end
|
|
||||||
local max_charge = data.max_charge * (1 + EU_upgrade / 10)
|
|
||||||
|
|
||||||
-- Charge/discharge the battery with the input EUs
|
|
||||||
if eu_input >= 0 then
|
|
||||||
current_charge = math.min(current_charge + eu_input, max_charge)
|
|
||||||
else
|
|
||||||
current_charge = math.max(current_charge + eu_input, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Charging/discharging tools here
|
|
||||||
local tool_full, tool_empty
|
|
||||||
current_charge, tool_full = technic.charge_tools(meta,
|
|
||||||
current_charge, data.charge_step)
|
|
||||||
current_charge, tool_empty = technic.discharge_tools(meta,
|
|
||||||
current_charge, data.discharge_step,
|
|
||||||
max_charge)
|
|
||||||
|
|
||||||
if data.tube then
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
technic.handle_machine_pipeworks(pos, tube_upgrade,
|
|
||||||
function(pos, x_velocity, z_velocity)
|
|
||||||
if tool_full and not inv:is_empty("src") then
|
|
||||||
technic.send_items(pos, x_velocity, z_velocity, "src")
|
|
||||||
elseif tool_empty and not inv:is_empty("dst") then
|
|
||||||
technic.send_items(pos, x_velocity, z_velocity, "dst")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- We allow batteries to charge on less than the demand
|
|
||||||
meta:set_int(tier.."_EU_demand",
|
|
||||||
math.min(data.charge_rate, max_charge - current_charge))
|
|
||||||
meta:set_int(tier.."_EU_supply",
|
|
||||||
math.min(data.discharge_rate, current_charge))
|
|
||||||
|
|
||||||
meta:set_int("internal_EU_charge", current_charge)
|
|
||||||
|
|
||||||
-- Select node textures
|
|
||||||
local charge_count = math.ceil((current_charge / max_charge) * 8)
|
|
||||||
charge_count = math.min(charge_count, 8)
|
|
||||||
charge_count = math.max(charge_count, 0)
|
|
||||||
local last_count = meta:get_float("last_side_shown")
|
|
||||||
if charge_count ~= last_count then
|
|
||||||
technic.swap_node(pos,"technic:"..ltier.."_battery_box"..charge_count)
|
|
||||||
meta:set_float("last_side_shown", charge_count)
|
|
||||||
end
|
|
||||||
|
|
||||||
local charge_percent = math.floor(current_charge / max_charge * 100)
|
|
||||||
meta:set_string("formspec",
|
|
||||||
formspec..
|
|
||||||
"image[1,1;1,2;technic_power_meter_bg.png"
|
|
||||||
.."^[lowpart:"..charge_percent
|
|
||||||
..":technic_power_meter_fg.png]")
|
|
||||||
|
|
||||||
local infotext = S("%s Battery Box: %d/%d"):format(tier,
|
|
||||||
current_charge, max_charge)
|
|
||||||
if eu_input == 0 then
|
|
||||||
infotext = S("%s Idle"):format(infotext)
|
|
||||||
end
|
|
||||||
meta:set_string("infotext", infotext)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Register as a battery type
|
-- Register as a battery type
|
||||||
-- Battery type machines function as power reservoirs and can both receive and give back power
|
-- Battery type machines function as power reservoirs and can both receive and give back power
|
||||||
for i = 0, 8 do
|
for i = 0, 8 do
|
||||||
|
@ -59,7 +59,6 @@ function technic.register_cable(tier, size)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_placenode(function(pos, node)
|
minetest.register_on_placenode(function(pos, node)
|
||||||
for tier, machine_list in pairs(technic.machines) do
|
for tier, machine_list in pairs(technic.machines) do
|
||||||
if machine_list[node.name] ~= nil then
|
if machine_list[node.name] ~= nil then
|
||||||
@ -79,7 +78,6 @@ minetest.register_on_dignode(function(pos, node)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
function technic.get_cable_id(links)
|
function technic.get_cable_id(links)
|
||||||
return (links[6] * 1) + (links[5] * 2)
|
return (links[6] * 1) + (links[5] * 2)
|
||||||
+ (links[4] * 4) + (links[3] * 8)
|
+ (links[4] * 4) + (links[3] * 8)
|
||||||
|
@ -18,8 +18,8 @@ function technic.register_generator(data)
|
|||||||
local tier = data.tier
|
local tier = data.tier
|
||||||
local ltier = string.lower(tier)
|
local ltier = string.lower(tier)
|
||||||
|
|
||||||
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
|
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}
|
||||||
local active_groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}
|
local active_groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, not_in_creative_inventory=1}
|
||||||
if data.tube then
|
if data.tube then
|
||||||
groups.tubedevice = 1
|
groups.tubedevice = 1
|
||||||
groups.tubedevice_receiver = 1
|
groups.tubedevice_receiver = 1
|
||||||
@ -35,53 +35,8 @@ function technic.register_generator(data)
|
|||||||
"list[current_player;main;0,5;8,4;]"
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
|
||||||
local desc = S("Fuel-Fired %s Generator"):format(tier)
|
local desc = S("Fuel-Fired %s Generator"):format(tier)
|
||||||
minetest.register_node("technic:"..ltier.."_generator", {
|
|
||||||
description = desc,
|
|
||||||
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
|
||||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
|
||||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = groups,
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
tube = data.tube and tube or nil,
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", desc)
|
|
||||||
meta:set_int(data.tier.."_EU_supply", 0)
|
|
||||||
meta:set_int("burn_time", 0)
|
|
||||||
meta:set_int("tube_time", 0)
|
|
||||||
meta:set_string("formspec", generator_formspec)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("src", 1)
|
|
||||||
end,
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_generator_active", {
|
local run = function(pos, node)
|
||||||
description = desc,
|
|
||||||
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
|
||||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
|
||||||
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = active_groups,
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
tube = data.tube and tube or nil,
|
|
||||||
drop = "technic:"..ltier.."_generator",
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
})
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:"..ltier.."_generator", "technic:"..ltier.."_generator_active"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local burn_time = meta:get_int("burn_time")
|
local burn_time = meta:get_int("burn_time")
|
||||||
local burn_totaltime = meta:get_int("burn_totaltime")
|
local burn_totaltime = meta:get_int("burn_totaltime")
|
||||||
@ -127,7 +82,53 @@ function technic.register_generator(data)
|
|||||||
(percent)..":default_furnace_fire_fg.png]"..
|
(percent)..":default_furnace_fire_fg.png]"..
|
||||||
"list[current_player;main;0, 5;8, 4;]")
|
"list[current_player;main;0, 5;8, 4;]")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:"..ltier.."_generator", {
|
||||||
|
description = desc,
|
||||||
|
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = groups,
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
tube = data.tube and tube or nil,
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", desc)
|
||||||
|
meta:set_int(data.tier.."_EU_supply", 0)
|
||||||
|
meta:set_int("burn_time", 0)
|
||||||
|
meta:set_int("tube_time", 0)
|
||||||
|
meta:set_string("formspec", generator_formspec)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("src", 1)
|
||||||
|
end,
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
technic_run = run,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:"..ltier.."_generator_active", {
|
||||||
|
description = desc,
|
||||||
|
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = active_groups,
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
tube = data.tube and tube or nil,
|
||||||
|
drop = "technic:"..ltier.."_generator",
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
technic_run = run,
|
||||||
|
technic_disabled_machine_name = "technic:"..ltier.."_generator",
|
||||||
|
})
|
||||||
|
|
||||||
technic.register_machine(tier, "technic:"..ltier.."_generator", technic.producer)
|
technic.register_machine(tier, "technic:"..ltier.."_generator", technic.producer)
|
||||||
technic.register_machine(tier, "technic:"..ltier.."_generator_active", technic.producer)
|
technic.register_machine(tier, "technic:"..ltier.."_generator_active", technic.producer)
|
||||||
end
|
end
|
||||||
|
@ -23,8 +23,8 @@ function technic.register_base_machine(data)
|
|||||||
local tier = data.tier
|
local tier = data.tier
|
||||||
local ltier = string.lower(tier)
|
local ltier = string.lower(tier)
|
||||||
|
|
||||||
local groups = {cracky = 2}
|
local groups = {cracky = 2, technic_machine = 1}
|
||||||
local active_groups = {cracky = 2, not_in_creative_inventory = 1}
|
local active_groups = {cracky = 2, technic_machine = 1, not_in_creative_inventory = 1}
|
||||||
if data.tube then
|
if data.tube then
|
||||||
groups.tubedevice = 1
|
groups.tubedevice = 1
|
||||||
groups.tubedevice_receiver = 1
|
groups.tubedevice_receiver = 1
|
||||||
@ -46,63 +46,7 @@ function technic.register_base_machine(data)
|
|||||||
"label[1,4;"..S("Upgrade Slots").."]"
|
"label[1,4;"..S("Upgrade Slots").."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_"..machine_name, {
|
local run = function(pos, node)
|
||||||
description = machine_desc:format(tier),
|
|
||||||
tiles = {"technic_"..ltier.."_"..machine_name.."_top.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_bottom.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_front.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = groups,
|
|
||||||
tube = data.tube and tube or nil,
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
on_construct = function(pos)
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", machine_desc:format(tier))
|
|
||||||
meta:set_int("tube_time", 0)
|
|
||||||
meta:set_string("formspec", formspec)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("src", numitems)
|
|
||||||
inv:set_size("dst", 4)
|
|
||||||
inv:set_size("upgrade1", 1)
|
|
||||||
inv:set_size("upgrade2", 1)
|
|
||||||
end,
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{
|
|
||||||
description = machine_desc:format(tier),
|
|
||||||
tiles = {"technic_"..ltier.."_"..machine_name.."_top.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_bottom.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_side.png",
|
|
||||||
"technic_"..ltier.."_"..machine_name.."_front_active.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
drop = "technic:"..ltier.."_"..machine_name,
|
|
||||||
groups = active_groups,
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
tube = data.tube and tube or nil,
|
|
||||||
can_dig = technic.machine_can_dig,
|
|
||||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
||||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
||||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:"..ltier.."_"..machine_name,
|
|
||||||
"technic:"..ltier.."_"..machine_name.."_active"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local eu_input = meta:get_int(tier.."_EU_input")
|
local eu_input = meta:get_int(tier.."_EU_input")
|
||||||
@ -118,9 +62,6 @@ function technic.register_base_machine(data)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Power off automatically if no longer connected to a switching station
|
|
||||||
technic.switching_station_timeout_count(pos, tier)
|
|
||||||
|
|
||||||
local EU_upgrade, tube_upgrade = 0, 0
|
local EU_upgrade, tube_upgrade = 0, 0
|
||||||
if data.upgrade then
|
if data.upgrade then
|
||||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||||
@ -159,6 +100,59 @@ function technic.register_base_machine(data)
|
|||||||
end
|
end
|
||||||
meta:set_int(tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
meta:set_int(tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:"..ltier.."_"..machine_name, {
|
||||||
|
description = machine_desc:format(tier),
|
||||||
|
tiles = {"technic_"..ltier.."_"..machine_name.."_top.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_bottom.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_side.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_side.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_side.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_front.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = groups,
|
||||||
|
tube = data.tube and tube or nil,
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
on_construct = function(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", machine_desc:format(tier))
|
||||||
|
meta:set_int("tube_time", 0)
|
||||||
|
meta:set_string("formspec", formspec)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("src", numitems)
|
||||||
|
inv:set_size("dst", 4)
|
||||||
|
inv:set_size("upgrade1", 1)
|
||||||
|
inv:set_size("upgrade2", 1)
|
||||||
|
end,
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:"..ltier.."_"..machine_name.."_active",{
|
||||||
|
description = machine_desc:format(tier),
|
||||||
|
tiles = {"technic_"..ltier.."_"..machine_name.."_top.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_bottom.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_side.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_side.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_side.png",
|
||||||
|
"technic_"..ltier.."_"..machine_name.."_front_active.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drop = "technic:"..ltier.."_"..machine_name,
|
||||||
|
groups = active_groups,
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
tube = data.tube and tube or nil,
|
||||||
|
can_dig = technic.machine_can_dig,
|
||||||
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||||
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||||
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||||
|
technic_run = run,
|
||||||
|
technic_disabled_machine_name = "technic:"..ltier.."_"..machine_name,
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine(tier, "technic:"..ltier.."_"..machine_name, technic.receiver)
|
technic.register_machine(tier, "technic:"..ltier.."_"..machine_name, technic.receiver)
|
||||||
|
@ -5,11 +5,42 @@ function technic.register_solar_array(data)
|
|||||||
local tier = data.tier
|
local tier = data.tier
|
||||||
local ltier = string.lower(tier)
|
local ltier = string.lower(tier)
|
||||||
|
|
||||||
|
local run = function(pos, node)
|
||||||
|
-- The action here is to make the solar array produce power
|
||||||
|
-- Power is dependent on the light level and the height above ground
|
||||||
|
-- There are many ways to cheat by using other light sources like lamps.
|
||||||
|
-- As there is no way to determine if light is sunlight that is just a shame.
|
||||||
|
-- To take care of some of it solar panels do not work outside daylight hours or if
|
||||||
|
-- built below 0m
|
||||||
|
local pos1 = {}
|
||||||
|
local machine_name = S("Arrayed Solar %s Generator"):format(tier)
|
||||||
|
pos1.y = pos.y + 1
|
||||||
|
pos1.x = pos.x
|
||||||
|
pos1.z = pos.z
|
||||||
|
local light = minetest.get_node_light(pos1, nil)
|
||||||
|
local time_of_day = minetest.get_timeofday()
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
light = light or 0
|
||||||
|
|
||||||
|
-- turn on array only during day time and if sufficient light
|
||||||
|
-- I know this is counter intuitive when cheating by using other light sources.
|
||||||
|
if light >= 12 and time_of_day >= 0.24 and time_of_day <= 0.76 and pos.y > 0 then
|
||||||
|
local charge_to_give = math.floor((light + pos.y) * data.power)
|
||||||
|
charge_to_give = math.max(charge_to_give, 0)
|
||||||
|
charge_to_give = math.min(charge_to_give, data.power * 50)
|
||||||
|
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..charge_to_give.."EU)")
|
||||||
|
meta:set_int(tier.."_EU_supply", charge_to_give)
|
||||||
|
else
|
||||||
|
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||||
|
meta:set_int(tier.."_EU_supply", 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:solar_array_"..ltier, {
|
minetest.register_node("technic:solar_array_"..ltier, {
|
||||||
tiles = {"technic_"..ltier.."_solar_array_top.png", "technic_"..ltier.."_solar_array_bottom.png",
|
tiles = {"technic_"..ltier.."_solar_array_top.png", "technic_"..ltier.."_solar_array_bottom.png",
|
||||||
"technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png",
|
"technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png",
|
||||||
"technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png"},
|
"technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png"},
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
description = S("Arrayed Solar %s Generator"):format(tier),
|
description = S("Arrayed Solar %s Generator"):format(tier),
|
||||||
active = false,
|
active = false,
|
||||||
@ -24,45 +55,7 @@ function technic.register_solar_array(data)
|
|||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
meta:set_int(tier.."_EU_supply", 0)
|
meta:set_int(tier.."_EU_supply", 0)
|
||||||
end,
|
end,
|
||||||
})
|
technic_run = run,
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:solar_array_"..ltier},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
-- The action here is to make the solar array produce power
|
|
||||||
-- Power is dependent on the light level and the height above ground
|
|
||||||
-- 130m and above is optimal as it would be above cloud level.
|
|
||||||
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 2880EU for the array.
|
|
||||||
-- There are many ways to cheat by using other light sources like lamps.
|
|
||||||
-- As there is no way to determine if light is sunlight that is just a shame.
|
|
||||||
-- To take care of some of it solar panels do not work outside daylight hours or if
|
|
||||||
-- built below -10m
|
|
||||||
local pos1 = {}
|
|
||||||
local machine_name = S("Arrayed Solar %s Generator"):format(tier)
|
|
||||||
pos1.y = pos.y + 1
|
|
||||||
pos1.x = pos.x
|
|
||||||
pos1.z = pos.z
|
|
||||||
local light = minetest.get_node_light(pos1, nil)
|
|
||||||
local time_of_day = minetest.get_timeofday()
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
light = light or 0
|
|
||||||
|
|
||||||
|
|
||||||
-- turn on array only during day time and if sufficient light
|
|
||||||
-- I know this is counter intuitive when cheating by using other light sources.
|
|
||||||
if light >= 12 and time_of_day >= 0.24 and time_of_day <= 0.76 and pos.y > 0 then
|
|
||||||
local charge_to_give = math.floor((light + pos.y) * data.power)
|
|
||||||
charge_to_give = math.max(charge_to_give, 0)
|
|
||||||
charge_to_give = math.min(charge_to_give, data.power * 50)
|
|
||||||
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..charge_to_give.."EU)")
|
|
||||||
meta:set_int(tier.."_EU_supply", charge_to_give)
|
|
||||||
else
|
|
||||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
|
||||||
meta:set_int(tier.."_EU_supply", 0)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
technic.register_machine(tier, "technic:solar_array_"..ltier, technic.producer)
|
technic.register_machine(tier, "technic:solar_array_"..ltier, technic.producer)
|
||||||
|
@ -9,40 +9,7 @@
|
|||||||
|
|
||||||
local S = technic.getter
|
local S = technic.getter
|
||||||
|
|
||||||
minetest.register_node("technic:supply_converter", {
|
local run = function(pos, node)
|
||||||
description = S("Supply Converter"),
|
|
||||||
tiles = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png",
|
|
||||||
"technic_supply_converter_side.png", "technic_supply_converter_side.png",
|
|
||||||
"technic_supply_converter_side.png", "technic_supply_converter_side.png"},
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
drawtype = "nodebox",
|
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
|
||||||
},
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.env:get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("Supply Converter"))
|
|
||||||
meta:set_float("active", false)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'technic:supply_converter 1',
|
|
||||||
recipe = {
|
|
||||||
{'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'},
|
|
||||||
{'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'},
|
|
||||||
{'technic:mv_cable0', 'technic:rubber', 'technic:lv_cable0'},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:supply_converter"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local demand = 10000
|
local demand = 10000
|
||||||
local remain = 0.9
|
local remain = 0.9
|
||||||
-- Machine information
|
-- Machine information
|
||||||
@ -72,7 +39,36 @@ minetest.register_abm({
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:supply_converter", {
|
||||||
|
description = S("Supply Converter"),
|
||||||
|
tiles = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png",
|
||||||
|
"technic_supply_converter_side.png", "technic_supply_converter_side.png",
|
||||||
|
"technic_supply_converter_side.png", "technic_supply_converter_side.png"},
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||||
|
},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("Supply Converter"))
|
||||||
|
meta:set_float("active", false)
|
||||||
end,
|
end,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:supply_converter 1',
|
||||||
|
recipe = {
|
||||||
|
{'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'},
|
||||||
|
{'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'},
|
||||||
|
{'technic:mv_cable0', 'technic:rubber', 'technic:lv_cable0'},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
for tier, machines in pairs(technic.machines) do
|
for tier, machines in pairs(technic.machines) do
|
||||||
|
@ -57,24 +57,10 @@ minetest.register_node("technic:switching_station",{
|
|||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", S("Switching Station"))
|
meta:set_string("infotext", S("Switching Station"))
|
||||||
|
meta:set_string("active", 1)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
--------------------------------------------------
|
|
||||||
-- Functions to help the machines on the electrical network
|
|
||||||
--------------------------------------------------
|
|
||||||
-- This one provides a timeout for a node in case it was disconnected from the network
|
|
||||||
-- A node must be touched by the station continuously in order to function
|
|
||||||
function technic.switching_station_timeout_count(pos, tier)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local timeout = meta:get_int(tier.."_EU_timeout")
|
|
||||||
if timeout == 0 then
|
|
||||||
meta:set_int(tier.."_EU_input", 0)
|
|
||||||
else
|
|
||||||
meta:set_int(tier.."_EU_timeout", timeout - 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
-- Functions to traverse the electrical network
|
-- Functions to traverse the electrical network
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
@ -93,8 +79,14 @@ local add_new_cable_node = function(nodes, pos)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local load_position = function(pos)
|
||||||
|
local vm = VoxelManip()
|
||||||
|
local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
|
||||||
|
end
|
||||||
|
|
||||||
-- Generic function to add found connected nodes to the right classification array
|
-- Generic function to add found connected nodes to the right classification array
|
||||||
local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, all_nodes, pos, machines, tier)
|
local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, pos, machines, tier, sw_pos)
|
||||||
|
load_position(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
|
|
||||||
@ -109,6 +101,12 @@ local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, all_nodes, pos, m
|
|||||||
elseif machines[name] == technic.producer_receiver then
|
elseif machines[name] == technic.producer_receiver then
|
||||||
add_new_cable_node(PR_nodes, pos)
|
add_new_cable_node(PR_nodes, pos)
|
||||||
add_new_cable_node(RE_nodes, pos)
|
add_new_cable_node(RE_nodes, pos)
|
||||||
|
elseif machines[name] == "SPECIAL" and
|
||||||
|
(pos.x ~= sw_pos.x or pos.y ~= sw_pos.y or pos.z ~= sw_pos.z) then
|
||||||
|
-- Another switching station -> disable it
|
||||||
|
add_new_cable_node(SP_nodes, pos)
|
||||||
|
meta:set_int("active", 0)
|
||||||
|
meta:set_string("active_pos", minetest.serialize(sw_pos))
|
||||||
elseif machines[name] == technic.battery then
|
elseif machines[name] == technic.battery then
|
||||||
add_new_cable_node(BA_nodes, pos)
|
add_new_cable_node(BA_nodes, pos)
|
||||||
end
|
end
|
||||||
@ -118,7 +116,7 @@ local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, all_nodes, pos, m
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Traverse a network given a list of machines and a cable type name
|
-- Traverse a network given a list of machines and a cable type name
|
||||||
local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, all_nodes, i, machines, tier)
|
local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, i, machines, tier, sw_pos)
|
||||||
local pos = all_nodes[i]
|
local pos = all_nodes[i]
|
||||||
local positions = {
|
local positions = {
|
||||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||||
@ -129,7 +127,7 @@ local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, all_nodes, i, ma
|
|||||||
{x=pos.x, y=pos.y, z=pos.z-1}}
|
{x=pos.x, y=pos.y, z=pos.z-1}}
|
||||||
--print("ON")
|
--print("ON")
|
||||||
for i, cur_pos in pairs(positions) do
|
for i, cur_pos in pairs(positions) do
|
||||||
check_node_subp(PR_nodes, RE_nodes, BA_nodes, all_nodes, cur_pos, machines, tier)
|
check_node_subp(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, cur_pos, machines, tier, sw_pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -140,25 +138,32 @@ local touch_nodes = function(list, tier)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local get_network = function(pos1, tier)
|
local get_network = function(sw_pos, pos1, tier)
|
||||||
local cached = technic.networks[minetest.hash_node_position(pos1)]
|
local cached = technic.networks[minetest.hash_node_position(pos1)]
|
||||||
if cached and cached.tier == tier then
|
if cached and cached.tier == tier then
|
||||||
touch_nodes(cached.PR_nodes, tier)
|
touch_nodes(cached.PR_nodes, tier)
|
||||||
touch_nodes(cached.BA_nodes, tier)
|
touch_nodes(cached.BA_nodes, tier)
|
||||||
touch_nodes(cached.RE_nodes, tier)
|
touch_nodes(cached.RE_nodes, tier)
|
||||||
|
for _, pos in ipairs(cached.SP_nodes) do
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_int("active", 0)
|
||||||
|
meta:set_string("active_pos", minetest.serialize(sw_pos))
|
||||||
|
end
|
||||||
return cached.PR_nodes, cached.BA_nodes, cached.RE_nodes
|
return cached.PR_nodes, cached.BA_nodes, cached.RE_nodes
|
||||||
end
|
end
|
||||||
local i = 1
|
local i = 1
|
||||||
local PR_nodes = {}
|
local PR_nodes = {}
|
||||||
local BA_nodes = {}
|
local BA_nodes = {}
|
||||||
local RE_nodes = {}
|
local RE_nodes = {}
|
||||||
|
local SP_nodes = {}
|
||||||
local all_nodes = {pos1}
|
local all_nodes = {pos1}
|
||||||
repeat
|
repeat
|
||||||
traverse_network(PR_nodes, RE_nodes, BA_nodes, all_nodes,
|
traverse_network(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes,
|
||||||
i, technic.machines[tier], tier)
|
i, technic.machines[tier], tier, sw_pos)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
until all_nodes[i] == nil
|
until all_nodes[i] == nil
|
||||||
technic.networks[minetest.hash_node_position(pos1)] = {tier = tier, PR_nodes = PR_nodes, RE_nodes = RE_nodes, BA_nodes = BA_nodes}
|
technic.networks[minetest.hash_node_position(pos1)] = {tier = tier, PR_nodes = PR_nodes,
|
||||||
|
RE_nodes = RE_nodes, BA_nodes = BA_nodes, SP_nodes = SP_nodes}
|
||||||
return PR_nodes, BA_nodes, RE_nodes
|
return PR_nodes, BA_nodes, RE_nodes
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -184,22 +189,47 @@ minetest.register_abm({
|
|||||||
local RE_nodes
|
local RE_nodes
|
||||||
local machine_name = S("Switching Station")
|
local machine_name = S("Switching Station")
|
||||||
|
|
||||||
|
if meta:get_int("active") ~= 1 then
|
||||||
|
meta:set_int("active", 1)
|
||||||
|
local active_pos = minetest.deserialize(meta:get_string("active_pos"))
|
||||||
|
if active_pos then
|
||||||
|
local meta1 = minetest.get_meta(active_pos)
|
||||||
|
meta:set_string("infotext", S("%s (Slave)"):format(meta1:get_string("infotext")))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Which kind of network are we on:
|
-- Which kind of network are we on:
|
||||||
pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
|
pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
|
|
||||||
local name = minetest.get_node(pos1).name
|
local name = minetest.get_node(pos1).name
|
||||||
local tier = technic.get_cable_tier(name)
|
local tier = technic.get_cable_tier(name)
|
||||||
if tier then
|
if tier then
|
||||||
PR_nodes, BA_nodes, RE_nodes = get_network(pos1, tier)
|
PR_nodes, BA_nodes, RE_nodes = get_network(pos, pos1, tier)
|
||||||
else
|
else
|
||||||
--dprint("Not connected to a network")
|
--dprint("Not connected to a network")
|
||||||
meta:set_string("infotext", S("%s Has No Network"):format(machine_name))
|
meta:set_string("infotext", S("%s Has No Network"):format(machine_name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
--dprint("nodes="..table.getn(all_nodes)
|
|
||||||
-- .." PR="..table.getn(PR_nodes)
|
-- Run all the nodes
|
||||||
-- .." BA="..table.getn(BA_nodes)
|
local function run_nodes(list)
|
||||||
-- .." RE="..table.getn(RE_nodes))
|
for _, pos2 in ipairs(list) do
|
||||||
|
load_position(pos2)
|
||||||
|
local node2 = minetest.get_node(pos2)
|
||||||
|
local nodedef
|
||||||
|
if node2 and node2.name then
|
||||||
|
nodedef = minetest.registered_nodes[node2.name]
|
||||||
|
end
|
||||||
|
if nodedef and nodedef.technic_run then
|
||||||
|
nodedef.technic_run(pos2, node2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
run_nodes(PR_nodes)
|
||||||
|
run_nodes(RE_nodes)
|
||||||
|
run_nodes(BA_nodes)
|
||||||
|
|
||||||
-- Strings for the meta data
|
-- Strings for the meta data
|
||||||
local eu_demand_str = tier.."_EU_demand"
|
local eu_demand_str = tier.."_EU_demand"
|
||||||
@ -306,6 +336,42 @@ minetest.register_abm({
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Timeout ABM
|
||||||
|
-- Timeout for a node in case it was disconnected from the network
|
||||||
|
-- A node must be touched by the station continuously in order to function
|
||||||
|
local function switching_station_timeout_count(pos, tier)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local timeout = meta:get_int(tier.."_EU_timeout")
|
||||||
|
if timeout <= 0 then
|
||||||
|
--meta:set_int(tier.."_EU_input", 0) -- Not needed anymore
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
meta:set_int(tier.."_EU_timeout", timeout - 1)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"group:technic_machine"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
for tier, machines in pairs(technic.machines) do
|
||||||
|
if machines[node.name] and switching_station_timeout_count(pos, tier) then
|
||||||
|
local nodedef = minetest.registered_nodes[node.name]
|
||||||
|
if nodedef and nodedef.technic_disabled_machine_name then
|
||||||
|
print(nodedef.technic_disabled_machine_name)
|
||||||
|
node.name = nodedef.technic_disabled_machine_name
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
if nodedef then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("%s Has No Network"):format(nodedef.description))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
for tier, machines in pairs(technic.machines) do
|
for tier, machines in pairs(technic.machines) do
|
||||||
-- SPECIAL will not be traversed
|
-- SPECIAL will not be traversed
|
||||||
technic.register_machine(tier, "technic:switching_station", "SPECIAL")
|
technic.register_machine(tier, "technic:switching_station", "SPECIAL")
|
||||||
|
Loading…
Reference in New Issue
Block a user