Add a settingtypes.txt file

This commit is contained in:
upsilon 2017-02-11 14:01:20 +01:00
parent b341335d3b
commit 795146a83e
No known key found for this signature in database
GPG Key ID: A80DAE1F266E1C3C
7 changed files with 113 additions and 22 deletions

View File

@ -1,7 +1,9 @@
local accepted_commands = {"tell"} -- Authorized commands. Any to accept all.
local NEAREST_MAX_DISTANCE = 8
local function initialize_data(meta)
local NEAREST_MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_commandblock.nearest_max_distance")) or 8
if NEAREST_MAX_DISTANCE <= 0 then
NEAREST_MAX_DISTANCE = 1
end
local commands = meta:get_string("commands")
meta:set_string("formspec",
"invsize[9,5;]" ..
@ -68,6 +70,23 @@ local function resolve_commands(commands, pos)
end
local function commandblock_action_on(pos, node)
local NEAREST_MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_commandblock.nearest_max_distance")) or 8
if NEAREST_MAX_DISTANCE <= 0 then
NEAREST_MAX_DISTANCE = 1
end
local accepted_commands = {}
do
local commands_str = minetest.setting_get("moremesecons_commandblock.authorized_commands")
if commands_str then
for command in string.gmatch(commands_str, "([^ ]+)") do
accepted_commands[command] = true
end
else
accepted_commands = {tell = true}
end
end
if node.name ~= "moremesecons_commandblock:commandblock_off" then
return
end
@ -93,14 +112,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,5 +1,3 @@
local JAMMER_MAX_DISTANCE = 10
-- see wireless jammer
local get = vector.get_data_from_pos
local set = vector.set_data_to_pos
@ -18,6 +16,11 @@ local function remove_jammer(pos)
end
local function is_jammed(pos)
local JAMMER_MAX_DISTANCE = tonumber(minetest.setting_get(moresecons_jammer.max_distance)) or 10
if JAMMER_MAX_DISTANCE <= 0 then
JAMMER_MAX_DISTANCE = 1
end
local pz,py,px = vector.unpack(pos)
for z,yxs in pairs(jammers) do
if math.abs(pz-z) <= JAMMER_MAX_DISTANCE then

View File

@ -1,5 +1,8 @@
local kill_nearest_player = function(pos)
local MAX_DISTANCE = 8 -- Use this number to set maximal distance to kill
local MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_playerkiller.max_distance")) or 8 -- Use this number to set maximal distance to kill
if MAX_DISTANCE <= 0 then
MAX_DISTANCE = 8
end
-- Search the nearest player
local nearest
@ -22,7 +25,7 @@ local kill_nearest_player = function(pos)
-- maybe some mod placed it
return
end
if owner == nearest:get_player_name() then
-- don't kill the owner !
return

View File

@ -1,5 +1,7 @@
local MAX_DISTANCE = 8
local use_speech_dispatcher = true
local use_speech_dispatcher = minetest.setting_getbool("moremesecons_sayer.use_speech_dispatcher")
if use_speech_dispatcher == nil then
use_speech_dispatcher = true
end
local popen, execute = io.popen, os.execute
if use_speech_dispatcher then
@ -34,8 +36,14 @@ and popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") == "y
if language ~= "en" then
tab[3] = "-l "..language
end
MAX_DISTANCE = MAX_DISTANCE^2
function sayer_activate(pos)
local MAX_DISTANCE = minetest.setting_get("moremesecons_sayer.max_distance") or 8
if MAX_DISTANCE <= 0 then
MAX_DISTANCE = 1
end
MAX_DISTANCE = MAX_DISTANCE^2
local text = minetest.get_meta(pos):get_string("text")
if text == "" then
-- nothing to say
@ -69,6 +77,11 @@ and popen("if hash spd-say 2>/dev/null; then printf yes; fi"):read("*all") == "y
end
else
function sayer_activate(pos)
local MAX_DISTANCE = minetest.setting_get("moremesecons_sayer.max_distance") or 8
if MAX_DISTANCE <= 0 then
MAX_DISTANCE = 1
end
local tab = {
"Sayer at pos",
nil,

View File

@ -10,8 +10,14 @@ local register = function(pos)
end
local teleport_nearest = function(pos)
local MAX_TELEPORTATION_DISTANCE = 50
local MAX_PLAYER_DISTANCE = 25
local MAX_TELEPORTATION_DISTANCE = tonumber(minetest.setting_get("moremesecons_teleporter.max_t2t_distance")) or 50
if MAX_TELEPORTATION_DISTANCE <= 0 then
MAX_TELEPORTATION_DISTANCE = 1
end
local MAX_PLAYER_DISTANCE = tonumber(minetest.setting_get("moremesecons_teleporter.max_p2t_distance")) or 25
if MAX_PLAYER_DISTANCE <= 0 then
MAX_PLAYER_DISTANCE = 1
end
-- Search the nearest player
local nearest = nil

View File

@ -1,5 +1,3 @@
local JAMMER_MAX_DISTANCE = 15
local wireless = {}
local wireless_rids = {}
@ -116,6 +114,11 @@ end
-- looks big, but should work fast
function is_jammed(pos)
local JAMMER_MAX_DISTANCE = tonumber(minetest.setting_get("moremesecons_wireless.jammer_max_distance")) or 15
if JAMMER_MAX_DISTANCE <= 0 then
JAMMER_MAX_DISTANCE = 1
end
local pz,py,px = vector.unpack(pos)
for z,yxs in pairs(jammers) do
if math.abs(pz-z) <= JAMMER_MAX_DISTANCE then

51
settingtypes.txt Normal file
View File

@ -0,0 +1,51 @@
[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 set to 1
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 set to 1
moremesecons_jammer.max_distance (Jammer action range) float 10
[Player Killer]
# Player Killer action range
# Any value less than or equal to 0 will be set to 1
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 set to 1
moremesecons_sayer.max_distance (Range) float 8
[Teleporter]
# Maximum Teleporter To Teleporter distance
# Any value less than or equal to 0 will be set to 1
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
[Wireless]
# Wireless Jammer action range
# Any value less than or equal to 0 will be set to 1
moremesecons_wireless.jammer_max_distance (Wireless Jammer action range) float 15