[mp_moremesecons] Update to Git commit e1d2e84 & patch caa71bc:

Commit: https://github.com/minetest-mods/MoreMesecons/tree/e1d2e84
Patch: https://github.com/AntumDeluge/mtmp-moremesecons/tree/caa71bc
This commit is contained in:
AntumDeluge 2017-05-12 15:59:19 -07:00
parent 800447b770
commit 5847a79dfc
56 changed files with 794 additions and 181 deletions

View File

@ -189,7 +189,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* barn
* mobf
* mobf_settings
* [moremesecons][] ([GPL][lic.gpl3.0])
* [moremesecons][] ([MPL][lic.mpl2.0]) -- version: [e1d2e84 Git][ver.moremesecons] *2017-05-02* ([patched][patch.moremesecons])
* mp_moremesecons/
* [mydoors][] ([CC-BY / CC-BY-SA][lic.mydoors] / [WTFPL][lic.wtfpl] / [DWYWFPL][lic.dwywpl]) -- version: [63aef13 Git][ver.mydoors] *2017-03-31* ([patched][patch.mydoors])
* mp_mydoors/
@ -385,6 +385,8 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[lic.lgpl2.1]: doc/licenses/LGPL-2.1.txt
[lic.lgpl3.0]: doc/licenses/LGPL-3.0.txt
[lic.mit]: doc/licenses/MIT.txt
[lic.mpl]: doc/licenses/MPL-2.0.txt
[lic.mpl2.0]: doc/licenses/MPL-2.0.txt
[lic.unlicense]: doc/licenses/Unlicense.txt
[lic.wtfpl]: doc/licenses/WTFPL.txt
[lic.zlib]: doc/licenses/zlib.txt
@ -439,6 +441,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.mobs_redo]: https://github.com/tenplus1/mobs_redo/tree/feb26ed
[ver.more_chests]: https://github.com/minetest-mods/more_chests/tree/c597779
[ver.moreblocks]: https://github.com/minetest-mods/moreblocks/tree/fbfb079
[ver.moremesecons]: https://github.com/minetest-mods/MoreMesecons/tree/e1d2e84
[ver.moreores]: https://github.com/minetest-mods/moreores/tree/0842b4f
[ver.mydoors]: https://github.com/minetest-mods/mydoors/tree/63aef13
[ver.mywoodslopes]: https://github.com/minetest-mods/mywoodslopes/tree/3a1b531
@ -487,6 +490,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[patch.kpgmobs]: https://github.com/AntumDeluge/mtmod-kpgmobs/tree/7da994c
[patch.mesecons]: https://github.com/AntumDeluge/mtmp-mesecons/tree/2c5beee
[patch.mobs_goblins]: https://github.com/AntumDeluge/mtmod-mobs_goblins/tree/c7fc71b
[patch.moremesecons]: https://github.com/AntumDeluge/mtmp-moremesecons/tree/caa71bc
[patch.moreores]: https://github.com/AntumDeluge/mtmod-moreores/tree/2172c49
[patch.mydoors]: https://github.com/AntumDeluge/mtmp-mydoors/tree/e36c9d1
[patch.nether]: https://github.com/AntumDeluge/mtmod-nether/tree/f634851

View File

@ -4,15 +4,14 @@ Based on Mesecons by Jeija
By @paly2 and @HybridDog
With the participation of @LeMagnesium (bugfix), @Ataron (textures), @JAPP (texture).
Dependencies: [Mesecons](https://github.com/Jeija/minetest-mod-mesecons/), [vector_extras](https://github.com/HybridDog/vector_extras/), [digilines](https://github.com/minetest-mods/digilines) (optionnal).
Dependencies: [Mesecons](https://github.com/Jeija/minetest-mod-mesecons/)
Optional dependencies: [vector_extras](https://github.com/HybridDog/vector_extras/) [digilines](https://github.com/minetest-mods/digilines)
This mod is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v3.0 as published by the Free Software Foundation. You should have received a copy of the GNU General Public License along with this mod.
MoreMesecons is a mod for minetest wich adds some mesecons items.
MoreMesecons is a mod for minetest which adds some mesecons items.
[Here](http://github.com/minetest-mods/MoreMesecons/wiki)'s the wiki !
### New items
## New items
* `Adjustable Blinky plant` : Like a mesecons blinky plant, but... adjustable. Right-click to change the interval.
* `Adjustable Player Detector` : Like a mesecons player detector, but you can change its detection radius by right-click.
@ -20,15 +19,32 @@ MoreMesecons is a mod for minetest wich adds some mesecons items.
* `Conductor Signal Changer` : Like a diode which can be activated by sending a signal on its pin "F", and deactivated by sending a signal on its pin "O".
* `Dual Delayer` : If it receives a mesecons signal, port 1 turns on immediatly and port 2 turns on 0.4 seconds later. At the end of the signal, port 2 turns off immediatly and port 1 turns off 0.4 secondes later. For example, this is useful for double extenders.
* `Entity Detector` : You can use it to detect an entity. You can choose the entity to detect by right-click (use itemstring, for example "mobs:rat". To detect a dropped item, write "__builtin:item". To detect a specific dropped item, write its itemstring (for example "default:cobble")).
* `Igniter` : This node is a lighter that ignites ajacent flammable nodes (including TNT).
* `Igniter` : This node is a lighter that ignites its adjacent flammable nodes (including TNT).
* `Injector Controller` : This node is useful to activate/deactivate a pipeworks filter injector : it sends a blinky signal.
* `Jammer` : If turned on, this node stops mesecons in a radius of 10 nodes.
* `LuaBlock`: This block allows its owner to execute any Lua code in the global environment when turned on. Using it requires the server privilege.
* `Luacontroller Template Tool` : This tool is very useful to manipulate templates with luacontrollers. Just click with it on a luacontroller, then you'll see a formspec.
* `Player Killer` : This block kills the nearest player (with a maximal distance of 8 blocks by default) (if this player isn't its owner) when it receives a mesecons signal.
* `Sayer` : This node sends a message to every players inside a radius of 8 nodes.
* `Signal Changer` : If it receives a signal on its pin "F", it turns on. If it receives a signal on its pin "O", it turns off. Note : an inverted signal is sended at the other end of the arrow.
* `Switch Torch` : It connects just like Mesecons Torch. If it receives a signal, it turns on, and if it receives a second signal, it turns off.
* `Teleporter` : If you place one teleporter, if it receives a mesecons, it teleports the nearest player on itself. If you place two teleporters on the same axis, if one receives a mesecons signal, it teleports the nearest player on the second (with a maximal distance of 50 nodes by default). The player teleporter must be inside a radius of 25 nodes.
* `Temporary Gate` : If it receives a mesecons signal, whatever its duration, a mesecons signal is send with a fixed duration. You can change it by right-click (in seconds) (you can write for example 0.2 to send a pulse, or 20 to send long signals).
* `Teleporter` : If you place one teleporter, it teleports the nearest player on itself when it receives a mesecons signal. If you place two teleporters on the same axis, when one receives a mesecons signal, it teleports the nearest player on the second (with a maximal distance of 50 nodes by default). The player teleporter must be inside a radius of 25 nodes.
* `Time Gate` : If it receives a mesecons signal, whatever its duration, a mesecons signal is send with a fixed duration. You can change it in the formspec by right-clicking on the gate.
* `Wireless` : Place 2 (or more) wireless somewhere. Change their channel by right-click. If you send a signal to a wireless, every wireless wich have the same channel will send the signal. Compatible with digiline mod.
* `Wireless Jammer` : If it receives a mesecons signal, it deactivates all wireless (receptors) in a radius of 15 nodes.
## Settings
You can set the settings by using the Minetest GUI ("Settings" tab -> Advanced settings -> Mods -> MoreMesecons).
## The Sayer and the Speech Dispatcher
[Speech Dispatcher project](http://freecode.com/projects/speech-dispatcher)
The Sayer item is able to speak on your speakers using the speech dispatcher, under these conditions:
1. The moremesecons_sayer mod is present in your trusted_mods setting
2. You are playing in singleplayer.
3. You are using a POSIX-compliant system and a sh-compatible shell (such as bash, dash, zsh...). Microsoft Windows is NOT POSIX-compliant.
4. The speech dispatcher is installed on your system.
The mod is able to detect issues 1, 2, and 4 by itself and then disable the speech dispatcher ; however, if you are using a non-POSIX-compliant system, the mod will crash on startup and you will need to disable the speech dispatcher manually (Settings tab -> Advanced settings -> Mods -> MoreMesecons -> Sayer -> Use the Speech Dispatcher).

View File

@ -0,0 +1 @@
Adds more Mesecons items.

View File

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

View File

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

View File

@ -4,9 +4,9 @@
local function make_formspec(meta)
meta:set_string("formspec", "size[9,5]" ..
"field[0.3, 0;9,2;scanname;Name of player 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;2,2;radius;Detection radius:;${radius}]"..
"field[0.3,3;4,2;radius;Detection radius:;${radius}]"..
"button_exit[3.5,3.5;2,3;;Save]")
end
@ -35,16 +35,23 @@ local object_detector_scan = function (pos)
local meta = minetest.get_meta(pos)
local scanname = meta:get_string("scanname")
local scan_all = scanname == ""
local scan_names = scanname:split(',')
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 isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
if isname ~= ""
and (scan_all or isname == scanname) then -- player with scanname found or not scanname specified
if isname ~= "" then
if scan_all then
return true
end
for _, name in ipairs(scan_names) do
if isname == name then
return true
end
end
end
end
return false
end

View File

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

View File

@ -1,7 +1,6 @@
local accepted_commands = {"tell"} -- Authorized commands. Any to accept all.
local NEAREST_MAX_DISTANCE = 8
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",
"invsize[9,5;]" ..
@ -68,6 +67,16 @@ local function resolve_commands(commands, pos)
end
local function commandblock_action_on(pos, node)
local NEAREST_MAX_DISTANCE = moremesecons.setting("commandblock", "nearest_max_distance", 8, 1)
local accepted_commands = {}
do
local commands_str = moremesecons.setting("commandblock", "authorized_commands", "tell")
for command in string.gmatch(commands_str, "([^ ]+)") do
accepted_commands[command] = true
end
end
if node.name ~= "moremesecons_commandblock:commandblock_off" then
return
end
@ -93,14 +102,7 @@ local function commandblock_action_on(pos, node)
param = command:sub(pos + 1)
end
local cmddef = minetest.chatcommands[cmd]
local is_an_authorized_command = false
for i = 1, #accepted_commands do
if cmd == accepted_commands[i] then
is_an_authorized_command = true
break
end
end
if not is_an_authorized_command and #accepted_commands ~= 0 then
if not accepted_commands[cmd] and next(accepted_commands) then
minetest.chat_send_player(owner, "You can not execute the command "..cmd.." with a craftable command block ! This event will be reported.")
minetest.log("action", "Player "..owner.." tryed to execute an unauthorized command with a craftable command block.")
return

View File

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

View File

@ -4,7 +4,7 @@ local nodebox = {
}
local function signalchanger_get_output_rules(node)
local rules = {{x=1, y=0, z=0}}
local rules = {{x=-1, y=0, z=0}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
@ -12,7 +12,7 @@ local function signalchanger_get_output_rules(node)
end
local function signalchanger_get_input_rules(node)
local rules = {{x=0, y=0, z=1, name="input_on"}, {x=0, y=0, z=-1, name="input_off"}, {x=-1, y=0, z=0, name="input_signal"}}
local rules = {{x=0, y=0, z=-1, name="input_on"}, {x=0, y=0, z=1, name="input_off"}, {x=1, y=0, z=0, name="input_signal"}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 158 B

View File

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

View File

@ -1,5 +1,5 @@
local function dual_delayer_get_input_rules(node)
local rules = {{x=-1, y=0, z=0}}
local rules = {{x=1, y=0, z=0}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
@ -7,7 +7,7 @@ local function dual_delayer_get_input_rules(node)
end
local function dual_delayer_get_output_rules(node)
local rules = {{x=0, y=0, z=-1}, {x=0, y=0, z=1}}
local rules = {{x=0, y=0, z=1}, {x=0, y=0, z=-1}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
@ -68,7 +68,7 @@ for n,i in pairs({{0,0},{1,0},{1,1}}) do
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-6/16, -8/16, -1/16, 6/16, -7/16, 8/16 },
fixed = {{-6/16, -8/16, -8/16, 6/16, -7/16, 1/16 },
{-8/16, -8/16, 1/16, -6/16, -7/16, -1/16},
{8/16, -8/16, -1/16, 6/16, -7/16, 1/16}}
},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 189 B

View File

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

View File

@ -4,7 +4,7 @@
local function make_formspec(meta)
meta:set_string("formspec", "size[9,5]" ..
"field[0.3, 0;9,2;scanname;Name (itemstring) of entity 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]")
@ -35,6 +35,7 @@ local object_detector_scan = function (pos)
local meta = minetest.get_meta(pos)
local scanname = meta:get_string("scanname")
local scan_all = scanname == ""
local scan_names = scanname:split(',')
local radius = meta:get_int("radius")
if radius == 0 then
radius = 6
@ -43,10 +44,16 @@ local object_detector_scan = function (pos)
if not obj:is_player() then
local luaentity = obj:get_luaentity()
local isname = luaentity.name
if isname
and (scan_all or isname == scanname or (isname == "__builtin:item" and luaentity.itemstring == scanname)) then -- entity with scanname found or not scanname specified
if isname then
if scan_all then
return true
end
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
end
return false

View File

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

View File

@ -1,3 +1,2 @@
mesecons
mesecons_blinkyplant
mesecons_gates
craft_guide?

View File

@ -1,2 +1,3 @@
mesecons
vector_extras
moremesecons_utils
craft_guide?

View File

@ -1,23 +1,42 @@
local JAMMER_MAX_DISTANCE = 10
-- see wireless jammer
local get = vector.get_data_from_pos
local set = vector.set_data_to_pos
local remove = vector.remove_data_from_pos
local jammers = {}
local jammers
local enable_lbm = moremesecons.setting("jammer", "enable_lbm", false)
local storage
if not minetest.get_mod_storage then
enable_lbm = true -- No mod storage (<= 0.4.15-stable): force registration of LBM
jammers = {}
else
storage = minetest.get_mod_storage()
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
end
local function update_mod_storage()
if not storage then
return
end
storage:set_string("jammers", minetest.serialize(jammers))
end
local function add_jammer(pos)
if get(jammers, pos.z,pos.y,pos.x) then
return
end
set(jammers, pos.z,pos.y,pos.x, true)
update_mod_storage()
end
local function remove_jammer(pos)
remove(jammers, pos.z,pos.y,pos.x)
update_mod_storage()
end
local function is_jammed(pos)
local JAMMER_MAX_DISTANCE = moremesecons.setting("jammer", "max_distance", 10, 1)
local pz,py,px = vector.unpack(pos)
for z,yxs in pairs(jammers) do
if math.abs(pz-z) <= JAMMER_MAX_DISTANCE then
@ -39,7 +58,7 @@ end
minetest.after(0, function() -- After loading all mods, override some functions
local jammed
local actual_node_get = minetest.get_node_or_nil
local actual_node_get = mesecon.get_node_force
local function temp_node_get(pos, ...)
local node = actual_node_get(pos, ...)
if jammed == nil
@ -77,13 +96,13 @@ minetest.after(0, function() -- After loading all mods, override some functions
local actual_turnon = mesecon.turnon
function mesecon.turnon(...)
--set those to the temporary functions
minetest.get_node_or_nil = temp_node_get
mesecon.get_node_force = temp_node_get
mesecon.is_conductor_off = temp_is_conductor_off
mesecon.is_effector = temp_is_effector
actual_turnon(...)
minetest.get_node_or_nil = actual_node_get
mesecon.get_node_force = actual_node_get
mesecon.is_conductor_off = actual_is_conductor_off
mesecon.is_effector = actual_is_effector
@ -101,6 +120,7 @@ mesecon.register_node("moremesecons_jammer:jammer", {
mesecons = {effector = {
action_on = function(pos)
add_jammer(pos)
minetest.sound_play("moremesecons_jammer", {pos = pos})
minetest.swap_node(pos, {name="moremesecons_jammer:jammer_on"})
end
}},
@ -123,9 +143,11 @@ minetest.register_craft({
{"", "moremesecons_wireless:jammer_off", ""}}
})
minetest.register_lbm({
if enable_lbm then
minetest.register_lbm({
name = "moremesecons_jammer:add_jammer",
nodenames = {"moremesecons_jammer:jammer_on"},
run_at_every_load = true,
action = add_jammer
})
})
end

View File

@ -0,0 +1,117 @@
local function make_formspec(meta, pos)
local code = meta:get_string("code")
local errmsg = minetest.formspec_escape(meta:get_string("errmsg"))
meta:set_string("formspec",
"size[10,8;]" ..
"textarea[0.5,0.5;10,7;code;Code;"..code.."]" ..
"label[0.1,7;"..errmsg.."]" ..
"button_exit[4,7.5;2,1;submit;Submit]")
end
minetest.register_node("moremesecons_luablock:luablock", {
description = "Lua Block",
tiles = {"moremesecons_luablock.png"},
groups = {cracky = 2},
on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and
not (placer and placer:get_player_control().sneak) then
return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
local pos
if minetest.registered_items[minetest.get_node(under).name].buildable_to then
pos = under
else
pos = pointed_thing.above
end
local name = placer:get_player_name()
if minetest.is_protected(pos, name) and
not minetest.check_player_privs(name, {protection_bypass = true}) then
minetest.record_protection_violation(pos, name)
return itemstack
end
if not minetest.check_player_privs(name, {server = true}) then
minetest.chat_send_player(name, "You can't use a LuaBlock without the server privilege.")
return itemstack
end
local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
if not node_def or not node_def.buildable_to then
return itemstack
end
minetest.set_node(pos, {name = "moremesecons_luablock:luablock"})
local meta = minetest.get_meta(pos)
meta:set_string("owner", name)
meta:set_string("infotext", "LuaBlock owned by " .. name)
make_formspec(meta, pos)
if not (creative and creative.is_enabled_for
and creative.is_enabled_for(placer:get_player_name())) then
itemstack:take_item()
end
return itemstack
end,
on_receive_fields = function(pos, form_name, fields, sender)
if not fields.submit then
return
end
local name = sender:get_player_name()
local meta = minetest.get_meta(pos)
if name ~= meta:get_string("owner") then
minetest.chat_send_player(name, "You don't own this LuaBlock.")
return
end
if not minetest.check_player_privs(name, {server = true}) then
minetest.chat_send_player(name, "You can't use a LuaBlock without the server privilege.")
return
end
meta:set_string("code", fields.code)
make_formspec(meta, pos)
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
return meta:get_string("owner") == player:get_player_name()
end,
mesecons = {effector = {
action_on = function(npos, node)
local meta = minetest.get_meta(npos)
local code = meta:get_string("code")
if code == "" then
return
end
-- We do absolutely no check there.
-- There is no limitation in the number of instruction the LuaBlock can execute
-- or the usage it can make of loops.
-- It is executed in the global namespace.
-- Remember: *The LuaBlock is highly dangerous and should be manipulated cautiously!*
local func, err = loadstring(code)
if not func then
meta:set_string("errmsg", err)
make_formspec(meta, pos)
return
end
-- Set the "pos" global
local old_pos = pos -- In case there's already an existing "pos" global
pos = table.copy(npos)
local good, err = pcall(func)
pos = old_pos
if not good then -- Runtime error
meta:set_string("errmsg", err)
make_formspec(meta, pos)
return
end
meta:set_string("errmsg", "")
make_formspec(meta, pos)
end
}}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

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

View File

@ -142,6 +142,9 @@ end
-- tests if the node is a luacontroller
local function is_luacontroller(pos)
if not pos then
return false
end
return string.match(minetest.get_node(pos).name, "mesecons_luacontroller:luacontroller%d%d%d%d")
end
@ -252,7 +255,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local code = get_code_or_nil(pname, fields.player_name, fields.template_name)
if code then
set_luacontroller_code(pos, code)
minetest.chat_send_player(pname, "code set to template at "..vector.pos_to_string(pos))
minetest.chat_send_player(pname, "code set to template at "..minetest.pos_to_string(pos))
end
return
end
@ -262,7 +265,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local code = get_code_or_nil(pname, fields.player_name, fields.template_name)
if code then
set_luacontroller_code(pos, meta:get_string("code").."\r"..code)
minetest.chat_send_player(pname, "code added to luacontroller at "..vector.pos_to_string(pos))
minetest.chat_send_player(pname, "code added to luacontroller at "..minetest.pos_to_string(pos))
end
return
end

View File

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

View File

@ -1,5 +1,5 @@
local kill_nearest_player = function(pos)
local MAX_DISTANCE = 8 -- Use this number to set maximal distance to kill
local MAX_DISTANCE = moremesecons.setting("playerkiller", "max_distance", 8, 1)
-- Search the nearest player
local nearest

View File

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

View File

@ -1,10 +1,34 @@
local MAX_DISTANCE = 8
local use_speech_dispatcher = true
local use_speech_dispatcher = moremesecons.setting("sayer", "use_speech_dispatcher", true)
local popen, execute = io.popen, os.execute
if use_speech_dispatcher then
if not minetest.is_singleplayer() then
minetest.log("warning", "[moremesecons_sayer] use_speech_dispatcher = true, but the speech dispatcher can only be used in singleplayer")
use_speech_dispatcher = false
else
local ie = {}
if minetest.request_insecure_environment then
ie = minetest.request_insecure_environment()
end
if not ie then
minetest.log("warning", "[moremesecons_sayer] This mod needs access to insecure functions in order to use the speech dispatcher. Please add the moremesecons_sayer mod to your secure.trusted_mods settings or disable the speech dispatcher.")
use_speech_dispatcher = false
else
popen = ie.io.popen
execute = ie.os.execute
end
end
if use_speech_dispatcher then
if popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") ~= "yes" then
minetest.log("warning", "[moremesecons_sayer] use_speech_dispatcher = true, but it seems the speech dispatcher isn't installed on your system")
use_speech_dispatcher = false
end
end
end
local sayer_activate
if use_speech_dispatcher
and minetest.is_singleplayer() -- must! executing commands with it and crashes may be possible
and io.popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") == "yes" then
if use_speech_dispatcher then
minetest.log("info", "[moremesecons_sayer] using speech dispatcher")
local tab = {
"spd-say",
@ -15,8 +39,10 @@ and io.popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") ==
if language ~= "en" then
tab[3] = "-l "..language
end
MAX_DISTANCE = MAX_DISTANCE^2
function sayer_activate(pos)
local MAX_DISTANCE = moremesecons.setting("sayer", "max_distance", 8, 1) ^ 2
local text = minetest.get_meta(pos):get_string("text")
if text == "" then
-- nothing to say
@ -46,10 +72,12 @@ and io.popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") ==
else
tab[4] = "-i "..volume
end
os.execute(table.concat(tab, " "))
execute(table.concat(tab, " "))
end
else
function sayer_activate(pos)
local MAX_DISTANCE = moremesecons.setting("sayer", "max_distance", 8, 1)
local tab = {
"Sayer at pos",
nil,

View File

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

View File

@ -4,8 +4,8 @@ local nodebox = {
}
local function signalchanger_get_output_rules(node)
local rules = {{x=1, y=0, z=0},
{x=-1, y=0, z=0}}
local rules = {{x=-1, y=0, z=0},
{x=1, y=0, z=0}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
@ -13,7 +13,7 @@ local function signalchanger_get_output_rules(node)
end
local function signalchanger_get_input_rules(node)
local rules = {{x=0, y=0, z=1, name="input_on"}, {x=0, y=0, z=-1, name="input_off"}}
local rules = {{x=0, y=0, z=-1, name="input_on"}, {x=0, y=0, z=1, name="input_off"}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
@ -77,5 +77,5 @@ mesecon.register_node("moremesecons_signalchanger:signalchanger", {
minetest.register_craft({
output = "moremesecons_signalchanger:signalchanger_off",
recipe = {{"group:mesecon_conductor_craftable","moremesecons_switchtorch:switchtorch_on","group:mesecon_conductor_craftable"}}
recipe = {{"group:mesecon_conductor_craftable","moremesecons_switchtorch:switchtorch_off","group:mesecon_conductor_craftable"}}
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 159 B

View File

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

View File

@ -34,7 +34,7 @@ local torch_get_input_rules = function(node)
end
minetest.register_craft({
output = "moremesecons_switchtorch:switchtorch_on 4",
output = "moremesecons_switchtorch:switchtorch_off 4",
recipe = {
{"default:stick"},
{"group:mesecon_conductor_craftable"},

View File

@ -1,2 +1,3 @@
mesecons
vector_extras
moremesecons_utils
craft_guide?

View File

@ -1,61 +1,90 @@
local teleporters = {}
local teleporters_rids = {}
local teleporters
local teleporters_rids
local enable_lbm = moremesecons.setting("teleporter", "enable_lbm", false)
local storage
if not minetest.get_mod_storage then
enable_lbm = true -- No mod storage (<= 0.4.15-stable): force registration of LBM
teleporters = {}
teleporters_rids = {}
jammers = {}
else
storage = minetest.get_mod_storage()
teleporters = minetest.deserialize(storage:get_string("teleporters")) or {}
teleporters_rids = minetest.deserialize(storage:get_string("teleporters_rids")) or {}
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
end
local function update_mod_storage()
if not storage then
return
end
storage:set_string("teleporters", minetest.serialize(teleporters))
storage:set_string("teleporters_rids", minetest.serialize(teleporters_rids))
end
local register = function(pos)
local function register(pos)
if not vector.get_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x) then
table.insert(teleporters, pos)
vector.set_data_to_pos(teleporters_rids, pos.z,pos.y,pos.x, #teleporters)
update_mod_storage()
end
end
local teleport_nearest = function(pos)
local MAX_TELEPORTATION_DISTANCE = 50
local MAX_PLAYER_DISTANCE = 25
local function teleport_nearest(pos)
local MAX_TELEPORTATION_DISTANCE = moremesecons.setting("teleporter", "max_t2t_distance", 50, 1)
local MAX_PLAYER_DISTANCE = moremesecons.setting("teleporter", "max_p2t_distance", 25, 1)
-- Search the nearest player
-- Search for the nearest player
local nearest = nil
local min_distance = MAX_PLAYER_DISTANCE
local players = minetest.get_connected_players()
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
if distance <= min_distance then
min_distance = distance
nearest = player
end
end
if not nearest then
-- If there is no nearest player (maybe too far...)
-- If there is no nearest player (maybe too far away...)
return
end
-- Search other teleporter and teleport
-- Search for the corresponding teleporter and teleport
if not minetest.registered_nodes["moremesecons_teleporter:teleporter"] then return end
local newpos = {}
local min_distance = MAX_TELEPORTATION_DISTANCE
for i = 1, #teleporters do
if minetest.get_node(teleporters[i]).name == "moremesecons_teleporter:teleporter" then
local tel_pos
if teleporters[i].y == pos.y and teleporters[i].x == pos.x and teleporters[i].z ~= pos.z then
newpos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
tel_pos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
elseif teleporters[i].z == pos.z and teleporters[i].x == pos.x and teleporters[i].y ~= pos.y then
newpos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
tel_pos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
elseif teleporters[i].z == pos.z and teleporters[i].y == pos.y and teleporters[i].x ~= pos.x then
newpos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
tel_pos = {x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z}
end
if tel_pos then
local distance = vector.distance(tel_pos, pos)
if distance <= min_distance then
min_distance = distance
newpos = tel_pos
end
end
end
if newpos.x then
-- If there is another teleporter BUT too far, delete newpos.
if vector.distance(newpos, pos) > MAX_TELEPORTATION_DISTANCE then
newpos = {}
end
end
if not newpos.x then
newpos = {x=pos.x, y=pos.y+1, z=pos.z} -- If newpos doesn't exist, teleport on the actual teleporter.
newpos = {x=pos.x, y=pos.y+1, z=pos.z} -- If newpos doesn't exist, teleport on the current teleporter
end
nearest:moveto(newpos)
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
minetest.log("action", "Player "..nearest:get_player_name().." was teleported using a MoreMesecons Teleporter.")
end
minetest.register_craft({
@ -79,14 +108,16 @@ minetest.register_node("moremesecons_teleporter:teleporter", {
if RID then
table.remove(teleporters, RID)
vector.remove_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x)
update_mod_storage()
end
end,
})
minetest.register_lbm({
if enable_lbm then
minetest.register_lbm({
name = "moremesecons_teleporter:add_teleporter",
nodenames = {"moremesecons_teleporter:teleporter"},
run_at_every_load = true,
action = register
})
})
end

View File

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

View File

@ -1,4 +1,4 @@
local temporarygate_get_output_rules = function(node)
local timegate_get_output_rules = function(node)
local rules = {{x = 0, y = 0, z = 1}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
@ -6,7 +6,7 @@ local temporarygate_get_output_rules = function(node)
return rules
end
local temporarygate_get_input_rules = function(node)
local timegate_get_input_rules = function(node)
local rules = {{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
@ -16,18 +16,18 @@ end
-- Functions that are called after the delay time
local function temporarygate_activate(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 then
return
end
node.name = "moremesecons_temporarygate:temporarygate_on"
node.name = "moremesecons_timegate:timegate_on"
minetest.swap_node(pos, node)
mesecon.receptor_on(pos)
minetest.after(time, function(pos, node)
mesecon.receptor_off(pos)
node.name = "moremesecons_temporarygate:temporarygate_off"
node.name = "moremesecons_timegate:timegate_off"
minetest.swap_node(pos, node)
end, pos, node)
end
@ -44,11 +44,11 @@ boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
{ -8/16, -8/16, -1/16, -6/16, -7/16, 1/16 }, -- the two wire stubs
{ 6/16, -8/16, -1/16, 8/16, -7/16, 1/16 }}
mesecon.register_node("moremesecons_temporarygate:temporarygate", {
description = "Temporary Gate",
mesecon.register_node("moremesecons_timegate:timegate", {
description = "Time Gate",
drawtype = "nodebox",
inventory_image = "moremesecons_temporarygate_off.png",
wield_image = "moremesecons_temporarygate_off.png",
inventory_image = "moremesecons_timegate_off.png",
wield_image = "moremesecons_timegate_off.png",
walkable = true,
selection_box = {
type = "fixed",
@ -74,51 +74,54 @@ mesecon.register_node("moremesecons_temporarygate:temporarygate", {
end
},{
tiles = {
"moremesecons_temporarygate_off.png",
"moremesecons_temporarygate_bottom.png",
"moremesecons_temporarygate_ends_off.png",
"moremesecons_temporarygate_ends_off.png",
"moremesecons_temporarygate_sides_off.png",
"moremesecons_temporarygate_sides_off.png"
"moremesecons_timegate_off.png",
"moremesecons_timegate_bottom.png",
"moremesecons_timegate_ends_off.png",
"moremesecons_timegate_ends_off.png",
"moremesecons_timegate_sides_off.png",
"moremesecons_timegate_sides_off.png"
},
groups = {bendy=2,snappy=1,dig_immediate=2},
mesecons = {
receptor =
{
state = mesecon.state.off,
rules = temporarygate_get_output_rules
rules = timegate_get_output_rules
},
effector =
{
rules = temporarygate_get_input_rules,
action_on = temporarygate_activate
rules = timegate_get_input_rules,
action_on = timegate_activate
}
},
},{
tiles = {
"moremesecons_temporarygate_on.png",
"moremesecons_temporarygate_bottom.png",
"moremesecons_temporarygate_ends_on.png",
"moremesecons_temporarygate_ends_on.png",
"moremesecons_temporarygate_sides_on.png",
"moremesecons_temporarygate_sides_on.png"
"moremesecons_timegate_on.png",
"moremesecons_timegate_bottom.png",
"moremesecons_timegate_ends_on.png",
"moremesecons_timegate_ends_on.png",
"moremesecons_timegate_sides_on.png",
"moremesecons_timegate_sides_on.png"
},
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1},
mesecons = {
receptor = {
state = mesecon.state.on,
rules = temporarygate_get_output_rules
rules = timegate_get_output_rules
},
effector = {
rules = temporarygate_get_input_rules,
rules = timegate_get_input_rules,
}
},
})
minetest.register_craft({
output = "moremesecons_temporarygate:temporarygate_off 2",
output = "moremesecons_timegate:timegate_off 2",
recipe = {
{"group:mesecon_conductor_craftable", "mesecons_delayer:delayer_off_1", "group:mesecon_conductor_craftable"},
{"default:wood","default:wood", "default:wood"},
}
})
minetest.register_alias("moremesecons_temporarygate:temporarygate_off", "moremesecons_timegate:timegate_off")
minetest.register_alias("moremesecons_temporarygate:temporarygate_on", "moremesecons_timegate:timegate_on")

View File

@ -0,0 +1 @@
vector_extras?

View File

@ -0,0 +1,77 @@
moremesecons = {}
function moremesecons.setting(modname, settingname, default, min)
local setting = "moremesecons_" .. modname .. "." .. settingname
if type(default) == "boolean" then
local ret = minetest.setting_getbool(setting)
if ret == nil then
ret = default
end
return ret
elseif type(default) == "string" then
return minetest.setting_get(setting) or default
elseif type(default) == "number" then
local ret = tonumber(minetest.setting_get(setting)) or default
if ret ~= ret then -- NaN
minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is NaN. Set to default value ("..tostring(default)..").")
ret = default
end
if min and ret < min then
minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is under minimum value "..tostring(min)..". Set to minimum value ("..tostring(min)..").")
ret = min
end
return ret
end
end
-- Vector helpers
-- All the following functions are from the vector_extras mod (https://github.com/HybridDog/vector_extras).
-- If you enable that mod, its functions will be used instead of the ones defined below
if not vector.get_data_from_pos then
function vector.get_data_from_pos(tab, z,y,x)
local data = tab[z]
if data then
data = data[y]
if data then
return data[x]
end
end
end
end
if not vector.set_data_to_pos then
function vector.set_data_to_pos(tab, z,y,x, data)
if tab[z] then
if tab[z][y] then
tab[z][y][x] = data
return
end
tab[z][y] = {[x] = data}
return
end
tab[z] = {[y] = {[x] = data}}
end
end
if not vector.remove_data_from_pos then
function vector.remove_data_from_pos(tab, z,y,x)
if vector.get_data_from_pos(tab, z,y,x) == nil then
return
end
tab[z][y][x] = nil
if not next(tab[z][y]) then
tab[z][y] = nil
end
if not next(tab[z]) then
tab[z] = nil
end
end
end
if not vector.unpack then
function vector.unpack(pos)
return pos.z, pos.y, pos.x
end
end

View File

@ -1,3 +1,4 @@
mesecons
vector_extras
moremesecons_utils
digilines?
craft_guide?

View File

@ -1,21 +1,139 @@
local JAMMER_MAX_DISTANCE = 15
local wireless
local wireless_meta -- This table contains wireless metadatas, it is a lot faster to access
local jammers
local wireless = {}
local wireless_rids = {}
local enable_lbm = moremesecons.setting("wireless", "enable_lbm", false)
local storage
if not minetest.get_mod_storage then
enable_lbm = true -- No mod storage (<= 0.4.15-stable): force registration of LBM
wireless = {}
wireless_meta = {owners = {}, channels = {}, ids = {}}
jammers = {}
else
storage = minetest.get_mod_storage()
wireless = minetest.deserialize(storage:get_string("wireless")) or {}
wireless_meta = minetest.deserialize(storage:get_string("wireless_meta")) or {owners = {}, channels = {}, ids = {}}
jammers = minetest.deserialize(storage:get_string("jammers")) or {}
end
local function update_mod_storage()
if not storage then
return
end
storage:set_string("wireless", minetest.serialize(wireless))
storage:set_string("wireless_meta", minetest.serialize(wireless_meta))
storage:set_string("jammers", minetest.serialize(jammers))
end
-- localize these functions with small names because they work fairly fast
local get = vector.get_data_from_pos
local set = vector.set_data_to_pos
local remove = vector.remove_data_from_pos
-- if the wireless at pos isn't stored yet, put it into the tables
local function register_RID(pos)
if get(wireless_rids, pos.z,pos.y,pos.x) then
local function remove_wireless(pos)
local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
if not owner or owner == "" then
return
end
local RID = #wireless+1
wireless[RID] = pos
set(wireless_rids, pos.z,pos.y,pos.x, RID)
remove(wireless_meta.owners, pos.z,pos.y,pos.x)
if not wireless[owner] or not next(wireless[owner]) then
wireless[owner] = nil
return
end
local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
if not channel or channel == "" then
return
end
table.remove(wireless[owner][channel], get(wireless_meta.ids, pos.z,pos.y,pos.x))
if #wireless[owner][channel] == 0 then
wireless[owner][channel] = nil
if not next(wireless[owner]) then
wireless[owner] = nil
end
end
remove(wireless_meta.channels, pos.z,pos.y,pos.x)
remove(wireless_meta.ids, pos.z,pos.y,pos.x)
end
local set_channel
local function set_owner(pos, owner)
if not owner or owner == "" then
return
end
local meta = minetest.get_meta(pos)
meta:set_string("owner", owner)
set(wireless_meta.owners, pos.z,pos.y,pos.x, owner)
if not wireless[owner] then
wireless[owner] = {}
end
local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
if channel and channel ~= "" then
if not wireless[owner][channel] then
wireless[owner][channel] = {}
end
set_channel(pos, channel)
end
meta:set_string("infotext", "Wireless owned by " .. owner .. " on " .. ((channel and channel ~= "") and "channel " .. channel or "undefined channel"))
end
function set_channel(pos, channel)
if not channel or channel == "" then
return
end
local meta = minetest.get_meta(pos)
local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
if not owner or owner == "" then
return
end
local old_channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
if old_channel and old_channel ~= "" and old_channel ~= channel then
remove_wireless(pos)
set_owner(pos, owner)
end
meta:set_string("channel", channel)
set(wireless_meta.channels, pos.z,pos.y,pos.x, channel)
if not wireless[owner] then
wireless[owner] = {}
end
if not wireless[owner][channel] then
wireless[owner][channel] = {}
end
local id = get(wireless_meta.ids, pos.z,pos.y,pos.x)
if id then
wireless[owner][channel][id] = pos
else
table.insert(wireless[owner][channel], pos)
meta:set_int("id", #wireless[owner][channel])
set(wireless_meta.ids, pos.z,pos.y,pos.x, #wireless[owner][channel])
end
meta:set_string("infotext", "Wireless owned by " .. owner .. " on channel " .. channel)
end
local function register_wireless(pos)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner == "" then
return
end
set_owner(pos, owner)
local channel = meta:get_string("channel")
if channel ~= "" then
set_channel(pos, channel)
end
update_mod_storage()
end
local is_jammed
@ -25,15 +143,19 @@ local function wireless_activate(pos)
return
end
local channel_first_wireless = minetest.get_meta(pos):get_string("channel")
if channel_first_wireless == "" then
local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
local id = get(wireless_meta.ids, pos.z,pos.y,pos.x)
if owner == "" or not wireless[owner] or channel == "" or not wireless[owner][channel] then
return
end
for i = 1, #wireless do
if not vector.equals(wireless[i], pos)
and minetest.get_meta(wireless[i]):get_string("channel") == channel_first_wireless then
mesecon.receptor_on(wireless[i])
minetest.swap_node(pos, {name = "moremesecons_wireless:wireless_on"})
for i, wl_pos in ipairs(wireless[owner][channel]) do
if i ~= id then
minetest.swap_node(wl_pos, {name = "moremesecons_wireless:wireless_on"})
mesecon.receptor_on(wl_pos)
end
end
end
@ -42,11 +164,20 @@ local function wireless_deactivate(pos)
if is_jammed(pos) then
return
end
local channel_first_wireless = minetest.get_meta(pos):get_string("channel")
for i = 1, #wireless do
if not vector.equals(wireless[i], pos)
and minetest.get_meta(wireless[i]):get_string("channel") == channel_first_wireless then
mesecon.receptor_off(wireless[i])
local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
local id = get(wireless_meta.ids, pos.z,pos.y,pos.x)
if owner == "" or not wireless[owner] or channel == "" or not wireless[owner][channel] then
return
end
minetest.swap_node(pos, {name = "moremesecons_wireless:wireless_off"})
for i, wl_pos in ipairs(wireless[owner][channel]) do
if i ~= id then
minetest.swap_node(wl_pos, {name = "moremesecons_wireless:wireless_off"})
mesecon.receptor_off(wl_pos)
end
end
end
@ -56,25 +187,26 @@ local function on_digiline_receive(pos, node, channel, msg)
if channel ~= setchan or is_jammed(pos) or setchan == "" then
return
end
for i = 1, #wireless do
if not vector.equals(wireless[i], pos)
and minetest.get_meta(wireless[i]):get_string("channel") == channel then
digiline:receptor_send(wireless[i], digiline.rules.default, channel, msg)
local channel = get(wireless_meta.channels, pos.z,pos.y,pos.x)
local owner = get(wireless_meta.owners, pos.z,pos.y,pos.x)
local id = get(wireless_meta.ids, pos.z,pos.y,pos.x)
if owner == "" or not wireless[owner] or channel == "" or not wireless[owner][channel] then
return
end
for i, wl_pos in ipairs(wireless[owner][channel]) do
if i ~= id then
digiline:receptor_send(wl_pos, digiline.rules.default, channel, msg)
end
end
end
minetest.register_node("moremesecons_wireless:wireless", {
tiles = {"moremesecons_wireless.png"},
mesecon.register_node("moremesecons_wireless:wireless", {
paramtype = "light",
paramtype2 = "facedir",
description = "Wireless",
walkable = true,
groups = {cracky=3},
mesecons = {effector = {
action_on = wireless_activate,
action_off = wireless_deactivate
}},
digiline = {
receptor = {},
effector = {
@ -84,38 +216,71 @@ minetest.register_node("moremesecons_wireless:wireless", {
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
minetest.get_meta(pos):set_string("formspec", "field[channel;channel;${channel}]")
register_RID(pos)
end,
on_destruct = function(pos)
local RID = get(wireless_rids, pos.z,pos.y,pos.x)
if RID then
table.remove(wireless, RID)
vector.remove_data_from_pos(wireless_rids, pos.z,pos.y,pos.x)
end
remove_wireless(pos)
update_mod_storage()
mesecon.receptor_off(pos)
end,
after_place_node = function(pos, placer)
local placername = placer:get_player_name()
set_owner(pos, placer:get_player_name())
update_mod_storage()
end,
on_receive_fields = function(pos, _, fields, player)
if fields.channel
and not minetest.is_protected(pos, player:get_player_name()) then
minetest.get_meta(pos):set_string("channel", fields.channel)
local meta = minetest.get_meta(pos)
local playername = player:get_player_name()
local owner = meta:get_string("owner")
if not owner or owner == "" then
-- Old wireless
if not minetest.is_protected(pos, playername) then
set_owner(pos, playername)
update_mod_storage()
else
return
end
end
if playername == owner then
set_channel(pos, fields.channel)
update_mod_storage()
end
end,
}, {
tiles = {"moremesecons_wireless_off.png"},
groups = {cracky=3},
mesecons = {effector = {
action_on = wireless_activate,
}},
}, {
tiles = {"moremesecons_wireless_on.png"},
groups = {cracky=3, not_in_creative_inventory=1},
mesecons = {effector = {
action_off = wireless_deactivate
}},
})
minetest.register_alias("moremesecons_wireless:wireless", "moremesecons_wireless:wireless_off")
local jammers = {}
local function add_jammer(pos)
if get(jammers, pos.z,pos.y,pos.x) then
return
end
set(jammers, pos.z,pos.y,pos.x, true)
update_mod_storage()
end
local function remove_jammer(pos)
remove(jammers, pos.z,pos.y,pos.x)
update_mod_storage()
end
-- looks big, but should work fast
function is_jammed(pos)
local JAMMER_MAX_DISTANCE = moremesecons.setting("wireless", "jammer_max_distance", 15, 1)
local pz,py,px = vector.unpack(pos)
for z,yxs in pairs(jammers) do
if math.abs(pz-z) <= JAMMER_MAX_DISTANCE then
@ -204,7 +369,7 @@ minetest.register_craft({
})
minetest.register_craft({
output = "moremesecons_wireless:wireless 2",
output = "moremesecons_wireless:wireless_off 2",
recipe = {
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
{"", "mesecons_torch:mesecon_torch_on", ""},
@ -212,16 +377,59 @@ minetest.register_craft({
}
})
minetest.register_lbm({
if enable_lbm then
minetest.register_lbm({
name = "moremesecons_wireless:add_jammer",
nodenames = {"moremesecons_wireless:jammer_on"},
run_at_every_load = true,
action = add_jammer
})
})
minetest.register_lbm({
minetest.register_lbm({
name = "moremesecons_wireless:add_wireless",
nodenames = {"moremesecons_wireless:wireless"},
run_at_every_load = true,
action = register_RID
})
action = register_wireless
})
end
-- Legacy
if storage and storage:get_string("wireless_rids") and storage:get_string("wireless_rids") ~= "" then
-- Upgrade mod storage!
local wireless_rids = minetest.deserialize(storage:get_string("wireless_rids"))
local old_wireless = table.copy(wireless)
wireless = {}
minetest.after(0, function(old_wireless)
-- After loading all mods, try to guess owners based on the areas mod database.
-- That won't work for all wireless. Owners of remaining wireless will be set
-- to the first player using their formspec.
if not areas then
return
end
for RID, pos in ipairs(old_wireless) do
local numerous_owners = false
local owner
for _, area in pairs(areas:getAreasAtPos(pos)) do
if owner and area.owner ~= owner then
numerous_owners = true
break
end
owner = area.owner
end
if not numerous_owners and owner then
set_owner(pos, owner)
set_channel(pos, minetest.get_meta(pos):get_string("channel"))
end
end
end, old_wireless)
-- Remove wireless_rids from storage
storage:from_table({
jammers = jammers,
wireless_meta = wireless_meta,
wireless = wireless
})
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,69 @@
[Craftable Commandblock]
# Space-separated list of authorized commands
# Empty to authorize all
moremesecons_commandblock.authorized_commands (Authorized commands) string tell
# Maximum distance of the @nearest player
# 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
[Signal Jammer]
# Jammer action range
# 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_jammer.max_distance (Jammer action range) float 10
# Whether to enable the registration LBM.
# The registration LBM will recover the jammer database if the moremesecons_jammer
# mod storage has been removed, and will create that mod storage after an update
# from an older version which did not use it.
moremesecons_jammer.enable_lbm (Enable Registration LBM) bool false
[Player Killer]
# Player Killer action range
# 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_playerkiller.max_distance (Player Killer action range) float 8
[Sayer]
# Whether to use the Speech Dispatcher
# It will work only if:
# * moremesecons_sayer is present in your trusted_mods setting
# * you are playing in singleplayer
# * the speech-dispatcher is installed on your system
# * you are using a POSIX-compliant system and a sh-compatible shell (such as bash, dash, zsh...)
moremesecons_sayer.use_speech_dispatcher (Use the Speech Dispatcher) bool true
# Sayer range
# 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_sayer.max_distance (Range) float 8
[Teleporter]
# Maximum Teleporter To Teleporter distance
# 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_teleporter.max_t2t_distance (Maximum Teleporter To Teleporter distance) float 50
# Maximum Player To Teleporter distance
# Any value less than or equal to 0 will be set to 1
moremesecons_teleporter.max_p2t_distance (Maximum Player To Teleporter distance) float 25
# Whether to enable the registration LBM.
# The registration LBM will recover a teleporter network if the moremesecons_teleporter
# mod storage has been removed, and will create that mod storage after an update
# from an older version which did not use it.
moremesecons_teleporter.enable_lbm (Enable Registration LBM) bool false
[Wireless]
# Wireless Jammer action range
# 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_wireless.jammer_max_distance (Wireless Jammer action range) float 15
# Whether to enable the registration LBM.
# The registration LBM will recover a wireless network if the moremesecons_wireless
# mod storage has been removed, and will create that mod storage after an update
# from an older version which did not use it.
moremesecons_wireless.enable_lbm (Enable Registration LBM) bool false