From 9e8c58895e949612ddef1fc789e1ad1cd10eaf7a Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Mon, 18 Aug 2014 22:33:28 -0400 Subject: [PATCH] Add slightly reduced and rewritten version of mushroom mod by Dan Duncombe and I, with tweaks added to make mushrooms able to spawn on woodsoils grass/dirt with leaves. Rewrites are just to make the ABMs a little lighter-weight, but they should still function the same as before. This mod does not hook into the map generator. --- mushroom/compat.lua | 41 ++++ mushroom/crafting.lua | 91 +++++++ mushroom/depends.txt | 3 + mushroom/init.lua | 262 +++++++++++++++++++++ mushroom/textures/mushroom_brown.png | Bin 0 -> 262 bytes mushroom/textures/mushroom_essence.png | Bin 0 -> 323 bytes mushroom/textures/mushroom_identifier.png | Bin 0 -> 268 bytes mushroom/textures/mushroom_poison.png | Bin 0 -> 283 bytes mushroom/textures/mushroom_red.png | Bin 0 -> 245 bytes mushroom/textures/mushroom_spore.png | Bin 0 -> 205 bytes mushroom/textures/mushroom_spore_brown.png | Bin 0 -> 205 bytes mushroom/textures/mushroom_spore_red.png | Bin 0 -> 205 bytes 12 files changed, 397 insertions(+) create mode 100644 mushroom/compat.lua create mode 100644 mushroom/crafting.lua create mode 100644 mushroom/depends.txt create mode 100644 mushroom/init.lua create mode 100644 mushroom/textures/mushroom_brown.png create mode 100644 mushroom/textures/mushroom_essence.png create mode 100644 mushroom/textures/mushroom_identifier.png create mode 100644 mushroom/textures/mushroom_poison.png create mode 100644 mushroom/textures/mushroom_red.png create mode 100644 mushroom/textures/mushroom_spore.png create mode 100644 mushroom/textures/mushroom_spore_brown.png create mode 100644 mushroom/textures/mushroom_spore_red.png diff --git a/mushroom/compat.lua b/mushroom/compat.lua new file mode 100644 index 0000000..c7a1009 --- /dev/null +++ b/mushroom/compat.lua @@ -0,0 +1,41 @@ + +-- Redefine grass and dirt nodes + +minetest.override_item("default:dirt", { + drop = { + max_items = 2, + items = { + { + items = {"mushroom:spore1"}, + rarity = 40, + }, + { + items = {"mushroom:spore2"}, + rarity = 40, + }, + { + items = {"default:dirt"}, + } + } + } +}) + +minetest.override_item("default:dirt_with_grass", { + drop = { + max_items = 2, + items = { + { + items = {"mushroom:spore1"}, + rarity = 40, + }, + { + items = {"mushroom:spore2"}, + rarity = 40, + }, + { + items = {"default:dirt"}, + } + } + } +}) + diff --git a/mushroom/crafting.lua b/mushroom/crafting.lua new file mode 100644 index 0000000..b05762b --- /dev/null +++ b/mushroom/crafting.lua @@ -0,0 +1,91 @@ +-- craft items + +minetest.register_craftitem("mushroom:spore1",{ + description = "Unidentified Mushroom Spore", + inventory_image = "mushroom_spore.png", + wield_image = "mushroom_spore.png", +}) + +minetest.register_craftitem("mushroom:spore2",{ + description = "Unidentified Mushroom Spore", + inventory_image = "mushroom_spore.png", + wield_image = "mushroom_spore.png", +}) + +minetest.register_craftitem("mushroom:identifier",{ + description = "Mushroom Spore Identifier/Spore Extractor", + inventory_image = "mushroom_identifier.png", + wield_image = "mushroom_identifier.png", +}) + +minetest.register_craftitem("mushroom:brown_essence",{ + description = "Healthy Brown Mushroom Essence", + inventory_image = "mushroom_essence.png", + wield_image = "mushroom_essence.png", + on_use = minetest.item_eat(10), +}) + +minetest.register_craftitem("mushroom:poison",{ + description = "Red Mushroom Poison", + inventory_image = "mushroom_poison.png", + wield_image = "mushroom_poison.png", + on_use = minetest.item_eat(-10), +}) + +-- recipes + +minetest.register_craft( { + output = "mushroom:identifier", + recipe = { + { "", "default:torch", "" }, + { "default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot" }, + } +}) + +minetest.register_craft( { + type = "shapeless", + output = "mushroom:brown_essence", + recipe = { "mushroom:brown" , "vessels:glass_bottle" }, +}) + +minetest.register_craft( { + type = "shapeless", + output = "mushroom:poison", + recipe = { "mushroom:red" , "vessels:glass_bottle" }, +}) + +minetest.register_craft( { + type = "shapeless", + output = "mushroom:spore_brown", + recipe = { "mushroom:identifier" , "mushroom:spore1" }, + replacements = { + { 'mushroom:identifier', 'mushroom:identifier' } + } +}) + +minetest.register_craft( { + type = "shapeless", + output = "mushroom:spore_red", + recipe = { "mushroom:identifier" , "mushroom:spore2" }, + replacements = { + { 'mushroom:identifier', 'mushroom:identifier' } + } +}) + +minetest.register_craft( { + type = "shapeless", + output = "mushroom:spore_red 2", + recipe = { "mushroom:identifier" , "mushroom:red" }, + replacements = { + { 'mushroom:identifier', 'mushroom:identifier' } + } +}) + +minetest.register_craft( { + type = "shapeless", + output = "mushroom:spore_brown 2", + recipe = { "mushroom:identifier" , "mushroom:brown" }, + replacements = { + { 'mushroom:identifier', 'mushroom:identifier' } + } +}) diff --git a/mushroom/depends.txt b/mushroom/depends.txt new file mode 100644 index 0000000..0a3c3f8 --- /dev/null +++ b/mushroom/depends.txt @@ -0,0 +1,3 @@ +default +vessels? +woodsoils? diff --git a/mushroom/init.lua b/mushroom/init.lua new file mode 100644 index 0000000..c895291 --- /dev/null +++ b/mushroom/init.lua @@ -0,0 +1,262 @@ + +-- Mushroom mod by DanDuncombe and VanessaE +-- +-- License: CC-By-SA for texures derived from Minetest defaults, +-- WTFPL for all code and everything else. + +mushroom = {} + +minetest.register_node("mushroom:brown",{ + description = "Brown Mushroom", + drawtype = "plantlike", + sunlight_propagates = true, + tiles = {"mushroom_brown.png"}, + inventory_image = "mushroom_brown.png", + wield_image = "mushroom_brown.png", + groups = {oddly_breakable_by_hand=3,attached_node=1}, + paramtype = "light", + walkable = false, + on_use = minetest.item_eat(5), + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3} + }, + drop = "mushroom:brown", +}) + +minetest.register_node("mushroom:red",{ + description = "Red Mushroom", + drawtype = "plantlike", + sunlight_propagates = true, + tiles = {"mushroom_red.png"}, + inventory_image = "mushroom_red.png", + wield_image = "mushroom_red.png", + groups = {oddly_breakable_by_hand=3,attached_node=1}, + paramtype = "light", + walkable = false, + on_use = minetest.item_eat(-5), + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3} + }, + drop = "mushroom:red", +}) + +minetest.register_node("mushroom:spore_brown",{ + description = "Brown Mushroom Spore", + drawtype = "raillike", + paramtype = "light", + tiles = {"mushroom_spore_brown.png"}, + sunlight_propagates = true, + walkable = false, + groups = {oddly_breakable_by_hand=3,attached_node=1}, + inventory_image = "mushroom_spore_brown.png", + wield_image = "mushroom_spore_brown.png", + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5} + }, +}) + +minetest.register_node("mushroom:spore_red",{ + description = "Red Mushroom Spore", + drawtype = "raillike", + paramtype = "light", + tiles = {"mushroom_spore_red.png"}, + sunlight_propagates = true, + walkable = false, + groups = {oddly_breakable_by_hand=3,attached_node=1}, + inventory_image = "mushroom_spore_red.png", + wield_image = "mushroom_spore_red.png", + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5} + }, +}) + +--Natural Mushrooms + +minetest.register_node("mushroom:brown_natural",{ + description = "Brown Mushroom (Naturally Spawned)", + drawtype = "plantlike", + sunlight_propagates = true, + tiles = {"mushroom_brown.png"}, + inventory_image = "mushroom_brown.png", + wield_image = "mushroom_brown.png", + groups = {oddly_breakable_by_hand=3}, + paramtype = "light", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3} + }, + drop = "mushroom:brown", +}) + +minetest.register_node("mushroom:red_natural",{ + description = "Red Mushroom (Naturally Spawned)", + drawtype = "plantlike", + sunlight_propagates = true, + tiles = {"mushroom_red.png"}, + inventory_image = "mushroom_red.png", + wield_image = "mushroom_red.png", + groups = {oddly_breakable_by_hand=3}, + paramtype = "light", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3} + }, + drop = "mushroom:red", +}) + +-- Spore Growing ABMs + +minetest.register_abm({ + nodenames = {"mushroom:spore_brown"}, + neighbors = {"air"}, + interval = 120, + chance = 4, + action = function(pos, node) + local soil = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + if (soil.name == "farming:soil_wet" or string.find(soil.name, "homedecor:flower_pot_")) + and minetest.get_node_light(pos, nil) < 8 then + minetest.add_node({x=pos.x,y=pos.y,z=pos.z}, {name="mushroom:brown"}) + end + end +}) + +minetest.register_abm({ + nodenames = {"mushroom:spore_red"}, + neighbors = {"air"}, + interval = 120, + chance = 4, + action = function(pos, node) + local soil = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + if (soil.name == "farming:soil_wet" or string.find(soil.name, "homedecor:flower_pot_")) + and minetest.get_node_light(pos, nil) < 8 then + minetest.add_node({x=pos.x,y=pos.y,z=pos.z}, {name="mushroom:red"}) + end + end +}) + +-- list of trees that mushrooms can grow next to + +local trees_list = { + "default:tree", + "default:jungletree", + "moretrees:apple_tree_trunk", + "moretrees:beech_trunk", + "moretrees:birch_trunk", + "moretrees:fir_trunk", + "moretrees:oak_trunk", + "moretrees:pine_trunk", + "moretrees:rubber_tree_trunk", + "moretrees:rubber_tree_trunk_empty", + "moretrees:sequoia_trunk", + "moretrees:spruce_trunk", + "moretrees:willow_trunk", +} + +-- Natural Spawning ABM + +minetest.register_abm({ + nodenames = { + "default:dirt_with_grass", + "default:dirt", + "woodsoils:dirt_with_leaves_1", + "woodsoils:dirt_with_leaves_2", + "woodsoils:grass_with_leaves_1", + "woodsoils:grass_with_leaves_2", + "farming:soil_wet" + }, + neighbors = {"air"}, + interval = 300, + chance = 100, + action = function(pos, node) + local top_pos = {x=pos.x, y=pos.y+1, z=pos.z} + if minetest.get_node(top_pos).name == "air" and minetest.get_node_light(top_pos, nil) < 8 + and minetest.find_node_near(pos, 1, trees_list) + and minetest.find_node_near(pos, 3, "default:water_source") then + if math.random(0, 1) == 0 then + minetest.add_node(top_pos, {name="mushroom:brown_natural"}) + else + minetest.add_node(top_pos, {name="mushroom:red_natural"}) + end + end + end +}) + +minetest.register_abm({ + nodenames = {"default:stone"}, + neighbors = {"air"}, + interval = 300, + chance = 100, + action = function(pos, node) + local top_pos = {x=pos.x, y=pos.y+1, z=pos.z} + if minetest.get_node(top_pos).name == "air" and minetest.get_node_light(top_pos, nil) < 8 + and minetest.find_node_near(pos, 1, {"default:water_source"}) then + if math.random(0,1) == 0 then + minetest.add_node(top_pos, {name="mushroom:brown_natural"}) + else + minetest.add_node(top_pos, {name="mushroom:red_natural"}) + end + end + end +}) + +-- Spreading ABM + +minetest.register_abm({ + nodenames = { + "mushroom:brown_natural", + "mushroom:red_natural" + }, + neighbors = {"air"}, + interval = 120, + chance = 100, + action = function(pos, node) + local soil_pos = {x=pos.x, y=pos.y-1, z=pos.z} + local soil = minetest.get_node(soil_pos) + local woodsoil_str = "woodsoils:.+_with_leaves_?" + if minetest.get_node_light(pos, nil) < 8 + and minetest.find_node_near(pos, 1, trees_list) then + local spread_x = math.random(-1, 1) + local spread_z = math.random(-1, 1) + local newpos = {x=pos.x+spread_x, y=pos.y, z=pos.z+spread_z} + local newsoil = minetest.get_node({x=newpos.x, y=newpos.y-1, z=newpos.z}) + if minetest.get_node(newpos).name == "air" + and (newsoil.name == "default:dirt_with_grass" + or newsoil.name == "default:dirt" + or string.match(newsoil.name, woodsoil_str)) + and minetest.find_node_near(newpos, 3, "default:water_source") then + minetest.add_node(newpos, {name=node.name}) + end + end + end +}) + +-- Dying ABM + +minetest.register_abm({ + nodenames = { + "mushroom:brown", + "mushroom:red", + }, + neighbors = {"air"}, + interval = 120, + chance = 50, + action = function(pos, node) + local soil = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}) + if soil.name ~= "farming:soil_wet" + and not string.find(soil.name, "homedecor:flower_pot_") then + minetest.remove_node(pos) + end + end +}) + +dofile(minetest.get_modpath("mushroom").."/crafting.lua") +dofile(minetest.get_modpath("mushroom").."/compat.lua") + +print("[Mushrooms] loaded.") + diff --git a/mushroom/textures/mushroom_brown.png b/mushroom/textures/mushroom_brown.png new file mode 100644 index 0000000000000000000000000000000000000000..c8b5bc99a98dd4bea64f917cfec09b92d9fe4430 GIT binary patch literal 262 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqE>1t64!_l=ltB< z)VvY~=c3falGGH1^30M91$R&1fbd2>aiF3^PZ!4!i_^&o60D0GxEchfA6X~V_@4&| z?CbugKS)STDR}+!fX5cb-CivJ4x1=3=d>9l8Z$(G?!W&(Fk=zJnVQL70(Y)*K0-AbW|YuPggqE>;mH9{a5s$ALnJJzX3_EKVmU zNMs!7@cnRaZ}tD3J9kR%0OE+qNXfeYzs`R6dOMu0u&~f=k#F74PfzP5exIIx{(s@h zWTj&p{#QJS_>g%gRO!R~Mj-fTFPT`7K1;A`M%_!_HHimYzDDdQ`g!VqI(O~{t+10; z#}_PFa-`!r>;I3HGbV8R&9nLV|8W-o9x0W_{KhX{y)t@Kz^E)}X7q^j$p8PH9>V`W zN*p-hQM4iX#f}=FDbH1oFg2bza`eEdW5+(cey-n^e}7-1uLncRA;%YG^VWU>dWXT& L)z4*}Q$iB}lv|CA literal 0 HcmV?d00001 diff --git a/mushroom/textures/mushroom_identifier.png b/mushroom/textures/mushroom_identifier.png new file mode 100644 index 0000000000000000000000000000000000000000..5d9d5c9aa3f7a6edf88a475771bc28ad50fd952e GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqE>>YBf!+0N>w!X&C9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y^{|o-U3d7N_q9Ir23aa4hcL|IqVIPx# literal 0 HcmV?d00001 diff --git a/mushroom/textures/mushroom_poison.png b/mushroom/textures/mushroom_poison.png new file mode 100644 index 0000000000000000000000000000000000000000..74891db70b5542dcd159aea89e343430cabc5fb1 GIT binary patch literal 283 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqE>;mH#i}fmO+ca9o-U3d7N?H} z8}c1i;IVO6a{kNk@Bi#Hwaw+v)I3xVmpVCRIW6$^x8h{9`+b1zAFt(Y6XR7{A)@Cj zWqux*S61_p$Z1ZRgQ$DgeiV5@(aHbbu9bI+f19-4FcF0;Rr WDc;p!X~PV3CWEJ|pUXO@geCx`t7H}c literal 0 HcmV?d00001 diff --git a/mushroom/textures/mushroom_red.png b/mushroom/textures/mushroom_red.png new file mode 100644 index 0000000000000000000000000000000000000000..cea95f56322290e2df47cc203b2cec53369ea20f GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqE>aiF3APZ!4!i_>rW4{{zb;9=IkTd&FgL~`AH zDW6P*$}iKIn+2y$cv$d5*wIm0dia01H4vW`50q3fMzpzy85}Sb4q9e05?KRGynhq literal 0 HcmV?d00001 diff --git a/mushroom/textures/mushroom_spore.png b/mushroom/textures/mushroom_spore.png new file mode 100644 index 0000000000000000000000000000000000000000..584c3f736bf5c8b56f5f9cd0c3df20578ae83338 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqE>>Yt!I=7Kyg(tz64!_l=ltB< z)VvY~=c3falGGH1^30M91$R&1fbd2>aiAg%PZ!4!i_^&o689eb2ZERR3RiPw7cqME oJaUu^dvQ+sSm5ac2M#bW6mrQwWO(_L2dIa^)78&qol`;+0NDsVo&W#< literal 0 HcmV?d00001 diff --git a/mushroom/textures/mushroom_spore_brown.png b/mushroom/textures/mushroom_spore_brown.png new file mode 100644 index 0000000000000000000000000000000000000000..22bc9d9a080966920590ab84866dbac4fbf35710 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqE>>Y>d86A}^*|xX64!_l=ltB< z)VvY~=c3falGGH1^30M91$R&1fbd2>aiAg%PZ!4!i_^&o689cdF&(b|CGAlf-Ja1P pw76nIyXdaZZG~5i3=9ky7?yVlZZ!B)J{PEm!PC{xWt~$(699DYI@16E literal 0 HcmV?d00001 diff --git a/mushroom/textures/mushroom_spore_red.png b/mushroom/textures/mushroom_spore_red.png new file mode 100644 index 0000000000000000000000000000000000000000..b1537ccf2cf987def85a98bc72d084564e8fe1c8 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqE>>Y>tIGTTEPz6iC9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y^_jo-U3d7N?UFB*o pXmQ1acF|p*+X}B385kHaFj)2Se-zdD^bx3s!PC{xWt~$(69C0_J3s&c literal 0 HcmV?d00001