summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chatcommands.lua11
-rw-r--r--chest.lua92
-rw-r--r--init.lua2
3 files changed, 99 insertions, 6 deletions
diff --git a/chatcommands.lua b/chatcommands.lua
index d452b63..458522b 100644
--- a/chatcommands.lua
+++ b/chatcommands.lua
@@ -104,7 +104,7 @@ minetest.register_chatcommand("unsharearea", {
minetest.chat_send_player(name, param.." may no longer edit this area.")
minetest.chat_send_player(param, name.." has just revoked your editing privileges in an area.")
else
- minetest.chat_send_player(name, 'Use "/unclaim" to unclaim the aria.')
+ minetest.chat_send_player(name, 'Use "/unclaim" to unclaim the area.')
end
else
minetest.chat_send_player(name, "This area is owned by "..owner)
@@ -193,8 +193,7 @@ minetest.register_chatcommand("unshareall", {
description = "unshares all your landclaims with <name>",
privs = {interact=true},
func = function(name, param)
-
- if minetest.env:get_player_by_name(param) then
+ if name ~= param then
local qdone = 0
for k,v in pairs(claims) do
if claims[k].owner == name then
@@ -206,14 +205,14 @@ minetest.register_chatcommand("unshareall", {
landrush.save_claims()
if qdone > 0 then
- minetest.chat_send_player(name, param.." no longer may edit all of your areas.")
+ minetest.chat_send_player(name, param.." may no longer edit any of your areas.")
minetest.chat_send_player(name, qdone.." total areas were unshared.")
minetest.chat_send_player(param, name.." has just unshared all of their areas with you.")
else
- minetest.chat_send_player(name, param.." had noting changed. You may not own any land.")
+ minetest.chat_send_player(name, param.." had no permissions being revoked. You may not own any land.")
end
else
- minetest.chat_send_player(name, param.." is not a valid player. Player must be online to unshare.")
+ minetest.chat_send_player(name, 'Use "/unclaim" to unclaim any of your areas.')
end
end,
})
diff --git a/chest.lua b/chest.lua
new file mode 100644
index 0000000..a328f6b
--- /dev/null
+++ b/chest.lua
@@ -0,0 +1,92 @@
+-- add a special chest that is shared among the land-possesors
+
+minetest.register_node("landrush:shared_chest", {
+ description = "Land Rush Shared Chest",
+ tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
+ groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
+ legacy_facedir_simple = true,
+ sounds = default.node_sound_wood_defaults(),
+
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ return inv:is_empty("main")
+ end,
+
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec",default.chest_formspec)
+ meta:set_string("infotext", "Shared Chest")
+ local inv = meta:get_inventory()
+ inv:set_size("main", 8*4)
+ end,
+
+ allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ local meta = minetest.get_meta(pos)
+ if not landrush.can_interact(player:get_player_name(),pos) then
+ minetest.log("action", player:get_player_name() .. " tried to access a shared chest at ".. minetest.pos_to_string(pos))
+ return 0
+ end
+ return count
+ end,
+
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ if not landrush.can_interact(player:get_player_name(),pos) then
+ minetest.log("action", player:get_player_name() .. " tried to access a shared chest at ".. minetest.pos_to_string(pos))
+ return 0
+ end
+ return stack:get_count()
+ end,
+
+ allow_metadata_inventory_take = function(pos, listname, index, stack, player)
+ local meta = minetest.get_meta(pos)
+ if not landrush.can_interact(player:get_player_name(),pos) then
+ minetest.log("action", player:get_player_name()..
+ " tried to access a shared chest at "..
+ minetest.pos_to_string(pos))
+ return 0
+ end
+ return stack:get_count()
+ end,
+
+ on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ minetest.log("action", player:get_player_name()..
+ " moves stuff in shared chest at "..minetest.pos_to_string(pos))
+ end,
+
+ on_metadata_inventory_put = function(pos, listname, index, stack, player)
+ minetest.log("action", player:get_player_name()..
+ " puts stuff into shared chest at "..minetest.pos_to_string(pos))
+ end,
+
+ on_metadata_inventory_take = function(pos, listname, index, stack, player)
+ minetest.log("action", player:get_player_name()..
+ " takes stuff from shared chest at "..minetest.pos_to_string(pos))
+ end,
+
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ local meta = minetest.env:get_meta(pos)
+ local inventory = meta:get_inventory()
+ return inventory:add_item("main",stack)
+ end,
+
+ can_insert = function(pos, node, stack, direction)
+ local meta=minetest.env:get_meta(pos)
+ local inventory = meta:get_inventory()
+ return inventory:room_for_item("main",stack)
+ end,
+ input_inventory="main",
+ connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
+ }
+})
+
+minetest.register_craft({
+ output = 'landrush:shared_chest',
+ recipe = {
+ {'default:wood','default:wood','default:wood'},
+ {'default:wood','landrush:landclaim','default:wood'},
+ {'default:wood','default:wood','default:wood'}
+ }
+}) \ No newline at end of file
diff --git a/init.lua b/init.lua
index 75edaa7..2aed384 100644
--- a/init.lua
+++ b/init.lua
@@ -524,6 +524,8 @@ if ( minetest.get_modpath("money2") ) then
dofile(path.."/landsale.lua")
end
+dofile(path.."/chest.lua")
+
minetest.after(0, function ()
dofile(path.."/default.lua")