From 61e33714039654369b2cf5daff0026750f2229ae Mon Sep 17 00:00:00 2001 From: NathanSalapat Date: Sun, 14 Feb 2016 18:27:20 -0600 Subject: [PATCH] Added privs for use on a server. --- README.md | 2 ++ mycanadiancheckers/init.lua | 21 ++++++++++++++++----- mycheckers/init.lua | 16 +++++++++++----- mychess/board.lua | 16 +++++++++++----- myconnect4/init.lua | 15 +++++++++++---- mydiamondblock/init.lua | 15 +++++++++++---- mydraughts/init.lua | 16 +++++++++++----- mygomoku/init.lua | 13 ++++++++++--- mylittle_bg/init.lua | 15 +++++++++++---- mymazes/init.lua | 30 ++++++++++++++++++++++-------- mypachisi/init.lua | 13 ++++++++++--- mypitfall/init.lua | 15 +++++++++++---- mys_n_l/init.lua | 13 ++++++++++--- mys_n_l_mini/init.lua | 13 ++++++++++--- mytrouble/init.lua | 13 ++++++++++--- myuno/init.lua | 17 ++++++++++++----- 16 files changed, 179 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index a1f88d7..2ed8fb1 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,5 @@ There is no craft for these. Use /giveme or creative to get the placer block. Place the block and right click it. The schematic places to the north east.(+x,+z) For more information please view the topic on the forum. https://forum.minetest.net/viewtopic.php?f=9&t=13209 + +This version of the mod has been modified for server use, basically you need to have the myboardgames privilege to place the boards, by default this isn't granted to singleplayer. ~Nathan.S diff --git a/mycanadiancheckers/init.lua b/mycanadiancheckers/init.lua index a4b4656..b8318fa 100644 --- a/mycanadiancheckers/init.lua +++ b/mycanadiancheckers/init.lua @@ -1,3 +1,8 @@ +minetest.register_privilege("myboardgames", { + description = "Place board games", + give_to_singleplayer = false +}) + minetest.register_node("mycanadiancheckers:board", { description = "Canadian Checkers", @@ -10,11 +15,17 @@ minetest.register_node("mycanadiancheckers:board", { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults(), -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mycanadiancheckers").."/schems/mycanadiancheckers.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) -end, - + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mycanadiancheckers").."/schems/mycanadiancheckers.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) local board = { diff --git a/mycheckers/init.lua b/mycheckers/init.lua index 2c7a8e1..ab9a454 100644 --- a/mycheckers/init.lua +++ b/mycheckers/init.lua @@ -10,11 +10,17 @@ minetest.register_node("mycheckers:board", { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults(), -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mycheckers").."/schems/mycheckersboard.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) -end, - + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mycheckers").."/schems/mycheckersboard.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) local board = { diff --git a/mychess/board.lua b/mychess/board.lua index f2585ae..3d26791 100644 --- a/mychess/board.lua +++ b/mychess/board.lua @@ -10,11 +10,17 @@ minetest.register_node("mychess:board", { groups = {cracky = 3}, sounds = default.node_sound_stone_defaults(), -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mychess").."/schems/mychessboard.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) -end, - + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mychess").."/schems/mychessboard.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) diff --git a/myconnect4/init.lua b/myconnect4/init.lua index 892de22..e2eeaf1 100644 --- a/myconnect4/init.lua +++ b/myconnect4/init.lua @@ -124,8 +124,15 @@ minetest.register_node("myconnect4:reset",{ paramtype = "light", paramtype2 = "facedir", groups = {cracky=1}, -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("myconnect4").."/schems/myconnect4.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) -end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("myconnect4").."/schems/myconnect4.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) diff --git a/mydiamondblock/init.lua b/mydiamondblock/init.lua index 0f41d3c..88a961a 100644 --- a/mydiamondblock/init.lua +++ b/mydiamondblock/init.lua @@ -7,10 +7,17 @@ minetest.register_node("mydiamondblock:block",{ paramtype = "light", light_source = 8, groups = {cracky = 1}, -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mydiamondblock").."/schems/mydiamondblock.mts" - minetest.place_schematic(pos,schem,0, "air", true) -end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mydiamondblock").."/schems/mydiamondblock.mts" + minetest.place_schematic(pos,schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) for blues = 1,6 do local blue = blues diff --git a/mydraughts/init.lua b/mydraughts/init.lua index 2e5c834..7cabc0c 100644 --- a/mydraughts/init.lua +++ b/mydraughts/init.lua @@ -10,11 +10,17 @@ minetest.register_node("mydraughts:board", { groups = {cracky = 1}, sounds = default.node_sound_stone_defaults(), -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mydraughts").."/schems/mydraughts.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) -end, - + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mydraughts").."/schems/mydraughts.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) local board = { diff --git a/mygomoku/init.lua b/mygomoku/init.lua index 58b842f..7a22786 100644 --- a/mygomoku/init.lua +++ b/mygomoku/init.lua @@ -41,9 +41,16 @@ minetest.register_node("mygomoku:placer",{ groups = {cracky=3}, light_source = 5, on_rightclick = function(pos, node, player, itemstack, pointed_thing) - local schem = minetest.get_modpath("mygomoku").."/schems/mygomoku.mts" - minetest.place_schematic(pos,schem,0, "air", true) -end, + local schem = minetest.get_modpath("mygomoku").."/schems/mygomoku.mts" + minetest.place_schematic(pos,schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) minetest.register_alias("mygomoku:stone_brown","mygomoku:stone_black") diff --git a/mylittle_bg/init.lua b/mylittle_bg/init.lua index 60b619a..17ebae4 100644 --- a/mylittle_bg/init.lua +++ b/mylittle_bg/init.lua @@ -83,10 +83,17 @@ minetest.register_node("mylittle_bg:board",{ paramtype = "light", light_source = 8, groups = {cracky = 1}, -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mylittle_bg").."/schems/my_little_bg.mts" - minetest.place_schematic({x=pos.x,y=pos.y-2,z=pos.z},schem,0, "air", true) -end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mylittle_bg").."/schems/my_little_bg.mts" + minetest.place_schematic({x=pos.x,y=pos.y-2,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) local signs = { {"1","red","^[colorize:red:120"}, diff --git a/mymazes/init.lua b/mymazes/init.lua index a81482c..f6c830a 100644 --- a/mymazes/init.lua +++ b/mymazes/init.lua @@ -7,10 +7,17 @@ minetest.register_node("mymazes:block1",{ paramtype = "light", light_source = 8, groups = {cracky = 1}, -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mymazes").."/schems/mymaze1.mts" - minetest.place_schematic(pos,schem,0, "air", true) -end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mymazes").."/schems/mymaze1.mts" + minetest.place_schematic(pos,schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) minetest.register_node("mymazes:block2",{ description = "Maze 2", @@ -21,8 +28,15 @@ minetest.register_node("mymazes:block2",{ paramtype = "light", light_source = 8, groups = {cracky = 1}, -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mymazes").."/schems/mymaze2.mts" - minetest.place_schematic(pos,schem,0, "air", true) -end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mymazes").."/schems/mymaze2.mts" + minetest.place_schematic(pos,schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) diff --git a/mypachisi/init.lua b/mypachisi/init.lua index b3e41f1..080fe6e 100644 --- a/mypachisi/init.lua +++ b/mypachisi/init.lua @@ -68,8 +68,15 @@ minetest.register_node("mypachisi:placer",{ paramtype2 = "facedir", groups = {cracky=3}, on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mypachisi").."/schems/mypachisi.mts" - minetest.place_schematic(pos,schem,0, "air", true) -end, + local schem = minetest.get_modpath("mypachisi").."/schems/mypachisi.mts" + minetest.place_schematic(pos,schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) dofile(minetest.get_modpath("mypachisi").."/dice.lua") diff --git a/mypitfall/init.lua b/mypitfall/init.lua index 3ae6b7b..2547d7c 100644 --- a/mypitfall/init.lua +++ b/mypitfall/init.lua @@ -7,10 +7,17 @@ minetest.register_node("mypitfall:block",{ paramtype = "light", light_source = 8, groups = {cracky = 1}, -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mypitfall").."/schems/mypitfall1.mts" - minetest.place_schematic({x=pos.x,y=pos.y-9,z=pos.z},schem,0, "air", true) -end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("mypitfall").."/schems/mypitfall1.mts" + minetest.place_schematic({x=pos.x,y=pos.y-9,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) minetest.register_node("mypitfall:swamp_water", { description = "Swamp Water", diff --git a/mys_n_l/init.lua b/mys_n_l/init.lua index ffe9174..3fd3f99 100644 --- a/mys_n_l/init.lua +++ b/mys_n_l/init.lua @@ -135,9 +135,16 @@ minetest.register_node("mys_n_l:placer",{ paramtype2 = "facedir", groups = {cracky=3}, on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mys_n_l").."/schems/mys_n_l.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) -end, + local schem = minetest.get_modpath("mys_n_l").."/schems/mys_n_l.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) local pieces = { {"Red","red","^[colorize:red:120"}, diff --git a/mys_n_l_mini/init.lua b/mys_n_l_mini/init.lua index b5b0874..e4f8a7b 100644 --- a/mys_n_l_mini/init.lua +++ b/mys_n_l_mini/init.lua @@ -71,9 +71,16 @@ minetest.register_node("mys_n_l_mini:placer",{ paramtype2 = "facedir", groups = {cracky=3}, on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mys_n_l_mini").."/schems/mys_n_l_mini.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) -end, + local schem = minetest.get_modpath("mys_n_l_mini").."/schems/mys_n_l_mini.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) local pieces = { {"Red","red","^[colorize:red:120"}, diff --git a/mytrouble/init.lua b/mytrouble/init.lua index 76a7fef..31297fe 100644 --- a/mytrouble/init.lua +++ b/mytrouble/init.lua @@ -72,8 +72,15 @@ minetest.register_node("mytrouble:placer",{ paramtype2 = "facedir", groups = {cracky=3}, on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("mytrouble").."/schems/mytrouble.mts" - minetest.place_schematic({x=pos.x-1,y=pos.y,z=pos.z-1},schem,0, "air", true) -end, + local schem = minetest.get_modpath("mytrouble").."/schems/mytrouble.mts" + minetest.place_schematic({x=pos.x-1,y=pos.y,z=pos.z-1},schem,0, "air", true) + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) dofile(minetest.get_modpath("mytrouble").."/dice.lua") diff --git a/myuno/init.lua b/myuno/init.lua index beeb2e0..d096f67 100644 --- a/myuno/init.lua +++ b/myuno/init.lua @@ -229,11 +229,18 @@ end, drawtype = "normal", paramtype = "light", groups = {oddly_breakable_by_hand = 1}, -on_rightclick = function(pos, node, player, itemstack, pointed_thing) -local schem = minetest.get_modpath("myuno").."/schems/myuno.mts" - minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) - count = 0 -end, + on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local schem = minetest.get_modpath("myuno").."/schems/myuno.mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z},schem,0, "air", true) + count = 0 + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and minetest.check_player_privs(placer:get_player_name(), {myboardgames = true}) then + else + minetest.remove_node(pos) + return true + end + end, }) minetest.register_node("myuno:placer",{