From 20258fe826566d973c9aee8c841c469a998ade08 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Mon, 8 Oct 2018 13:40:31 +0100 Subject: [PATCH] fix global check, add 9x lucky blocks, smoker has 200 uses --- depends.txt | 1 + init.lua | 109 ++++++++++++++++++++++++++++++++++++---------------- readme.txt | 2 + 3 files changed, 79 insertions(+), 33 deletions(-) diff --git a/depends.txt b/depends.txt index 9207dab..53a9e75 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@ default intllib? +lucky_block? diff --git a/init.lua b/init.lua index 95ff21e..45490a5 100644 --- a/init.lua +++ b/init.lua @@ -5,7 +5,7 @@ -- Intllib support local S -if intllib then +if minetest.global_exists('intllib') then S = intllib.Getter() else S = function(s) return s end @@ -253,7 +253,12 @@ minetest.register_node('bees:bees', { damage_per_second = 1, walkable = false, buildable_to = true, - pointable = false, + selection_box = { + type = 'fixed', + fixed = { + {-0.3, -0.4, -0.3, 0.3, 0.4, 0.3}, + } + }, on_punch = function(pos, node, puncher) @@ -854,39 +859,38 @@ minetest.register_tool('bees:smoker', { damage_groups = {fleshy = 2}, }, - on_use = function(tool, user, node) + on_use = function(itemstack, user, pointed_thing) - if node then - - local pos = node.under - - if pos then - - for i = 1, 6 do - - minetest.add_particle({ - pos = { - x = pos.x + math.random() - 0.5, - y = pos.y, - z = pos.z + math.random() - 0.5 - }, - vel = {x = 0, y = 0.5 + math.random(), z = 0}, - acc = {x = 0, y = 0, z = 0}, - expirationtime = 2 + math.random(2.5), - size = math.random(3), - collisiondetection = false, - texture = 'bees_smoke_particle.png', - }) - end - - --tool:add_wear(2) - local meta = minetest.get_meta(pos) - - meta:set_int('agressive', 0) - - return nil - end + if pointed_thing.type ~= "node" then + return end + + local pos = pointed_thing.under + + for i = 1, 6 do + + minetest.add_particle({ + pos = { + x = pos.x + math.random() - 0.5, + y = pos.y, + z = pos.z + math.random() - 0.5 + }, + vel = {x = 0, y = 0.5 + math.random(), z = 0}, + acc = {x = 0, y = 0, z = 0}, + expirationtime = 2 + math.random(2.5), + size = math.random(3), + collisiondetection = false, + texture = 'bees_smoke_particle.png', + }) + end + + itemstack:add_wear(65535 / 200) + + local meta = minetest.get_meta(pos) + + meta:set_int('agressive', 0) + + return itemstack end, }) @@ -1195,4 +1199,43 @@ if minetest.get_modpath("pipeworks") then end +-- LUCKY BLOCKS + +if minetest.get_modpath('lucky_block') then + + local add_bees = function(pos, player) + + local objs = minetest.get_objects_inside_radius(pos, 15) + local violet = minetest.get_color_escape_sequence("#ff00ff") + + minetest.chat_send_player(player:get_player_name(), + violet .. S("Bees! Bees for all!")) + + for n = 1, #objs do + + if objs[n]:is_player() then + + local player_pos = objs[n]:get_pos() + + player_pos.y = player_pos.y + 1 + + minetest.swap_node(player_pos, {name = 'bees:bees'}) + end + end + end + + lucky_block:add_blocks({ + {'cus', add_bees}, + {'dro', {'bees:grafting_tool'}, 1}, + {'dro', {'bees:frame_empty'}, 2}, + {'dro', {'bees:queen'}, 1}, + {'nod', 'bees:extractor'}, + {'dro', {'bees:frame_full'}, 2}, + {'dro', {'bees:bottle_honey'}, 3}, + {'dro', {'bees:smoker'}, 1}, + {'nod', 'bees:hive_artificial'}, + }) +end + + print(S('[MOD] Bees Loaded!')) diff --git a/readme.txt b/readme.txt index 0920e0f..5c2636f 100644 --- a/readme.txt +++ b/readme.txt @@ -12,6 +12,8 @@ FEATURES - Change compatibility abm to lbm - Change from WTFPL to MIT license - Make wild hive abm less intensive (thanks VanessaE) +- Added 9x Lucky Blocks +- Smokers have 200 uses before breaking 2.2.2 - Pipeworks compatibility (Industrial beehive)