From b21c3d368077aa3a1c42ff1582cda6263c018585 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Wed, 6 Mar 2019 17:01:02 -0500 Subject: updated cottages, areasprotector, bees, biome_lib, technic, facade, farming redo, homedecor, maptools, mesecons, moreblocks, moreores, pipeworks, quartz, travelnet, unified_inventory, unifieddyes, xban2 delete the playeranim mod, not 5.0.0 compatible. --- cottages/functions.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cottages/functions.lua (limited to 'cottages/functions.lua') diff --git a/cottages/functions.lua b/cottages/functions.lua new file mode 100644 index 0000000..81d88bc --- /dev/null +++ b/cottages/functions.lua @@ -0,0 +1,42 @@ + +local S = cottages.S + +--- if no owner is set, all players may use the node; else only the owner +cottages.player_can_use = function( meta, player ) + if( not( player) or not( meta )) then + return false; + end + local pname = player:get_player_name(); + local owner = meta:get_string('owner' ); + local public = meta:get_string('public') + if( not(owner) or owner=="" or owner==pname or public=="public") then + return true; + end + return false; +end + + +-- call this in on_receive_fields and add suitable buttons in order +-- to switch between public and private use +cottages.switch_public = function(pos, formname, fields, sender, name_of_the_thing) + -- switch between public and private + local meta = minetest.get_meta(pos) + local public = meta:get_string("public") + local owner = meta:get_string("owner") + if( sender and sender:get_player_name() == owner and fields.public) then + if( public ~= "public") then + meta:set_string("public", "public") + meta:set_string("infotext", + S("Public "..name_of_the_thing.." (owned by %s)"):format(owner)) + minetest.chat_send_player(owner, + S("Your "..name_of_the_thing.." can now be used by other players as well.")) + else + meta:set_string("public", "") + meta:set_string("infotext", + S("Private "..name_of_the_thing.." (owned by %s)"):format(owner)) + minetest.chat_send_player(owner, + S("Your "..name_of_the_thing.." can only be used by yourself.")) + end + return true + end +end -- cgit v1.2.3