summaryrefslogtreecommitdiff
path: root/cottages/functions.lua
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-03-06 17:01:02 -0500
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-03-06 17:01:02 -0500
commitb21c3d368077aa3a1c42ff1582cda6263c018585 (patch)
tree4053ef589ef5c5b99f0a87b567207e8c52cf4c76 /cottages/functions.lua
parentec25fd83415d0ecb49f41295af3dc30f14850b2f (diff)
downloaddreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar.gz
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar.bz2
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.tar.xz
dreambuilder_modpack-b21c3d368077aa3a1c42ff1582cda6263c018585.zip
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.
Diffstat (limited to 'cottages/functions.lua')
-rw-r--r--cottages/functions.lua42
1 files changed, 42 insertions, 0 deletions
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