1
0
Fork 0

setting working

This commit is contained in:
AFCMS 2021-03-25 22:13:37 +01:00
parent e4a6244fdd
commit 8258dae1b8
1 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,7 @@ local F = minetest.formspec_escape
local color_red = mcl_colors.RED
local command_blocks_activated = minetest.settings:get_bool("mcl_enable_commandblocks", true)
local msg_not_activated = S("Command Blocks are not activated on the server") --TODO: real mc message and translation
local function construct(pos)
local meta = minetest.get_meta(pos)
@ -103,9 +104,14 @@ local function commandblock_action_on(pos, node)
return
end
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local meta = minetest.get_meta(pos)
local commander = meta:get_string("commander")
if not command_blocks_activated then
minetest.chat_send_player(commander, msg_not_activated)
return
end
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local commands = resolve_commands(meta:get_string("commands"), pos)
for _, command in pairs(commands:split("\n")) do
@ -121,7 +127,6 @@ local function commandblock_action_on(pos, node)
return
end
-- Execute command in the name of commander
local commander = meta:get_string("commander")
cmddef.func(commander, param)
end
end
@ -133,6 +138,10 @@ local function commandblock_action_off(pos, node)
end
local on_rightclick = function(pos, node, player, itemstack, pointed_thing)
if not command_blocks_activated then
minetest.chat_send_player(player:get_player_name(), msg_not_activated)
return
end
local can_edit = true
-- Only allow write access in Creative Mode
if not minetest.is_creative_enabled(player:get_player_name()) then