Based on the mod nuke version 1.4 from sfan5
http://forum.minetest.net/viewtopic.php?id=638I modified the
init.lua file.
At the verry beginning I register a new privilege (add before the first line):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_privilege("nuke", {
description = "Can use TNT from mod nuke",
give_to_singleplayer = false
})
After this, I modified every
register_on_punchnode function to check the newly registerd privilege:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_on_punchnode(function(p, node, puncher)
if node.name == "nuke:iron_tnt" then
minetest.env:remove_node(p)
local p_name = puncher:get_player_name()
if minetest.check_player_privs(p_name, {nuke=false}) then
-- player doesn''t have privilege --> cancel explosion
minetest.chat_send_player(p_name, "privilege nuke required: defuse!")
nodeupdate(p)
end
if minetest.check_player_privs(p_name, {nuke=true}) then
-- player has privilege --> explode
minetest.chat_send_player(p_name, "privilege nuke found: explode!")
spawn_tnt(p, "nuke:iron_tnt")
nodeupdate(p)
end
end
end)
This works.
Nobody has the privilege "nuke" by default (except maybe the serveradmin). The TNT gets defused and removed as it should.
If somebody has the privilege, the TNT explodes. But in this case both messages
"privilege nuke required: defuse!" and
"privilege nuke found: explode!" are sent to the player. This one thing i don't understand. Only "privilege nuke found: explode!" should be sent to the player.