8 Commits

Author SHA1 Message Date
b9d8cb03f2 Fix wireless receptors not triggering in unloaded map blocks 2021-04-06 23:56:34 +02:00
a9febb7572 Fix crash 2021-04-06 18:59:02 +02:00
90be91e9d6 Merge remote-tracking branch 'github/hybriddog/warning_fixes' 2021-04-06 16:26:03 +02:00
HybridDog
ba31d9e663 test for the use_texture_alpha_string_modes feature 2021-03-15 14:46:06 +01:00
a7f8e2e98b Merge remote-tracking branch 'upstream/hybriddog/warning_fixes' 2021-03-12 12:35:05 +01:00
28411dd7e9 Merge remote-tracking branch 'upstream/master' 2021-03-12 12:34:26 +01:00
HybridDog
e162cabae4 Use opaque use_texture_alpha for the timegate and dual_delayer
This avoids warnings shown by Minetest and improves the nodes' look when a bilinear filter is enabled.
Since the textures are also used as inventory images, I didn't remove the transparency from the texture files.
2021-03-11 12:57:45 +01:00
sys4-fr
23b96b9db6 Ajoute messages de chargement des mods dans le journal "action" 2018-12-31 17:26:41 +01:00
65 changed files with 214 additions and 212 deletions

View File

@@ -1,10 +0,0 @@
name: luacheck
on: [push, pull_request]
jobs:
luacheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Luacheck
uses: lunarmodules/luacheck@master

View File

@@ -1,9 +1,22 @@
read_globals = {
-- Defined by Minetest
"minetest", "vector", "PseudoRandom", "VoxelArea", "table", "ItemStack",
"vector", "PseudoRandom", "VoxelArea", "table",
-- Mods
"digiline", "default", "creative",
-- Required for the mesechest registration
minetest = {
fields = {
register_lbm = {read_only = false},
register_node = {read_only = false},
registered_on_player_receive_fields = {
read_only = false,
other_fields = true,
},
},
other_fields = true
}
}
globals = {"moremesecons", "mesecon"}
ignore = {"212", "631", "422", "432"}

View File

@@ -0,0 +1,3 @@
mesecons
moremesecons_utils
craft_guide?

View File

@@ -64,3 +64,5 @@ minetest.register_craft({
recipe = { {"mesecons_blinkyplant:blinky_plant_off"},
{"default:mese_crystal_fragment"},}
})
minetest.log("action", "[moremesecons_adjustable_blinky_plant] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_adjustable_blinkyplant
depends = mesecons,moremesecons_utils,default
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -2,11 +2,9 @@
-- Detects players in a certain radius
-- The radius can be changes by right-click (by default 6)
local MAX_RADIUS = moremesecons.setting("adjustable_player_detector", "max_radius", 16, 0)
local function make_formspec(meta)
meta:set_string("formspec", "size[9,5]" ..
"field[0.3, 0;9,2;scanname;Comma-separated list of the names of players to scan for (empty for any):;${scanname}]"..
"field[0.3, 0;9,2;scanname;Coma-separated list of the names of players to scan for (empty for any):;${scanname}]"..
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
"field[0.3,3;4,2;radius;Detection radius:;${radius}]"..
"button_exit[3.5,3.5;2,3;;Save]")
@@ -38,7 +36,7 @@ local object_detector_scan = function (pos)
local scanname = meta:get_string("scanname")
local scan_all = scanname == ""
local scan_names = scanname:split(',')
local radius = math.min(meta:get_int("radius"), MAX_RADIUS)
local radius = meta:get_int("radius")
if radius <= 0 then
radius = 6
end
@@ -78,11 +76,11 @@ local object_detector_digiline = {
make_formspec(meta)
end
end
if type(msg.scanname) == "string" then
if msg.scanname then
meta:set_string("scanname", msg.scanname)
make_formspec(meta)
end
if msg.command == "get" then
if msg.command and msg.command == "get" then
local found, name = object_detector_scan(pos)
if not found then
name = ""
@@ -158,3 +156,5 @@ minetest.register_abm({
end
end,
})
minetest.log("action", "[moremesecons_adjustable_player_detector] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_adjustable_player_detector
depends = mesecons,moremesecons_utils,default
optional_depends = craft_guide

View File

@@ -0,0 +1,3 @@
mesecons
moremesecons_utils
craft_guide?

View File

@@ -1,12 +1,10 @@
local strip_color_codes = minetest.settings:get_bool("strip_color_codes", false)
local function initialize_data(meta)
local NEAREST_MAX_DISTANCE = moremesecons.setting("commandblock", "nearest_max_distance", 8, 1)
local commands = meta:get_string("commands")
meta:set_string("formspec",
"size[9,5]" ..
"textarea[0.5,0.5;8.5,4;commands;Commands;"..minetest.formspec_escape(commands).."]" ..
"invsize[9,5;]" ..
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
"label[1,3.8;@nearest is replaced by the nearest player name ("..tostring(NEAREST_MAX_DISTANCE).." nodes max for the nearest distance)".."]" ..
"button_exit[3.3,4.5;2,1;submit;Submit]")
local owner = meta:get_string("owner")
@@ -48,21 +46,17 @@ local function receive_fields(pos, _, fields, player)
and player:get_player_name() ~= owner then
return
end
if strip_color_codes then
meta:set_string("commands", minetest.strip_colors(fields.commands))
else
meta:set_string("commands", fields.commands)
end
meta:set_string("commands", fields.commands)
initialize_data(meta)
end
local function resolve_commands(commands, pos)
local nearest = ""
local nearest = nil
local min_distance = math.huge
local players = minetest.get_connected_players()
for _, player in pairs(players) do
local distance = vector.distance(pos, player:get_pos())
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player:get_player_name()
@@ -178,3 +172,5 @@ minetest.register_craft({
{"group:mesecon_conductor_craftable","default:mese_crystal","group:mesecon_conductor_craftable"}
}
})
minetest.log("action", "[moremesecons_commandblock] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_commandblock
depends = mesecons,moremesecons_utils,default
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -45,11 +45,10 @@ mesecon.register_node("moremesecons_conductor_signalchanger:conductor_signalchan
inventory_image = "moremesecons_conductor_signalchanger_off.png",
groups = {dig_immediate = 2},
paramtype = "light",
paramtype2 = "4dir",
paramtype2 = "facedir",
drawtype = "nodebox",
selection_box = nodebox,
node_box = nodebox,
on_rotate = mesecon.on_rotate,
},{
groups = {dig_immediate = 2},
mesecons = {
@@ -80,3 +79,5 @@ minetest.register_craft({
output = "moremesecons_conductor_signalchanger:conductor_signalchanger_off",
recipe = {{"group:mesecon_conductor_craftable","moremesecons_signalchanger:signalchanger_off"}}
})
minetest.log("action", "[moremesecons_conductor_signalchanger] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_conductor_signalchanger
depends = mesecons
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -68,7 +68,7 @@ for n,i in pairs({{0,0},{1,0},{1,1}}) do
inventory_image = top_texture,
wield_image = top_texture,
paramtype = "light",
paramtype2 = "4dir",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
@@ -79,7 +79,6 @@ for n,i in pairs({{0,0},{1,0},{1,1}}) do
groups = groups,
tiles = {top_texture, "moremesecons_dual_delayer_bottom.png", "moremesecons_dual_delayer_side_left.png", "moremesecons_dual_delayer_side_right.png", "moremesecons_dual_delayer_ends.png", "moremesecons_dual_delayer_ends.png"},
use_texture_alpha = use_texture_alpha,
on_rotate = mesecon.on_rotate,
mesecons = {
receptor = {
state = mesecon.state.off,
@@ -99,3 +98,5 @@ minetest.register_craft({
output = "moremesecons_dual_delayer:dual_delayer_00 2",
recipe = {"mesecons_delayer:delayer_off_1", "mesecons_delayer:delayer_off_1"}
})
minetest.log("action", "[moremesecons_dual_delayer] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_dual_delayer
depends = mesecons
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -2,11 +2,9 @@
-- Detects entitys in a certain radius
-- The radius can be changes by right-click (by default 6)
local MAX_RADIUS = moremesecons.setting("entity_detector", "max_radius", 16, 0)
local function make_formspec(meta)
meta:set_string("formspec", "size[9,5]" ..
"field[0.3, 0;9,2;scanname;Comma-separated list of the names (itemstring) of entities to scan for (empty for any):;${scanname}]"..
"field[0.3, 0;9,2;scanname;Coma-separated list of the names (itemstring) of entities to scan for (empty for any):;${scanname}]"..
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
"field[0.3,3;2,2;radius;Detection radius:;${radius}]"..
"button_exit[3.5,3.5;2,3;;Save]")
@@ -28,7 +26,7 @@ local function object_detector_on_receive_fields(pos, _, fields, player)
meta:set_string("digiline_channel", fields.digiline_channel)
local r = tonumber(fields.radius)
if r then
meta:set_int("radius", math.min(r, MAX_RADIUS))
meta:set_int("radius", r)
end
end
@@ -38,22 +36,22 @@ local object_detector_scan = function (pos)
local scanname = meta:get_string("scanname")
local scan_all = scanname == ""
local scan_names = scanname:split(',')
local radius = math.min(tonumber(meta:get("radius")) or 6, MAX_RADIUS)
local radius = meta:get_int("radius")
if radius == 0 then
radius = 6
end
for _,obj in pairs(minetest.get_objects_inside_radius(pos, radius)) do
local luaentity = obj:get_luaentity()
if luaentity then
if scan_all then
return true
end
if not obj:is_player() then
local luaentity = obj:get_luaentity()
local isname = luaentity.name
-- If the item is present as dropped item entity:
local bitemname = (isname == "__builtin:item" and ItemStack(luaentity.itemstring):get_name())
for _, name in ipairs(scan_names) do
if name == isname then
return true -- object name matches
if isname then
if scan_all then
return true
end
if name == bitemname then
return true -- item of the item entity matches
for _, name in ipairs(scan_names) do
if isname == name or (isname == "__builtin:item" and luaentity.itemstring == name) then
return true
end
end
end
end
@@ -67,7 +65,7 @@ local object_detector_digiline = {
action = function (pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local active_channel = meta:get_string("digiline_channel")
if channel ~= active_channel or type(msg) ~= "string" then
if channel ~= active_channel then
return
end
meta:set_string("scanname", msg)
@@ -141,3 +139,5 @@ minetest.register_abm({
end
end,
})
minetest.log("action", "[moremesecons_entity_detector] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_entity_detector
depends = mesecons,moremesecons_utils,default
optional_depends = craft_guide

View File

@@ -0,0 +1,3 @@
mesecons
fire
craft_guide?

View File

@@ -46,3 +46,5 @@ minetest.register_craft({
recipe = { {"default:torch"},
{"default:mese_crystal_fragment"},}
})
minetest.log("action", "[moremesecons_igniter] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_igniter
depends = mesecons,fire
optional_depends = craft_guide

View File

@@ -0,0 +1,3 @@
mesecons
mesecons_torch
default

View File

@@ -58,7 +58,6 @@ mesecon.register_node("moremesecons_induction_transmitter:induction_transmitter"
{-0.25, -0.25, -0.5, 0.25, 0.25, -0.1875},
},
},
on_rotate = mesecon.on_rotate,
}, {
tiles = {"default_mese_block.png"},
groups = {cracky = 3},
@@ -99,3 +98,5 @@ minetest.register_craft({
{"", "default:mese_crystal_fragment", ""}
}
})
minetest.log("action", "[moremesecons_induction_transmitter] loaded.")

View File

@@ -1,2 +0,0 @@
name = moremesecons_induction_transmitter
depends = mesecons,mesecons_torch,default

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -42,13 +42,12 @@ mesecon.register_node("moremesecons_injector_controller:injector_controller", {
drawtype = "nodebox",
inventory_image = "moremesecons_injector_controller_off.png",
paramtype = "light",
paramtype2 = "4dir",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }},
},
on_timer = on_timer,
on_rotate = mesecon.on_rotate,
},{
tiles = {"moremesecons_injector_controller_off.png", "moremesecons_injector_controller_side.png", "moremesecons_injector_controller_side.png"},
groups = {dig_immediate=2},
@@ -83,3 +82,5 @@ minetest.register_craft({
output = "moremesecons_injector_controller:injector_controller_off",
recipe = {{"mesecons_blinkyplant:blinky_plant_off","mesecons_gates:and_off"}}
})
minetest.log("action", "[moremesecons_injector_controller] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_injector_controller
depends = mesecons
optional_depends = craft_guide

View File

@@ -0,0 +1,3 @@
mesecons
moremesecons_utils
craft_guide?

View File

@@ -131,3 +131,5 @@ if moremesecons.setting("jammer", "enable_lbm", false) then
action = add_jammer
})
end
minetest.log("action", "[moremesecons_jammer] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_jammer
depends = mesecons,moremesecons_utils
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
moremesecons_utils

View File

@@ -158,3 +158,5 @@ minetest.register_node("moremesecons_luablock:luablock", {
end
}}
})
minetest.log("action", "[moremesecons_luablock] loaded.")

View File

@@ -1,2 +0,0 @@
name = moremesecons_luablock
depends = mesecons,moremesecons_utils

View File

@@ -0,0 +1,3 @@
mesecons
mesecons_luacontroller
moremesecons_utils

View File

@@ -355,3 +355,5 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return
end
end)
minetest.log("action", "[moremesecons_luacontroller_tool] loaded.")

View File

@@ -1,2 +0,0 @@
name = moremesecons_luacontroller_tool
depends = mesecons,mesecons_luacontroller,moremesecons_utils

View File

@@ -0,0 +1,2 @@
default
mesecons

View File

@@ -8,9 +8,60 @@ local function mesechest_get_output_rules(node)
return rules
end
-- default.chest.register_chest() doesn't allow to register most of the callbacks we need
-- we have to override the chest node we registered again
default.chest.register_chest("moremesecons_mesechest:mesechest", {
local open_chests = {}
-- Override minetest.register_node so it adds a prefix ":"
local old_minetest_register_node = minetest.register_node
minetest.register_node = function(name, def)
local old_on_metadata_inventory_put = def.on_metadata_inventory_put
local old_on_metadata_inventory_take = def.on_metadata_inventory_take
local old_on_rightclick = def.on_rightclick
def.on_metadata_inventory_put = function(pos, ...)
old_on_metadata_inventory_put(pos, ...)
mesecon.receptor_on(pos, {mesechest_get_output_rules(minetest.get_node(pos))[2]})
minetest.after(1, function(pos)
mesecon.receptor_off(pos, {mesechest_get_output_rules(minetest.get_node(pos))[2]})
end, pos)
end
def.on_metadata_inventory_take = function(pos, ...)
old_on_metadata_inventory_take(pos, ...)
mesecon.receptor_on(pos, {mesechest_get_output_rules(minetest.get_node(pos))[3]})
minetest.after(1, function(pos)
mesecon.receptor_off(pos, {mesechest_get_output_rules(minetest.get_node(pos))[3]})
end, pos)
end
def.on_rightclick = function(pos, node, clicker, ...)
if old_on_rightclick(pos, node, clicker, ...) == nil then
mesecon.receptor_on(pos, {mesechest_get_output_rules(node)[1]})
open_chests[clicker:get_player_name()] = pos
end
end
old_minetest_register_node(":"..name, def)
end
local old_minetest_register_lbm = minetest.register_lbm
minetest.register_lbm = function() end
-- Get the on_player_receive_fields function. That's a huge hack
for i, f in ipairs(minetest.registered_on_player_receive_fields) do
local serialized = minetest.serialize(f)
if string.find(serialized, "default:chest") then
minetest.registered_on_player_receive_fields[i] = function(player, formname, fields)
if f(player, formname, fields) == true then
local pn = player:get_player_name()
if open_chests[pn] then
mesecon.receptor_off(open_chests[pn], {mesechest_get_output_rules(minetest.get_node(open_chests[pn]))[1]})
open_chests[pn] = nil
end
end
end
break
end
end
default.register_chest("mesechest", {
description = "Mese Chest",
tiles = {
"default_chest_top.png^[colorize:#d8e002:70",
@@ -31,7 +82,7 @@ default.chest.register_chest("moremesecons_mesechest:mesechest", {
}
})
default.chest.register_chest("moremesecons_mesechest:mesechest_locked", {
default.register_chest("mesechest_locked", {
description = "Locked Mese Chest",
tiles = {
"default_chest_top.png^[colorize:#d8e002:70",
@@ -53,68 +104,17 @@ default.chest.register_chest("moremesecons_mesechest:mesechest_locked", {
}
})
local moremesecons_chests = {}
for _, chest in ipairs({"moremesecons_mesechest:mesechest", "moremesecons_mesechest:mesechest_locked",
"moremesecons_mesechest:mesechest_open", "moremesecons_mesechest:mesechest_locked_open"}) do
local old_def = minetest.registered_nodes[chest]
local old_on_metadata_inventory_put = old_def.on_metadata_inventory_put
local old_on_metadata_inventory_take = old_def.on_metadata_inventory_take
local old_on_rightclick = old_def.on_rightclick
local override = {}
override.on_metadata_inventory_put = function(pos, ...)
old_on_metadata_inventory_put(pos, ...)
mesecon.receptor_on(pos, {mesechest_get_output_rules(minetest.get_node(pos))[2]})
minetest.after(1, function(pos)
mesecon.receptor_off(pos, {mesechest_get_output_rules(minetest.get_node(pos))[2]})
end, pos)
end
override.on_metadata_inventory_take = function(pos, ...)
old_on_metadata_inventory_take(pos, ...)
mesecon.receptor_on(pos, {mesechest_get_output_rules(minetest.get_node(pos))[3]})
minetest.after(1, function(pos)
mesecon.receptor_off(pos, {mesechest_get_output_rules(minetest.get_node(pos))[3]})
end, pos)
end
override.on_rightclick = function(pos, node, clicker, ...)
if old_on_rightclick(pos, node, clicker, ...) == nil then
mesecon.receptor_on(pos, {mesechest_get_output_rules(node)[1]})
end
end
minetest.override_item(chest, override)
moremesecons_chests[chest] = true
end
-- if the chest is getting closed, turn the signal off
-- luacheck: ignore 122
local old_lid_close = default.chest.chest_lid_close
function default.chest.chest_lid_close(pn)
local pos = default.chest.open_chests[pn].pos
-- old_lid_close will return true if the chest won't be closed
if old_lid_close(pn) then
return true
end
local node = minetest.get_node(pos)
if moremesecons_chests[node.name] then
mesecon.receptor_off(pos, {mesechest_get_output_rules(node)[1]})
end
end
minetest.register_node = old_minetest_register_node
minetest.register_lbm = old_minetest_register_lbm
minetest.register_craft({
output = "moremesecons_mesechest:mesechest",
output = "default:mesechest",
recipe = {{"group:mesecon_conductor_craftable", "default:chest", "group:mesecon_conductor_craftable"}}
})
minetest.register_craft({
output = "moremesecons_mesechest:mesechest_locked",
output = "default:mesechest_locked",
recipe = {{"group:mesecon_conductor_craftable", "default:chest_locked", "group:mesecon_conductor_craftable"}}
})
-- Legacy
minetest.register_alias("default:mesechest", "moremesecons_mesechest:mesechest")
minetest.register_alias("mesechest", "moremesecons_mesechest:mesechest")
minetest.register_alias("default:mesechest_locked", "moremesecons_mesechest:mesechest")
minetest.register_alias("mesechest_locked", "moremesecons_mesechest:mesechest_locked")
minetest.log("action", "[moremesecons_mesechest] loaded.")

View File

@@ -1,2 +0,0 @@
name = moremesecons_mesechest
depends = default,mesecons

View File

@@ -0,0 +1,4 @@
mesecons
mesecons_materials
moremesecons_utils
craft_guide?

View File

@@ -60,3 +60,5 @@ minetest.register_node("moremesecons_playerkiller:playerkiller", {
end,
sounds = default.node_sound_stone_defaults(),
})
minetest.log("action", "[moremesecons_playerkiller] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_playerkiller
depends = mesecons,mesecons_materials,moremesecons_utils,default
optional_depends = craft_guide

View File

@@ -0,0 +1,5 @@
mesecons
mesecons_noteblock
moremesecons_utils
default
craft_guide?

View File

@@ -121,3 +121,5 @@ minetest.register_craft({
recipe = {{"mesecons_luacontroller:luacontroller0000", "mesecons_noteblock:noteblock"},
{"group:wood", "group:wood"}}
})
minetest.log("action", "[moremesecons_sayer] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_sayer
depends = mesecons,mesecons_noteblock,moremesecons_utils,default
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -41,11 +41,10 @@ mesecon.register_node("moremesecons_signalchanger:signalchanger", {
inventory_image = "moremesecons_signalchanger_off.png",
groups = {dig_immediate = 2},
paramtype = "light",
paramtype2 = "4dir",
paramtype2 = "facedir",
drawtype = "nodebox",
selection_box = nodebox,
node_box = nodebox,
on_rotate = mesecon.on_rotate,
},{
groups = {dig_immediate = 2},
mesecons = {
@@ -80,3 +79,5 @@ minetest.register_craft({
output = "moremesecons_signalchanger:signalchanger_off",
recipe = {{"group:mesecon_conductor_craftable","moremesecons_switchtorch:switchtorch_off","group:mesecon_conductor_craftable"}}
})
minetest.log("action", "[moremesecons_signalchanger] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_signalchanger
depends = mesecons
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -127,3 +127,5 @@ minetest.register_abm({
-- 2 = x+1
-- 0 = y+1
-- 1 = y-1
minetest.log("action", "[moremesecons_switchtorch] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_switchtorch
depends = mesecons
optional_depends = craft_guide

View File

@@ -0,0 +1,3 @@
mesecons
moremesecons_utils
craft_guide?

View File

@@ -106,3 +106,5 @@ if moremesecons.setting("teleporter", "enable_lbm", false) then
action = register
})
end
minetest.log("action", "[moremesecons_teleporter] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_teleporter
depends = mesecons,moremesecons_utils,default
optional_depends = craft_guide

View File

@@ -0,0 +1,2 @@
mesecons
craft_guide?

View File

@@ -1,5 +1,3 @@
local MIN_DELAY = moremesecons.setting("timegate", "min_delay", 0.5)
local timegate_get_output_rules = function(node)
local rules = {{x = 0, y = 0, z = 1}}
for _ = 0, node.param2 do
@@ -16,28 +14,25 @@ local timegate_get_input_rules = function(node)
return rules
end
local function turnoff(pos, _, node)
if mesecon.is_receptor_on(node.name) then
node.name = "moremesecons_timegate:timegate_off"
minetest.swap_node(pos, node)
mesecon.receptor_off(pos)
end
end
-- Functions that are called after the delay time
local function turnon(pos, node)
local function timegate_activate(pos, node)
-- using a meta string allows writing the time in hexadecimals
local time = tonumber(minetest.get_meta(pos):get_string("time"))
if not (time and time >= MIN_DELAY) then
if not time then
return
end
-- restart the timer when the input was turned off and on again
minetest.get_node_timer(pos):start(time)
if mesecon.is_receptor_off(node.name) then
node.name = "moremesecons_timegate:timegate_on"
minetest.swap_node(pos, node)
mesecon.receptor_on(pos)
end
node.name = "moremesecons_timegate:timegate_on"
minetest.swap_node(pos, node)
mesecon.receptor_on(pos)
minetest.after(time, function()
local node = minetest.get_node(pos)
if node.name == "moremesecons_timegate:timegate_on" then
mesecon.receptor_off(pos)
node.name = "moremesecons_timegate:timegate_off"
minetest.swap_node(pos, node)
end
end)
end
local boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
@@ -71,7 +66,7 @@ mesecon.register_node("moremesecons_timegate:timegate", {
fixed = boxes
},
paramtype = "light",
paramtype2 = "4dir",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
sounds = default.node_sound_stone_defaults(),
@@ -83,9 +78,7 @@ mesecon.register_node("moremesecons_timegate:timegate", {
and not minetest.is_protected(pos, player:get_player_name()) then
minetest.get_meta(pos):set_string("time", fields.time)
end
end,
on_timer = turnoff,
on_rotate = mesecon.on_rotate
end
},{
tiles = {
"moremesecons_timegate_off.png",
@@ -106,7 +99,7 @@ mesecon.register_node("moremesecons_timegate:timegate", {
effector =
{
rules = timegate_get_input_rules,
action_on = turnon
action_on = timegate_activate
}
},
},{
@@ -127,7 +120,6 @@ mesecon.register_node("moremesecons_timegate:timegate", {
},
effector = {
rules = timegate_get_input_rules,
action_on = turnon
}
},
})
@@ -142,3 +134,5 @@ minetest.register_craft({
minetest.register_alias("moremesecons_temporarygate:temporarygate_off", "moremesecons_timegate:timegate_off")
minetest.register_alias("moremesecons_temporarygate:temporarygate_on", "moremesecons_timegate:timegate_on")
minetest.log("action", "[moremesecons_timegate] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_timegate
depends = mesecons,default
optional_depends = craft_guide

View File

@@ -379,3 +379,4 @@ local function do_test()
end
do_test()
--]]
minetest.log("action", "[moremesecons_utils] loaded.")

View File

@@ -1,2 +0,0 @@
name = moremesecons_utils
description = Various helping functions for moremesecons

View File

@@ -0,0 +1,4 @@
mesecons
moremesecons_utils
digilines?
craft_guide?

View File

@@ -277,7 +277,7 @@ local function on_digiline_receive(pos, node, channel, msg)
sending_digilines[pos_hash] = true
for i, wl_pos in pairs(wireless[wls.owner][wls.channel].members) do
if i ~= wls.id then
if i ~= wls.id then -- and check_wireless_exists(wl_pos) then
digiline:receptor_send(wl_pos, digiline.rules.default, channel, msg)
end
end
@@ -498,3 +498,5 @@ if storage:get_string("wireless_meta_2") == "" then
end
minetest.log("action", "[moremesecons_wireless] Done!")
end
minetest.log("action", "[moremesecons_wireless] loaded.")

View File

@@ -1,3 +0,0 @@
name = moremesecons_wireless
depends = mesecons,moremesecons_utils,default
optional_depends = digilines,craft_guide

View File

@@ -3,10 +3,6 @@
# Minimal interval authorized. Any lower will be set to it.
moremesecons_adjustable_blinky_plant.min_interval (Minimum Interval) float 0.5
[Adjustable Player Detector]
moremesecons_adjustable_player_detector.max_radius (Maximum adjustable player detector radius) float 16 0
[Craftable Commandblock]
# Space-separated list of authorized commands
@@ -17,10 +13,6 @@ moremesecons_commandblock.authorized_commands (Authorized commands) string tell
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_commandblock.nearest_max_distance (Nearest player maximum distance) float 8
[Entity Detector]
moremesecons_entity_detector.max_radius (Maximum entity detector radius) float 16 0
[Signal Jammer]
# Jammer action range
@@ -69,11 +61,6 @@ moremesecons_teleporter.max_p2t_distance (Maximum Player To Teleporter distance)
# from an older version which did not use it.
moremesecons_teleporter.enable_lbm (Enable Registration LBM) bool false
[Timegate]
# Minimum authorized length for the timegate signal. Timegates with a shorter time will not respond.
moremesecons_timegate.min_delay (Minimum timegate delay) float 0.5
[Wireless]
# Whether to enable the wireless jammer node