update mesecons, pipeworks, castle, and technic
parent
02c000610d
commit
d7a62ee312
|
@ -4,3 +4,4 @@ It can also receive digiline signals. You can either send "GET" and it will
|
|||
respond with the detected nodename or you can send any other string and it will
|
||||
set this string as the node to scan for.
|
||||
Nodenames must include the mod they reside in, so for instance default:dirt, not just dirt.
|
||||
The distance parameter specifies how many blocks are between the node detector and the node to detect.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
The object detector is a receptor. It changes its state when a player approaches.
|
||||
Right-click it to set a name to scan for.
|
||||
You can also search for comma-separated lists of players where the detector gets activated if any of the names in the list are found.
|
||||
It can also receive digiline signals which are the name to scan for on the specified channel in the right-click menu.
|
||||
|
|
|
@ -5,15 +5,18 @@ local GET_COMMAND = "GET"
|
|||
-- The radius can be specified in mesecons/settings.lua
|
||||
|
||||
local function object_detector_make_formspec(pos)
|
||||
minetest.get_meta(pos):set_string("formspec", "size[9,2.5]" ..
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", "size[9,2.5]" ..
|
||||
"field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]"..
|
||||
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
||||
"button_exit[7,0.75;2,3;;Save]")
|
||||
end
|
||||
|
||||
local function object_detector_on_receive_fields(pos, _, fields)
|
||||
local function object_detector_on_receive_fields(pos, formname, fields, sender)
|
||||
if not fields.scanname or not fields.digiline_channel then return end
|
||||
|
||||
if minetest.is_protected(pos, sender:get_player_name()) then return end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("scanname", fields.scanname)
|
||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||
|
@ -28,14 +31,17 @@ local function object_detector_scan(pos)
|
|||
if next(objs) == nil then return false end
|
||||
|
||||
local scanname = minetest.get_meta(pos):get_string("scanname")
|
||||
local scan_for = {}
|
||||
for _, str in pairs(string.split(scanname:gsub(" ", ""), ",")) do
|
||||
scan_for[str] = true
|
||||
end
|
||||
|
||||
local every_player = scanname == ""
|
||||
for _, obj in pairs(objs) do
|
||||
-- "" is returned if it is not a player; "" ~= nil; so only handle objects with foundname ~= ""
|
||||
local foundname = obj:get_player_name()
|
||||
|
||||
if foundname ~= "" then
|
||||
-- return true if scanning for any player or if specific playername was detected
|
||||
if scanname == "" or foundname == scanname then
|
||||
if every_player or scan_for[foundname] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -128,17 +134,23 @@ minetest.register_abm({
|
|||
-- Detects the node in front of it
|
||||
|
||||
local function node_detector_make_formspec(pos)
|
||||
minetest.get_meta(pos):set_string("formspec", "size[9,2.5]" ..
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("distance") == "" then meta:set_string("distance", "0") end
|
||||
meta:set_string("formspec", "size[9,2.5]" ..
|
||||
"field[0.3, 0;9,2;scanname;Name of node to scan for (empty for any):;${scanname}]"..
|
||||
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
||||
"field[0.3,1.5;2.5,2;distance;Distance (0-"..mesecon.setting("node_detector_distance_max", 10).."):;${distance}]"..
|
||||
"field[3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
||||
"button_exit[7,0.75;2,3;;Save]")
|
||||
end
|
||||
|
||||
local function node_detector_on_receive_fields(pos, _, fields)
|
||||
local function node_detector_on_receive_fields(pos, fieldname, fields, sender)
|
||||
if not fields.scanname or not fields.digiline_channel then return end
|
||||
|
||||
if minetest.is_protected(pos, sender:get_player_name()) then return end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("scanname", fields.scanname)
|
||||
meta:set_string("distance", fields.distance or "0")
|
||||
meta:set_string("digiline_channel", fields.digiline_channel)
|
||||
node_detector_make_formspec(pos)
|
||||
end
|
||||
|
@ -148,10 +160,17 @@ local function node_detector_scan(pos)
|
|||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node then return end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local distance = meta:get_int("distance")
|
||||
local distance_max = mesecon.setting("node_detector_distance_max", 10)
|
||||
if distance < 0 then distance = 0 end
|
||||
if distance > distance_max then distance = distance_max end
|
||||
|
||||
local frontname = minetest.get_node(
|
||||
vector.subtract(pos, minetest.facedir_to_dir(node.param2))
|
||||
vector.subtract(pos, vector.multiply(minetest.facedir_to_dir(node.param2), distance + 1))
|
||||
).name
|
||||
local scanname = minetest.get_meta(pos):get_string("scanname")
|
||||
local scanname = meta:get_string("scanname")
|
||||
|
||||
return (frontname == scanname) or
|
||||
(frontname ~= "air" and frontname ~= "ignore" and scanname == "")
|
||||
|
@ -162,11 +181,17 @@ local node_detector_digiline = {
|
|||
effector = {
|
||||
action = function(pos, node, channel, msg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local distance = meta:get_int("distance")
|
||||
local distance_max = mesecon.setting("node_detector_distance_max", 10)
|
||||
if distance < 0 then distance = 0 end
|
||||
if distance > distance_max then distance = distance_max end
|
||||
|
||||
if channel ~= meta:get_string("digiline_channel") then return end
|
||||
|
||||
if msg == GET_COMMAND then
|
||||
local nodename = minetest.get_node(
|
||||
vector.subtract(pos, minetest.facedir_to_dir(node.param2))
|
||||
vector.subtract(pos, vector.multiply(minetest.facedir_to_dir(node.param2), distance + 1))
|
||||
).name
|
||||
|
||||
digiline:receptor_send(pos, digiline.rules.default, channel, nodename)
|
||||
|
@ -208,7 +233,6 @@ minetest.register_node("mesecons_detector:node_detector_off", {
|
|||
}},
|
||||
on_construct = node_detector_make_formspec,
|
||||
on_receive_fields = node_detector_on_receive_fields,
|
||||
after_place_node = after_place_node_detector,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = node_detector_digiline
|
||||
})
|
||||
|
@ -225,7 +249,6 @@ minetest.register_node("mesecons_detector:node_detector_on", {
|
|||
}},
|
||||
on_construct = node_detector_make_formspec,
|
||||
on_receive_fields = node_detector_on_receive_fields,
|
||||
after_place_node = after_place_node_detector,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
digiline = node_detector_digiline
|
||||
})
|
||||
|
|
|
@ -52,32 +52,27 @@ local function get_blockpos(pos)
|
|||
end
|
||||
|
||||
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
|
||||
local handle_active_blocks_step = 2
|
||||
local handle_active_blocks_timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
handle_active_blocks_timer = handle_active_blocks_timer + dtime
|
||||
if handle_active_blocks_timer >= handle_active_blocks_step then
|
||||
handle_active_blocks_timer = handle_active_blocks_timer - handle_active_blocks_step
|
||||
local active_block_range = tonumber(minetest.setting_get("active_block_range")) or 2
|
||||
local new_active_blocks = {}
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local blockpos = get_blockpos(player:getpos())
|
||||
local minp = vector.subtract(blockpos, active_block_range)
|
||||
local maxp = vector.add(blockpos, active_block_range)
|
||||
|
||||
for x = minp.x, maxp.x do
|
||||
for y = minp.y, maxp.y do
|
||||
for z = minp.z, maxp.z do
|
||||
local pos = {x = x, y = y, z = z}
|
||||
new_active_blocks[minetest.hash_node_position(pos)] = pos
|
||||
end
|
||||
end
|
||||
end
|
||||
local move_entities_globalstep_part1 = function(dtime)
|
||||
local active_block_range = tonumber(minetest.setting_get("active_block_range")) or 2
|
||||
local new_active_blocks = {}
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local blockpos = get_blockpos(player:getpos())
|
||||
local minp = vector.subtract(blockpos, active_block_range)
|
||||
local maxp = vector.add(blockpos, active_block_range)
|
||||
|
||||
for x = minp.x, maxp.x do
|
||||
for y = minp.y, maxp.y do
|
||||
for z = minp.z, maxp.z do
|
||||
local pos = {x = x, y = y, z = z}
|
||||
new_active_blocks[minetest.hash_node_position(pos)] = pos
|
||||
end
|
||||
end
|
||||
end
|
||||
active_blocks = new_active_blocks
|
||||
-- todo: callbacks on block load/unload
|
||||
end
|
||||
end)
|
||||
active_blocks = new_active_blocks
|
||||
-- todo: callbacks on block load/unload
|
||||
end
|
||||
|
||||
local function is_active(pos)
|
||||
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
|
||||
|
@ -309,7 +304,7 @@ function luaentity.get_objects_inside_radius(pos, radius)
|
|||
end
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local move_entities_globalstep_part2 = function(dtime)
|
||||
if not luaentity.entities then
|
||||
luaentity.entities = read_entities()
|
||||
end
|
||||
|
@ -348,4 +343,16 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local handle_active_blocks_step = 0.2
|
||||
local handle_active_blocks_timer = 0.1
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
handle_active_blocks_timer = handle_active_blocks_timer + dtime
|
||||
if handle_active_blocks_timer >= handle_active_blocks_step then
|
||||
handle_active_blocks_timer = handle_active_blocks_timer - handle_active_blocks_step
|
||||
move_entities_globalstep_part1(dtime)
|
||||
move_entities_globalstep_part2(dtime)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -225,9 +225,8 @@ local rope_def = {
|
|||
drop = "",
|
||||
tiles = { "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_3.png", "ropes_5.png", "ropes_5.png" },
|
||||
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
sounds = {
|
||||
footstep = "ropes_creak",
|
||||
footstep = {name = "ropes_creak", gain = 0.8, max_hear_distance = 6},
|
||||
dig = "__group",
|
||||
dug = "__group",
|
||||
},
|
||||
|
@ -262,7 +261,7 @@ local rope_bottom_def = {
|
|||
drawtype = "nodebox",
|
||||
groups = {choppy=2, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = {
|
||||
footstep = "ropes_creak",
|
||||
footstep = {name = "ropes_creak", gain = 0.8, max_hear_distance = 6},
|
||||
dig = "__group",
|
||||
dug = "__group",
|
||||
},
|
||||
|
|
|
@ -221,6 +221,7 @@ end
|
|||
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: reactor melt-down check",
|
||||
nodenames = {"technic:hv_nuclear_reactor_core_active"},
|
||||
interval = 4,
|
||||
chance = 1,
|
||||
|
|
|
@ -146,6 +146,7 @@ minetest.register_node("technic:power_radiator", {
|
|||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: run power radiator",
|
||||
nodenames = {"technic:power_radiator"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
|
|
@ -70,6 +70,7 @@ minetest.register_node("technic:coal_alloy_furnace_active", {
|
|||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: run coal alloy furnace",
|
||||
nodenames = {"technic:coal_alloy_furnace", "technic:coal_alloy_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
|
|
@ -104,6 +104,7 @@ minetest.register_node("technic:injector", {
|
|||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: run injector",
|
||||
nodenames = {"technic:injector"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
|
|
@ -35,7 +35,7 @@ minetest.register_node("technic:power_monitor",{
|
|||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:power_monitor"},
|
||||
label = "Power Monitor",
|
||||
label = "Machines: run power monitor",
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
|
|
@ -436,6 +436,7 @@ local function switching_station_timeout_count(pos, tier)
|
|||
end
|
||||
end
|
||||
minetest.register_abm({
|
||||
label = "Machines: timeout check",
|
||||
nodenames = {"group:technic_machine"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
@ -461,6 +462,7 @@ minetest.register_abm({
|
|||
|
||||
--Re-enable disabled switching station if necessary, similar to the timeout above
|
||||
minetest.register_abm({
|
||||
label = "Machines: re-enable check",
|
||||
nodenames = {"technic:switching_station"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
|
|
@ -346,6 +346,7 @@ end
|
|||
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
minetest.register_abm({
|
||||
label = "Radiation damage",
|
||||
nodenames = {"group:radioactive"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
@ -438,6 +439,7 @@ minetest.register_node("technic:chernobylite_block", {
|
|||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Corium: boil-off water (sources)",
|
||||
nodenames = {"group:water"},
|
||||
neighbors = {"technic:corium_source"},
|
||||
interval = 1,
|
||||
|
@ -448,6 +450,7 @@ minetest.register_abm({
|
|||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Corium: boil-off water (flowing)",
|
||||
nodenames = {"technic:corium_flowing"},
|
||||
neighbors = {"group:water"},
|
||||
interval = 1,
|
||||
|
@ -458,6 +461,7 @@ minetest.register_abm({
|
|||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Corium: become chernobylite",
|
||||
nodenames = {"technic:corium_flowing"},
|
||||
interval = 5,
|
||||
chance = (griefing and 10 or 1),
|
||||
|
@ -468,6 +472,7 @@ minetest.register_abm({
|
|||
|
||||
if griefing then
|
||||
minetest.register_abm({
|
||||
label = "Corium: griefing",
|
||||
nodenames = {"technic:corium_source", "technic:corium_flowing"},
|
||||
interval = 4,
|
||||
chance = 4,
|
||||
|
|
|
@ -62,6 +62,7 @@ minetest.register_craftitem("technic:rubber", {
|
|||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Tools: tree tap",
|
||||
nodenames = {"moretrees:rubber_tree_trunk_empty"},
|
||||
interval = 60,
|
||||
chance = 15,
|
||||
|
|
|
@ -51,7 +51,7 @@ mg.register_ore({
|
|||
mg.register_ore({
|
||||
name = "technic:mineral_lead",
|
||||
wherein = "default:stone",
|
||||
seeddiff = 13,
|
||||
seeddiff = 14,
|
||||
maxvdistance = 10.5,
|
||||
maxheight = 16,
|
||||
seglenghtn = 15,
|
||||
|
|
|
@ -73,6 +73,7 @@ technic.rubber_tree_model={
|
|||
|
||||
minetest.register_abm({
|
||||
nodenames = {"moretrees:rubber_tree_sapling"},
|
||||
label = "Worldgen: grow rubber tree sapling",
|
||||
interval = 60,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
|
|
Loading…
Reference in New Issue