From c4416c04777b0ac04044ea8c5ac817648ce987b9 Mon Sep 17 00:00:00 2001 From: bas080 Date: Thu, 5 Jun 2014 01:03:09 +0200 Subject: [PATCH] added extractor and smoker. Changed stack_max and added particles --- init.lua | 251 ++++++++++++++---- readme.txt | 9 +- ...honey_bottle.png => bees_bottle_honey.png} | Bin textures/bees_frame_empty.png | Bin 658 -> 642 bytes textures/bees_smoke_particle.png | Bin 0 -> 378 bytes textures/bees_smoker.png | Bin 0 -> 697 bytes textures/bees_wax.png | Bin 0 -> 502 bytes textures/bees_wax_particle.png | Bin 0 -> 255 bytes 8 files changed, 211 insertions(+), 49 deletions(-) rename textures/{bees_honey_bottle.png => bees_bottle_honey.png} (100%) create mode 100644 textures/bees_smoke_particle.png create mode 100644 textures/bees_smoker.png create mode 100644 textures/bees_wax.png create mode 100644 textures/bees_wax_particle.png diff --git a/init.lua b/init.lua index 0e564b4..bd2b5aa 100644 --- a/init.lua +++ b/init.lua @@ -1,19 +1,21 @@ --Bees ------ --Author Bas080 ---Version 2.0 +--Version 2.2 --License WTFPL ---[[TODO - smoker maybe - Spreading bee colonies - x Grafting Tool - to remove queen bees from wild hives - x Make flowers reproduce when near a hive - x Add formspec to twild hive when using grafting tool -]] +--FEATURES + --pipeworks industrial hive + --more realistic colonie spreading + --x sweet particles bra + --x smokers to calm down the bees before opening the hive + --x frame honey and wax extractor + --x spreading bee colonies + --x grafting tool - to remove queen bees from wild hives + --x Make flowers reproduce when near a hive + --x Add formspec to twild hive when using grafting tool + --VARIABLES - local sound = {} - local particles = {} local bees = {} local formspecs = {} @@ -51,10 +53,87 @@ end --NODES + minetest.register_node('bees:honey_extractor', { + description = 'honey extractor', + tiles = {'default_wood.png'}, + on_construct = function(pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local pos = pos.x..','..pos.y..','..pos.z + inv:set_size('frames_filled' ,1) + inv:set_size('frames_emptied' ,1) + inv:set_size('bottles_empty' ,1) + inv:set_size('bottles_full' ,1) + inv:set_size('wax',1) + meta:set_string('formspec', + 'size[8,9]'.. + --input + 'list[nodemeta:'..pos..';frames_filled;2,1;1,1;]'.. + 'list[nodemeta:'..pos..';bottles_empty;2,3;1,1;]'.. + --output + 'list[nodemeta:'..pos..';frames_emptied;5,0.5;1,1;]'.. + 'list[nodemeta:'..pos..';wax;5,2;1,1;]'.. + 'list[nodemeta:'..pos..';bottles_full;5,3.5;1,1;]'.. + --player inventory + 'list[current_player;main;0,5;8,4;]' + ) + end, + on_timer = function(pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if not inv:contains_item('frames_filled','bees:frame_full') and not inv:contains_item('bottles_empty','vessels:glass_bottle') then + return + end + if inv:room_for_item('frames_emptied', 'bees:frame_empty') + and inv:room_for_item('wax','bees:wax') + and inv:room_for_item('bottles_full', 'bees:bottle_honey') --output ok + and inv:contains_item('frames_filled','bees:frame_full') + and inv:contains_item('bottles_empty', 'vessels:glass_bottle') then --input ok + --add to output + inv:add_item('frames_emptied', 'bees:frame_empty') + inv:add_item('wax', 'bees:wax') + inv:add_item('bottles_full', 'bees:bottle_honey') + --remove from input + inv:remove_item('bottles_empty','vessels:glass_bottle') + inv:remove_item('frames_filled','bees:frame_full') + local p = {x=pos.x+math.random()-0.5, y=pos.y+math.random()-0.5, z=pos.z+math.random()-0.5} + --wax flying all over the place + minetest.add_particle({ + pos = {x=pos.x, y=pos.y, z=pos.z}, + vel = {x=math.random(-4,4),y=math.random(8),z=math.random(-4,4)}, + acc = {x=0,y=-6,z=0}, + expirationtime = 2, + size = math.random(1,3), + collisiondetection = false, + texture = 'bees_wax_particle.png', + }) + local timer = minetest.get_node_timer(pos) + timer:start(5) + end + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + local timer = minetest.get_node_timer(pos) + timer:start(5) --create a honey bottle and empty frame and wax every 5 seconds + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + local timer = minetest.get_node_timer(pos) + timer:start(5) --create a honey bottle and empty frame and wax every 5 seconds + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + print(listname..stack:get_name()) + if listname == 'bottles_empty' and stack:get_name() == 'vessels:glass_bottle' or listname == 'frames_filled' and stack:get_name() == 'bees:frame_full' then + return stack:get_count() + else + return 0 + end + end + }) + minetest.register_node('bees:bees', { - description = 'Flying Bees', + description = 'flying bees', drawtype = 'plantlike', paramtype = 'light', + groups = { not_in_creative_inventory=1 }, tiles = { { name='bees_strip.png', @@ -124,6 +203,7 @@ local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local timer = minetest.get_node_timer(pos) + meta:set_int('agressive', 1) timer:start(100+math.random(100)) inv:set_size('queen', 1) inv:set_size('combs', 5) @@ -169,6 +249,14 @@ 'bees:hive_artificial', formspecs.hive_wild(pos, (itemstack:get_name() == 'bees:grafting_tool')) ) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if meta:get_int('agressive') == 1 and inv:contains_item('queen', 'bees:queen') then + local health = clicker:get_hp() + clicker:set_hp(health-4) + else + meta:set_int('agressive', 1) + end end, can_dig = function(pos,player) local meta = minetest.get_meta(pos) @@ -191,7 +279,7 @@ }) minetest.register_node('bees:hive_artificial', { - description = 'Bee Hive', + description = 'bee hive', tiles = {'default_wood.png','default_wood.png','default_wood.png', 'default_wood.png','default_wood.png','bees_hive_artificial.png'}, drawtype = 'nodebox', paramtype = 'light', @@ -213,6 +301,7 @@ local timer = minetest.get_node_timer(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() + meta:set_int('agressive', 1) inv:set_size('queen', 1) inv:set_size('frames', 8) meta:set_string('infotext','requires queen bee to function') @@ -223,6 +312,14 @@ 'bees:hive_artificial', formspecs.hive_artificial(pos) ) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if meta:get_int('agressive') == 1 and inv:contains_item('queen', 'bees:queen') then + local health = clicker:get_hp() + clicker:set_hp(health-4) + else + meta:set_int('agressive', 1) + end end, on_timer = function(pos,elapsed) local meta = minetest.get_meta(pos) @@ -243,7 +340,7 @@ bees.polinate_flower(flower, minetest.get_node(flower).name) local stacks = inv:get_list('frames') for k, v in pairs(stacks) do - if inv:get_stack('frames', k):get_name() == 'bees:frame_empty' then --then replace that with a full one and reset pro.. + if inv:get_stack('frames', k):get_name() == 'bees:frame_empty' then meta:set_int('progress', 0) inv:set_stack('frames',k,'bees:frame_full') return @@ -287,6 +384,7 @@ end end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if not minetest.get_meta(pos):get_inventory():get_stack(listname, index):is_empty() then return 0 end if listname == 'queen' then if stack:get_name():match('bees:queen*') then return 1 @@ -301,6 +399,23 @@ }) --ABMS + minetest.register_abm({ --particles + nodenames = {'bees:hive_artificial', 'bees:hive_wild', 'bees:hive_industrial'}, + interval = 10, + chance = 4, + action = function(pos) + minetest.add_particle({ + pos = {x=pos.x, y=pos.y, z=pos.z}, + vel = {x=(math.random()-0.5)*5,y=(math.random()-0.5)*5,z=(math.random()-0.5)*5}, + acc = {x=math.random()-0.5,y=math.random()-0.5,z=math.random()-0.5}, + expirationtime = math.random(2.5), + size = math.random(3), + collisiondetection = true, + texture = 'bees_particle_bee.png', + }) + end, + }) + minetest.register_abm({ --spawn abm. This should be changed to a more realistic type of spawning nodenames = {'group:leaves'}, neighbors = {''}, @@ -341,17 +456,30 @@ minetest.register_craftitem('bees:frame_empty', { description = 'empty hive frame', inventory_image = 'bees_frame_empty.png', - stack_max = 20, + stack_max = 24, }) minetest.register_craftitem('bees:frame_full', { description = 'filled hive frame', inventory_image = 'bees_frame_full.png', - stack_max = 4, + stack_max = 12, + }) + + minetest.register_craftitem('bees:bottle_honey', { + description = 'honey bottle', + inventory_image = 'bees_bottle_honey.png', + stack_max = 12, + on_use = minetest.item_eat(3), + }) + + minetest.register_craftitem('bees:wax', { + description = 'bees wax', + inventory_image = 'bees_wax.png', + stack_max = 48, }) minetest.register_craftitem('bees:honey_comb', { - description = 'Honey Comb', + description = 'honey comb', inventory_image = 'bees_comb.png', on_use = minetest.item_eat(2), stack_max = 8, @@ -385,51 +513,82 @@ minetest.register_craft({ output = 'bees:frame_empty', recipe = { - {'default:wood', 'default:wood', 'default:wood'}, + {'group:wood', 'group:wood', 'group:wood'}, {'default:stick', 'default:stick', 'default:stick'}, {'default:stick', 'default:stick', 'default:stick'}, } }) --TOOLS + minetest.register_tool('bees:smoker', { + description = 'smoker', + inventory_image = 'bees_smoker.png', + tool_capabilities = { + full_punch_interval = 3.0, + max_drop_level=0, + damage_groups = {fleshy=2}, + }, + on_use = function(tool, user, node) + local pos = node.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 + --tool:add_wear(2) + local meta = minetest.get_meta(pos) + meta:set_int('agressive', 0) + return nil + end, + }) + minetest.register_tool('bees:grafting_tool', { - description = 'Grafting Tool', + description = 'grafting tool', inventory_image = 'bees_grafting_tool.png', tool_capabilities = { full_punch_interval = 3.0, max_drop_level=0, - groupcaps={ - choppy = {times={[2]=3.00, [3]=2.00}, uses=10, maxlevel=1}, - }, damage_groups = {fleshy=2}, }, }) ---ALIASES (enable once old nodes have been changed to the new versions) - --minetest.register_alias('bees:hive', 'bees:hive_wild') - --minetest.register_alias('bees:hive_artificial_inhabited', 'bees:hive_artificial') - --COMPATIBILTY --remove after all has been updated - minetest.register_abm({ - nodenames = {'bees:hive', 'bees:hive_artificial_inhabited'}, - interval = 0, - chance = 1, - action = function(pos, node) - if node.name == 'bees:hive' then - minetest.set_node(pos, { name = 'bees:hive_wild' }) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - inv:set_stack('queen', 1, 'bees:queen') - end - if node.name == 'bees:hive_artificial_inhabited' then - minetest.set_node(pos, { name = 'bees:hive_artificial_inhabited' }) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - inv:set_stack('queen', 1, 'bees:queen') - local timer = minetest.get_node_timer(pos) - timer:start(60) - end - end, - }) + --BACKWARDS COMPATIBILITY WITH OLDER VERSION + minetest.register_alias('bees:honey_bottle', 'bees:bottle_honey') + minetest.register_abm({ + nodenames = {'bees:hive', 'bees:hive_artificial_inhabited'}, + interval = 0, + chance = 1, + action = function(pos, node) + if node.name == 'bees:hive' then + minetest.set_node(pos, { name = 'bees:hive_wild' }) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + inv:set_stack('queen', 1, 'bees:queen') + end + if node.name == 'bees:hive_artificial_inhabited' then + minetest.set_node(pos, { name = 'bees:hive_artificial_inhabited' }) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + inv:set_stack('queen', 1, 'bees:queen') + local timer = minetest.get_node_timer(pos) + timer:start(60) + end + end, + }) + + --PIPEWORKS + if false then --todo + minetest.register_node('bees:hive_industrial', { --the hive that is compatible with pipeworks and is only when pipeworks is installed + description = 'industrial hive', + tiles = {}, + }) + end print('[Mod]Bees Loaded!') diff --git a/readme.txt b/readme.txt index b223f74..c10ed28 100644 --- a/readme.txt +++ b/readme.txt @@ -3,23 +3,26 @@ BEES MOD FEATURES -------- +- smoke, flying wax and bee particles +- smokers to calm down the bees before opening the hive +- a centrifuge to extract the honey from the frames - spawn wild bee hives on tree leaves - grab eatable honeycomb from wild hives - craft a grafting tool to extract queen bees from wild hives - craft artificial hives and frames - use the queen bee to populate artificial hives - plant flowers near hives to increase their productivity +- spreading bee colonies +- add formspec to wild and artificial hive when using grafting tool FUTURE ------ -- a centrifuge to extract the honey from the frames - more realistic spawning of wild bee hives -- improved textures - pipeworks compatibility (Industrial beehive) CONTRIBUTORS ------------ -- bas080 (coding) +- bas080 - VanessaE (wild bee hive nodebox) - Neuromancer (textures for wild bee hive and inspiration for other textures) diff --git a/textures/bees_honey_bottle.png b/textures/bees_bottle_honey.png similarity index 100% rename from textures/bees_honey_bottle.png rename to textures/bees_bottle_honey.png diff --git a/textures/bees_frame_empty.png b/textures/bees_frame_empty.png index 1cbf30b557978f14e53ac7db10d8b7f7f4270e72..3ac446a4f475f6273f31a46fca57efa401ad91a2 100644 GIT binary patch delta 520 zcmV+j0{8ur1%d^TUi87jV%v|W*CD1Y5aL_t(I%gvHMXcKW1$3G`Wt~Mq;Q%Mf) zu4!tusbDoBA)+xz5IVW49i%w9Iye-Z1qTOLXBUyKU86Yl8voFxrAs5`j^qN$rPrjr z5OWTa&~Q5In;yUSexLX63;)`LwFd?N2mdA0)V5g%YXHy z3xBOvYaRqU7&^DIx-SRpkM-R8sIgfEIA-hKKe z0Gv8WODa)bz1hTVszlGu0noNYPDhe#tlN}|ScnP+`GLhX7kd@^)PG4hXIgTuvWYP*LRStIW@Xlp_ zC@6rG68)o?cJ?itLwNq$5CFtsAR$lEXt|@rM#~+O^~ufuU-k=)N2OcjoPzHF0000< KMNUMnLSTZAYy9B= delta 537 zcmV+!0_OdK1(F4jUgG0etaBy&Sb`j~?HHuTO@rN!gT^ccWBo|OFz2@2r zG0!O>;dItFJ>K`;_x?WMUmLAIDDrr~^@2!JFFXMN7)mmN39c95>O}OBEtH^MT)BqUcPGZ~flPJNrQrhkgXx#T3lv%4~S;R%idA9O}%t5)TdkthGhKAY(Q z7Yh|K(*y1}0%z0&6nT1*;Q2cbhLXgk1r2;;Q?XE?cHNa)*<%n9*d&K@!2I3MUSmomE*HZWYww+fOiiZ#KfuS7j9nBcz;e!V1A}a zPFIH}+3a+60x}9d*Hx30$#ka2mpj3pvco`w*66Jv+YmFdi?VL bm;DAyz{OK{-2?dm0000QL70(Y)*K0-AbW|YuPggKHWo24!;Sj))qz5iC9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y^`LJzX3_EKbi2KFE7mL7-URy^XQsW*6?; zB^`Yi6c>5ST*U0K`~;iL%mwqAEn6mRo2JxPV3%WICD3D7J}ZjB&&`A9{of;V);Vp< zNDlT0J+ZiEL50q0l|H?H_ciu0bTCxSySTqU!! QfF5MPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i^t* z7BCS>pM1*z000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0006MNkl{%XvJCXhu-(xbIyB3sq~1M*^Km+V-9V7>|$3w%Zl}tE(jzvKh{tJ;z*jp0)K2 z`R?%(a)}8l`>k-j_^eD+*OS7w_oU|g#8p*x+C7qQTQxqsf6nC843*6axx~bXf@ZTx zr2oQo9AdGU49?Rh7kK;T^*~d<3V=xQUJ+eSicY7~BXM0KiV~7+R(GgwR{^N(w+6^8 z%Oa9Jequyg+ja4LU-BP_^jFpE767}uyZr8S2m&5PE-^u}u*`$vLlF&T*J#-EY)Bl( z#rGwi=TWQGWG0gd8v~f8*;5c)7>16js+gvUs>U%49Zk~)UJf!y7M8ho^}6U;kbhOC z(kxHd#H0(ot$6~Q?9~DA`78FInaU7(SxUP%mc_Yoq!ZLSm-wl6lwBN$m*ckP? z#4rqeU!tliM#L8$$RLCM*9S5f4#zO`gIU)B#MXuL_*e31nkMewy2+2t?}G{s!(Pkf zbov2^Id fO=BiAd!)iYu>#h<<3_1H00000NkvXXu0mjfqTnt~ literal 0 HcmV?d00001 diff --git a/textures/bees_wax.png b/textures/bees_wax.png new file mode 100644 index 0000000000000000000000000000000000000000..4891e06d4c6fba330e22b7b02b515a245be4010f GIT binary patch literal 502 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i^t* z6g4uH3oViW00DMML_t(I%iWUCO9D|4$3Jhi0^QQpBoLQiGolV1>mP{fKd1=&13Y!M zv!0@3bPI&&)*lgc=pd+vB2gg(%R_CjR{o0DrIlURg02lb-prf%&V1+1!2gk4O8e0s zr`xykTcX{Kq}*E9WvTThcQ=v}Ad@%Ar8F{m698d@oQ_;dquh+j_)MEwwafkE1kpJk z&8HxVm?{jT20%J%c^T|)F3P*dfLx6~Gplw1SYP{~`4l7+oWL+@)awhwc*RMp+>FY} zsWy=)w0Z$ry#Qf-z}3whiI@sNwJ~rN^xH}%Z*s5`XKy>{3OGKmpvP29t3$hA7r~Iv z-jN8@Ay|*BIR2pM zW{}QWd@8qS+N-b+%8RfkWmg^*G5T;BT8|JKZ(TX0UqxiA1n7e!C(7j`&^y#-;O%>V!Z07*qoM6N<$f_VhiQL70(Y)*K0-AbW|YuPggKHWm>BrLU(?ZUzd~d%8G=Se#By zkYGK`VDM;?h2{On_Pb_OKH_s*#M6*zSN&Wg?C|C&d*eqY51!QY|2OEBm)o3>AvWRf z;R8T0mNQrxYr==$(>}bej&{IFm;G!&;Xs~wHcY9`L p=EHldPiZ`|J*{uRcesUx;rb^nb(@TRXMj#&@O1TaS?83{1OOd!S~CCu literal 0 HcmV?d00001