From f9cae7314e08fbeeef509c5c6ca095822fec1747 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Thu, 14 Jul 2016 09:03:38 -0400 Subject: update boost carts, mesecons, moreblocks, moretrees, unified inventory, and worldedit --- mesecons_commandblock/init.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mesecons_commandblock') diff --git a/mesecons_commandblock/init.lua b/mesecons_commandblock/init.lua index b1a0c6f..6cd0027 100644 --- a/mesecons_commandblock/init.lua +++ b/mesecons_commandblock/init.lua @@ -93,9 +93,22 @@ local function receive_fields(pos, formname, fields, sender) end local function resolve_commands(commands, pos) + local players = minetest.get_connected_players() + + -- No players online: remove all commands containing + -- @nearest, @farthest and @random + if #players == 0 then + commands = commands:gsub("[^\r\n]+", function (line) + if line:find("@nearest") then return "" end + if line:find("@farthest") then return "" end + if line:find("@random") then return "" end + return line + end) + return commands + end + local nearest, farthest = nil, nil local min_distance, max_distance = math.huge, -1 - 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 -- cgit v1.2.3