From e630074a9f35cb0d79bcc8a9e174041a735ad72e Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Mon, 9 Oct 2017 12:16:07 +0100 Subject: [PATCH] updated to newer 0.4.16 functions --- README.md | 3 ++- init.lua | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 18241c0..de452d9 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,9 @@ Changelog: - 0.1 - Initial release - 0.2 - Added global on_use function for bonemeal growth -- 0.3 - Added strength to on_use global for new items (mulch and fertiliser). +- 0.3 - Added strength to on_use global for new items (mulch and fertiliser) - 0.4 - Added Intllib support and fr.txt file - 0.5 - Added support for default bush and acacia bush saplings +- 0.6 - Using newer functions, Minetest 0.4.16 and above needed to run Lucky Blocks: 2 diff --git a/init.lua b/init.lua index 6552f0d..9e8b175 100644 --- a/init.lua +++ b/init.lua @@ -6,6 +6,13 @@ local MP = minetest.get_modpath(minetest.get_current_modname()) local S, NS = dofile(MP .. "/intllib.lua") +-- creative check +local creative_mode_cache = minetest.settings:get_bool("creative_mode") +function is_creative(name) + return creative_mode_cache or minetest.check_player_privs(name, {creative = true}) +end + + -- default crops local crops = { {"farming:cotton_", 8, "farming:seed_cotton"}, @@ -347,7 +354,7 @@ minetest.register_craftitem("bonemeal:mulch", { end -- take item if not in creative - if not minetest.setting_getbool("creative_mode") then + if not is_creative(user:get_player_name()) then itemstack:take_item() end @@ -376,7 +383,7 @@ minetest.register_craftitem("bonemeal:bonemeal", { end -- take item if not in creative - if not minetest.setting_getbool("creative_mode") then + if not is_creative(user:get_player_name()) then itemstack:take_item() end @@ -406,7 +413,7 @@ minetest.register_craftitem("bonemeal:fertiliser", { end -- take item if not in creative - if not minetest.setting_getbool("creative_mode") then + if not is_creative(user:get_player_name()) then itemstack:take_item() end