diff options
author | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2018-10-25 12:14:05 -0400 |
---|---|---|
committer | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2018-10-25 12:14:05 -0400 |
commit | f23603a325cfad46e16550521d4409300af40b49 (patch) | |
tree | 7884df937ec836ac4b79d90ab3ed6e068ed2c60d | |
parent | 9d67dc5e829951b288f266a316c0bce06e9ae66e (diff) | |
download | dreambuilder_modpack-f23603a325cfad46e16550521d4409300af40b49.tar dreambuilder_modpack-f23603a325cfad46e16550521d4409300af40b49.tar.gz dreambuilder_modpack-f23603a325cfad46e16550521d4409300af40b49.tar.bz2 dreambuilder_modpack-f23603a325cfad46e16550521d4409300af40b49.tar.xz dreambuilder_modpack-f23603a325cfad46e16550521d4409300af40b49.zip |
update biome_lib, plantlife (which includes switching
to Tenplus1's vines fork), and moretrees
37 files changed, 642 insertions, 669 deletions
diff --git a/biome_lib/init.lua b/biome_lib/init.lua index 761a57e..2675389 100644 --- a/biome_lib/init.lua +++ b/biome_lib/init.lua @@ -9,6 +9,7 @@ -- Various settings - most of these probably won't need to be changed biome_lib = {} +biome_lib.air = {name = "air"} plantslib = setmetatable({}, { __index=function(t,k) print("Use of deprecated function:", k) return biome_lib[k] end }) @@ -233,7 +234,6 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes, end if surface_ok - and (not checkair or minetest.get_node(p_top).name == "air") and pos.y >= biome.min_elevation and pos.y <= biome.max_elevation and noise1 > biome.plantlife_limit @@ -241,6 +241,7 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes, and noise2 >= biome.temp_max and noise3 <= biome.humidity_min and noise3 >= biome.humidity_max + and (not checkair or minetest.get_node(p_top).name == "air") and (not biome.ncount or #(minetest.find_nodes_in_area({x=pos.x-1, y=pos.y, z=pos.z-1}, {x=pos.x+1, y=pos.y, z=pos.z+1}, biome.neighbors)) > biome.ncount) and (not biome.near_nodes or #(minetest.find_nodes_in_area({x=pos.x-biome.near_nodes_size, y=pos.y-biome.near_nodes_vertical, z=pos.z-biome.near_nodes_size}, {x=pos.x+biome.near_nodes_size, y=pos.y+biome.near_nodes_vertical, z=pos.z+biome.near_nodes_size}, biome.near_nodes)) >= biome.near_nodes_count) and math.random(1,100) > biome.rarity @@ -267,24 +268,24 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes, if not (biome.avoid_nodes and biome.avoid_radius and minetest.find_node_near(p_top, biome.avoid_radius + math.random(-1.5,2), biome.avoid_nodes)) then if biome.delete_above then - minetest.remove_node(p_top) - minetest.remove_node({x=p_top.x, y=p_top.y+1, z=p_top.z}) + minetest.swap_node(p_top, biome_lib.air) + minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z}, biome_lib.air) end if biome.delete_above_surround then - minetest.remove_node({x=p_top.x-1, y=p_top.y, z=p_top.z}) - minetest.remove_node({x=p_top.x+1, y=p_top.y, z=p_top.z}) - minetest.remove_node({x=p_top.x, y=p_top.y, z=p_top.z-1}) - minetest.remove_node({x=p_top.x, y=p_top.y, z=p_top.z+1}) - - minetest.remove_node({x=p_top.x-1, y=p_top.y+1, z=p_top.z}) - minetest.remove_node({x=p_top.x+1, y=p_top.y+1, z=p_top.z}) - minetest.remove_node({x=p_top.x, y=p_top.y+1, z=p_top.z-1}) - minetest.remove_node({x=p_top.x, y=p_top.y+1, z=p_top.z+1}) + minetest.swap_node({x=p_top.x-1, y=p_top.y, z=p_top.z}, biome_lib.air) + minetest.swap_node({x=p_top.x+1, y=p_top.y, z=p_top.z}, biome_lib.air) + minetest.swap_node({x=p_top.x, y=p_top.y, z=p_top.z-1}, biome_lib.air) + minetest.swap_node({x=p_top.x, y=p_top.y, z=p_top.z+1}, biome_lib.air) + + minetest.swap_node({x=p_top.x-1, y=p_top.y+1, z=p_top.z}, biome_lib.air) + minetest.swap_node({x=p_top.x+1, y=p_top.y+1, z=p_top.z}, biome_lib.air) + minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z-1}, biome_lib.air) + minetest.swap_node({x=p_top.x, y=p_top.y+1, z=p_top.z+1}, biome_lib.air) end if biome.spawn_replace_node then - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) end local objtype = type(nodes_or_function_or_model) @@ -298,7 +299,7 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes, if biome.random_facedir then fdir = math.random(biome.random_facedir[1], biome.random_facedir[2]) end - minetest.set_node(p_top, { name = nodes_or_function_or_model[math.random(#nodes_or_function_or_model)], param2 = fdir }) + minetest.swap_node(p_top, { name = nodes_or_function_or_model[math.random(#nodes_or_function_or_model)], param2 = fdir }) spawned = true end elseif objtype == "string" and @@ -307,7 +308,7 @@ function biome_lib:populate_surfaces(biome, nodes_or_function_or_model, snodes, if biome.random_facedir then fdir = math.random(biome.random_facedir[1], biome.random_facedir[2]) end - minetest.set_node(p_top, { name = nodes_or_function_or_model, param2 = fdir }) + minetest.swap_node(p_top, { name = nodes_or_function_or_model, param2 = fdir }) spawned = true elseif objtype == "function" then nodes_or_function_or_model(pos) @@ -529,7 +530,7 @@ function biome_lib:spawn_on_surfaces(sd,sp,sr,sc,ss,sa) local walldir = biome_lib:find_adjacent_wall(p_top, biome.verticals_list, biome.choose_random_wall) if biome.alt_wallnode and walldir then if n_top.name == "air" then - minetest.set_node(p_top, { name = biome.alt_wallnode, param2 = walldir }) + minetest.swap_node(p_top, { name = biome.alt_wallnode, param2 = walldir }) end else local currentsurface = minetest.get_node(pos).name @@ -546,19 +547,19 @@ function biome_lib:spawn_on_surfaces(sd,sp,sr,sc,ss,sa) assert(loadstring(biome.spawn_plants.."(...)"))(pos) elseif not biome.spawn_on_side and not biome.spawn_on_bottom and not biome.spawn_replace_node then if n_top.name == "air" then - minetest.set_node(p_top, { name = plant_to_spawn, param2 = fdir }) + minetest.swap_node(p_top, { name = plant_to_spawn, param2 = fdir }) end elseif biome.spawn_replace_node then - minetest.set_node(pos, { name = plant_to_spawn, param2 = fdir }) + minetest.swap_node(pos, { name = plant_to_spawn, param2 = fdir }) elseif biome.spawn_on_side then local onside = biome_lib:find_open_side(pos) if onside then - minetest.set_node(onside.newpos, { name = plant_to_spawn, param2 = onside.facedir }) + minetest.swap_node(onside.newpos, { name = plant_to_spawn, param2 = onside.facedir }) end elseif biome.spawn_on_bottom then if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then - minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, { name = plant_to_spawn, param2 = fdir} ) + minetest.swap_node({x=pos.x, y=pos.y-1, z=pos.z}, { name = plant_to_spawn, param2 = fdir} ) end end end @@ -605,15 +606,15 @@ function biome_lib:grow_plants(opts) -- corner case for changing short junglegrass -- to dry shrub in desert if n_bot.name == options.dry_early_node and options.grow_plant == "junglegrass:short" then - minetest.set_node(pos, { name = "default:dry_shrub" }) + minetest.swap_node(pos, { name = "default:dry_shrub" }) elseif options.grow_vertically and walldir then if biome_lib:search_downward(pos, options.height_limit, options.ground_nodes) then - minetest.set_node(p_top, { name = options.grow_plant, param2 = walldir}) + minetest.swap_node(p_top, { name = options.grow_plant, param2 = walldir}) end elseif not options.grow_result and not options.grow_function then - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) else biome_lib:replace_object(pos, options.grow_result, options.grow_function, options.facedir, options.seed_diff) @@ -629,7 +630,7 @@ end function biome_lib:replace_object(pos, replacement, grow_function, walldir, seeddiff) local growtype = type(grow_function) if growtype == "table" then - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) biome_lib:grow_tree(pos, grow_function) return elseif growtype == "function" then @@ -645,7 +646,7 @@ function biome_lib:replace_object(pos, replacement, grow_function, walldir, seed assert(loadstring(grow_function.."(...)"))(pos,noise1,noise2,walldir) return elseif growtype == "nil" then - minetest.set_node(pos, { name = replacement, param2 = walldir}) + minetest.swap_node(pos, { name = replacement, param2 = walldir}) return elseif growtype ~= "nil" and growtype ~= "string" and growtype ~= "table" then error("Invalid grow function "..dump(grow_function).." used on object at ("..dump(pos)..")") diff --git a/bushes/init.lua b/bushes/init.lua index b880bd2..ea61887 100644 --- a/bushes/init.lua +++ b/bushes/init.lua @@ -183,14 +183,14 @@ abstract_bushes.grow_bush_node = function(pos,dir, leaf_type) if minetest.get_node(right_here).name == "air" -- instead of check_air = true, or minetest.get_node(right_here).name == "default:junglegrass" then - minetest.set_node(right_here, {name="bushes:bushbranches"..bush_branch_type , param2=dir}) + minetest.swap_node(right_here, {name="bushes:bushbranches"..bush_branch_type , param2=dir}) --minetest.chat_send_all("leaf_type: (" .. leaf_type .. ")") - minetest.set_node(above_right_here, {name="bushes:BushLeaves"..leaf_type}) + minetest.swap_node(above_right_here, {name="bushes:BushLeaves"..leaf_type}) local chance_of_high_leaves = math.random(1,10) if chance_of_high_leaves> 5 then local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z} --minetest.chat_send_all("leaf_type: (" .. leaf_type .. ")") - minetest.set_node(two_above_right_here, {name="bushes:BushLeaves"..leaf_type}) + minetest.swap_node(two_above_right_here, {name="bushes:BushLeaves"..leaf_type}) end end end @@ -229,12 +229,12 @@ abstract_bushes.grow_youngtree_node2 = function(pos, height) if height == 4 then local two_above_right_here_south = {x=pos.x, y=pos.y+3, z=pos.z-1} local three_above_right_here_south = {x=pos.x, y=pos.y+4, z=pos.z-1} - minetest.set_node(right_here, {name="bushes:youngtree2_bottom"}) - minetest.set_node(above_right_here, {name="bushes:youngtree2_bottom"}) - minetest.set_node(two_above_right_here, {name="bushes:bushbranches2" , param2=2}) - minetest.set_node(two_above_right_here_south, {name="bushes:bushbranches2" , param2=0}) - minetest.set_node(three_above_right_here, {name="bushes:BushLeaves1" }) - minetest.set_node(three_above_right_here_south, {name="bushes:BushLeaves1" }) + minetest.swap_node(right_here, {name="bushes:youngtree2_bottom"}) + minetest.swap_node(above_right_here, {name="bushes:youngtree2_bottom"}) + minetest.swap_node(two_above_right_here, {name="bushes:bushbranches2" , param2=2}) + minetest.swap_node(two_above_right_here_south, {name="bushes:bushbranches2" , param2=0}) + minetest.swap_node(three_above_right_here, {name="bushes:BushLeaves1" }) + minetest.swap_node(three_above_right_here_south, {name="bushes:BushLeaves1" }) end end diff --git a/bushes_classic/nodes.lua b/bushes_classic/nodes.lua index bf15596..1babb1d 100644 --- a/bushes_classic/nodes.lua +++ b/bushes_classic/nodes.lua @@ -47,7 +47,7 @@ plantlife_bushes.after_dig_node = function(pos, oldnode, oldmetadata, digger) elseif groupcaps.snappy then -- plant a new bush without fruits - minetest.set_node(pos, {type = "node", name = "bushes:fruitless_bush"}) + minetest.swap_node(pos, {type = "node", name = "bushes:fruitless_bush"}) local meta = minetest.get_meta(pos) meta:set_string('bush_type', bush_name) @@ -114,7 +114,7 @@ plantlife_bushes.after_place_node = function(pos, placer, itemstack) return end - minetest.set_node(pos, {name = "bushes:fruitless_bush"}) + minetest.swap_node(pos, {name = "bushes:fruitless_bush"}) local meta = minetest.get_meta(pos) meta:set_string("bush_type", name_parts[1]) end @@ -137,7 +137,7 @@ minetest.register_abm({ local is_soil = minetest.get_item_group(dirt.name, "soil") or minetest.get_item_group(dirt.name, "potting_soil") if is_soil and (dirt.name == "farming:soil_wet" or math.random(1,3) == 1) then - minetest.set_node( pos, {name = "bushes:" .. bush_name .. "_bush"}) + minetest.swap_node( pos, {name = "bushes:" .. bush_name .. "_bush"}) end end end diff --git a/cavestuff/mapgen.lua b/cavestuff/mapgen.lua index fc890b3..3be9f31 100644 --- a/cavestuff/mapgen.lua +++ b/cavestuff/mapgen.lua @@ -38,9 +38,9 @@ minetest.register_on_generated(function(minp, maxp, seed) nn = minetest.get_node({x=x,y=ground_y,z=z}).name -- If desert sand, add dry shrub if nn == "default:dirt_with_grass" then - minetest.set_node(p,{name="cavestuff:pebble_"..pr:next(1,2), param2=math.random(0,3)}) + minetest.swap_node(p,{name="cavestuff:pebble_"..pr:next(1,2), param2=math.random(0,3)}) elseif nn == "default:desert_sand" then - minetest.set_node(p,{name="cavestuff:desert_pebble_"..pr:next(1,2), param2=math.random(0,3)}) + minetest.swap_node(p,{name="cavestuff:desert_pebble_"..pr:next(1,2), param2=math.random(0,3)}) end end end diff --git a/cavestuff/nodes.lua b/cavestuff/nodes.lua index d4be0f2..1c6bc29 100644 --- a/cavestuff/nodes.lua +++ b/cavestuff/nodes.lua @@ -97,7 +97,7 @@ minetest.register_node("cavestuff:stalactite_1",{ if minetest.get_node(pt.under).name=="default:stone" and minetest.get_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}).name=="air" and minetest.get_node({x=pt.under.x, y=pt.under.y-2, z=pt.under.z}).name=="air" then - minetest.set_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..math.random(1,3)}) + minetest.swap_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..math.random(1,3)}) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end diff --git a/dryplants/init.lua b/dryplants/init.lua index 461a9dd..9fde6eb 100644 --- a/dryplants/init.lua +++ b/dryplants/init.lua @@ -86,7 +86,7 @@ local function sickle_on_use(itemstack, user, pointed_thing, uses) -- check if flora but no flower if minetest.get_item_group(under.name, "flora") == 1 and minetest.get_item_group(under.name, "flower") == 0 then -- turn the node into cut grass, wear out item and play sound - minetest.set_node(pt.under, {name="dryplants:grass"}) + minetest.swap_node(pt.under, {name="dryplants:grass"}) else -- otherwise dig the node if not minetest.node_dig(pt.under, under, user) then return @@ -102,8 +102,8 @@ local function sickle_on_use(itemstack, user, pointed_thing, uses) if minetest.is_protected(above_pos, user:get_player_name()) or above.name ~= "air" then return end - minetest.set_node(pt.under, {name="dryplants:grass_short"}) - minetest.set_node(above_pos, {name="dryplants:grass"}) + minetest.swap_node(pt.under, {name="dryplants:grass_short"}) + minetest.swap_node(above_pos, {name="dryplants:grass"}) minetest.sound_play("default_dig_crumbly", { pos = pt.under, gain = 0.5, @@ -148,7 +148,7 @@ minetest.register_abm({ interval = HAY_DRYING_TIME, --1200, -- 20 minutes: a minetest-day/night-cycle chance = 1, action = function(pos) - minetest.set_node(pos, {name="dryplants:hay"}) + minetest.swap_node(pos, {name="dryplants:hay"}) end, }) @@ -196,7 +196,7 @@ minetest.register_abm({ -- Only become dirt with grass if no cut grass or hay lies on top local above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}) if above.name ~= "dryplants:grass" and above.name ~= "dryplants:hay" then - minetest.set_node(pos, {name="default:dirt_with_grass"}) + minetest.swap_node(pos, {name="default:dirt_with_grass"}) end end, }) diff --git a/dryplants/juncus.lua b/dryplants/juncus.lua index 34176ce..4ba1cab 100644 --- a/dryplants/juncus.lua +++ b/dryplants/juncus.lua @@ -18,9 +18,9 @@ abstract_dryplants.grow_juncus = function(pos) if minetest.get_node(right_here).name == "air" -- instead of check_air = true, or minetest.get_node(right_here).name == "default:junglegrass" then if juncus_type == 2 then - minetest.set_node(right_here, {name="dryplants:juncus_02"}) + minetest.swap_node(right_here, {name="dryplants:juncus_02"}) else - minetest.set_node(right_here, {name="dryplants:juncus"}) + minetest.swap_node(right_here, {name="dryplants:juncus"}) end end end @@ -57,9 +57,9 @@ minetest.register_node("dryplants:juncus", { local juncus_type = math.random(2,3) local right_here = {x=pos.x, y=pos.y+1, z=pos.z} if juncus_type == 2 then - minetest.set_node(right_here, {name="dryplants:juncus_02"}) + minetest.swap_node(right_here, {name="dryplants:juncus_02"}) else - minetest.set_node(right_here, {name="dryplants:juncus"}) + minetest.swap_node(right_here, {name="dryplants:juncus"}) end if not minetest.setting_getbool("creative_mode") then itemstack:take_item() diff --git a/dryplants/meadowvariation.lua b/dryplants/meadowvariation.lua index d703ae6..7554585 100644 --- a/dryplants/meadowvariation.lua +++ b/dryplants/meadowvariation.lua @@ -10,7 +10,7 @@ abstract_dryplants.grow_grass_variation = function(pos) local right_here = {x=pos.x, y=pos.y, z=pos.z} - minetest.set_node(right_here, {name="dryplants:grass_short"}) + minetest.swap_node(right_here, {name="dryplants:grass_short"}) end biome_lib:register_generate_plant({ diff --git a/dryplants/moregrass.lua b/dryplants/moregrass.lua index 2593d73..41b61f4 100644 --- a/dryplants/moregrass.lua +++ b/dryplants/moregrass.lua @@ -13,7 +13,7 @@ abstract_dryplants.grow_grass = function(pos) local grass_size = math.random(1,5) if minetest.get_node(right_here).name == "air" -- instead of check_air = true, or minetest.get_node(right_here).name == "default:junglegrass" then - minetest.set_node(right_here, {name="default:grass_"..grass_size}) + minetest.swap_node(right_here, {name="default:grass_"..grass_size}) end end diff --git a/dryplants/reed.lua b/dryplants/reed.lua index 707cafc..155233f 100644 --- a/dryplants/reed.lua +++ b/dryplants/reed.lua @@ -107,7 +107,7 @@ if AUTO_ROOF_CORNER == true then and ((node_north.name == roof and node_north.param2 == 3) or (node_north.name == corner and node_north.param2 == 3)) then - minetest.set_node(pos, {name=corner, param2=0}) + minetest.swap_node(pos, {name=corner, param2=0}) end if ((node_north.name == roof and node_north.param2 == 1) @@ -115,7 +115,7 @@ if AUTO_ROOF_CORNER == true then and ((node_east.name == roof and node_east.param2 == 0) or (node_east.name == corner and node_east.param2 == 0)) then - minetest.set_node(pos, {name=corner, param2=1}) + minetest.swap_node(pos, {name=corner, param2=1}) end if ((node_east.name == roof and node_east.param2 == 2) @@ -123,7 +123,7 @@ if AUTO_ROOF_CORNER == true then and ((node_south.name == roof and node_south.param2 == 1) or (node_south.name == corner and node_south.param2 == 1)) then - minetest.set_node(pos, {name=corner, param2=2}) + minetest.swap_node(pos, {name=corner, param2=2}) end if ((node_south.name == roof and node_south.param2 == 3) @@ -131,7 +131,7 @@ if AUTO_ROOF_CORNER == true then and ((node_west.name == roof and node_west.param2 == 2) or (node_west.name == corner and node_west.param2 == 2)) then - minetest.set_node(pos, {name=corner, param2=3}) + minetest.swap_node(pos, {name=corner, param2=3}) end -- corner 2 if ((node_west.name == roof and node_west.param2 == 2) @@ -139,7 +139,7 @@ if AUTO_ROOF_CORNER == true then and ((node_north.name == roof and node_north.param2 == 1) or (node_north.name == corner_2 and node_north.param2 == 3)) then - minetest.set_node(pos, {name=corner_2, param2=0}) + minetest.swap_node(pos, {name=corner_2, param2=0}) end if ((node_north.name == roof and node_north.param2 == 3) @@ -147,7 +147,7 @@ if AUTO_ROOF_CORNER == true then and ((node_east.name == roof and node_east.param2 == 2) or (node_east.name == corner_2 and node_east.param2 == 0)) then - minetest.set_node(pos, {name=corner_2, param2=1}) + minetest.swap_node(pos, {name=corner_2, param2=1}) end if ((node_east.name == roof and node_east.param2 == 0) @@ -155,7 +155,7 @@ if AUTO_ROOF_CORNER == true then and ((node_south.name == roof and node_south.param2 == 3) or (node_south.name == corner_2 and node_south.param2 == 1)) then - minetest.set_node(pos, {name=corner_2, param2=2}) + minetest.swap_node(pos, {name=corner_2, param2=2}) end if ((node_south.name == roof and node_south.param2 == 1) @@ -163,7 +163,7 @@ if AUTO_ROOF_CORNER == true then and ((node_west.name == roof and node_west.param2 == 0) or (node_west.name == corner_2 and node_west.param2 == 2)) then - minetest.set_node(pos, {name=corner_2, param2=3}) + minetest.swap_node(pos, {name=corner_2, param2=3}) end end, @@ -255,7 +255,7 @@ if REED_WILL_DRY == true then chance = 1, action = function(pos) local direction = minetest.get_node(pos).param2 - minetest.set_node(pos, {name=DRy, param2=direction}) + minetest.swap_node(pos, {name=DRy, param2=direction}) end, }) end diff --git a/dryplants/reedmace.lua b/dryplants/reedmace.lua index ec37442..e5e8b69 100644 --- a/dryplants/reedmace.lua +++ b/dryplants/reedmace.lua @@ -34,18 +34,18 @@ abstract_dryplants.grow_reedmace = function(pos) if minetest.get_node(pos_01).name == "air" -- bug fix or minetest.get_node(pos_01).name == "dryplants:reedmace_sapling" then if minetest.get_node(pos_02).name ~= "air" then - minetest.set_node(pos_01, {name="dryplants:reedmace_top"}) + minetest.swap_node(pos_01, {name="dryplants:reedmace_top"}) elseif minetest.get_node(pos_03).name ~= "air" then - minetest.set_node(pos_01, {name="dryplants:reedmace_height_2"}) + minetest.swap_node(pos_01, {name="dryplants:reedmace_height_2"}) elseif size == 1 then - minetest.set_node(pos_01, {name="dryplants:reedmace_top"}) + minetest.swap_node(pos_01, {name="dryplants:reedmace_top"}) elseif size == 2 then - minetest.set_node(pos_01, {name="dryplants:reedmace_height_2"}) + minetest.swap_node(pos_01, {name="dryplants:reedmace_height_2"}) elseif size == 3 then if spikes == 1 then - minetest.set_node(pos_01, {name="dryplants:reedmace_height_3_spikes"}) + minetest.swap_node(pos_01, {name="dryplants:reedmace_height_3_spikes"}) else - minetest.set_node(pos_01, {name="dryplants:reedmace_height_3"}) + minetest.swap_node(pos_01, {name="dryplants:reedmace_height_3"}) end end end @@ -61,18 +61,18 @@ abstract_dryplants.grow_reedmace_water = function(pos) minetest.add_entity(pos_01, "dryplants:reedmace_water_entity") if minetest.get_node(pos_02).name == "air" then -- bug fix if minetest.get_node(pos_03).name ~= "air" then - minetest.set_node(pos_02, {name="dryplants:reedmace_top"}) + minetest.swap_node(pos_02, {name="dryplants:reedmace_top"}) elseif minetest.get_node(pos_04).name ~= "air" then - minetest.set_node(pos_02, {name="dryplants:reedmace_height_2"}) + minetest.swap_node(pos_02, {name="dryplants:reedmace_height_2"}) elseif size == 1 then - minetest.set_node(pos_02, {name="dryplants:reedmace_top"}) + minetest.swap_node(pos_02, {name="dryplants:reedmace_top"}) elseif size == 2 then - minetest.set_node(pos_02, {name="dryplants:reedmace_height_2"}) + minetest.swap_node(pos_02, {name="dryplants:reedmace_height_2"}) elseif size == 3 then if spikes == 1 then - minetest.set_node(pos_02, {name="dryplants:reedmace_height_3_spikes"}) + minetest.swap_node(pos_02, {name="dryplants:reedmace_height_3_spikes"}) else - minetest.set_node(pos_02, {name="dryplants:reedmace_height_3"}) + minetest.swap_node(pos_02, {name="dryplants:reedmace_height_3"}) end end end @@ -286,7 +286,7 @@ minetest.register_abm({ if minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air" then abstract_dryplants.grow_reedmace_water({x = pos.x, y = pos.y - 1, z = pos.z}) end - minetest.set_node({x=pos.x, y=pos.y, z=pos.z}, {name="default:water_source"}) + minetest.swap_node({x=pos.x, y=pos.y, z=pos.z}, {name="default:water_source"}) else abstract_dryplants.grow_reedmace({x = pos.x, y = pos.y - 1, z = pos.z}) end diff --git a/ferns/gianttreefern.lua b/ferns/gianttreefern.lua index 60d3b82..198c6cc 100644 --- a/ferns/gianttreefern.lua +++ b/ferns/gianttreefern.lua @@ -69,11 +69,11 @@ abstract_ferns.grow_giant_tree_fern = function(pos) brk = true break end - minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, {name="ferns:fern_trunk_big"}) + minetest.swap_node({x = pos.x, y = pos.y + i, z = pos.z}, {name="ferns:fern_trunk_big"}) end if not brk then - minetest.set_node({x = pos.x, y = pos.y + size-2, z = pos.z}, {name="ferns:fern_trunk_big_top"}) - minetest.set_node({x = pos.x, y = pos.y + size-1, z = pos.z}, {name="ferns:tree_fern_leaves_giant"}) + minetest.swap_node({x = pos.x, y = pos.y + size-2, z = pos.z}, {name="ferns:fern_trunk_big_top"}) + minetest.swap_node({x = pos.x, y = pos.y + size-1, z = pos.z}, {name="ferns:tree_fern_leaves_giant"}) -- all the checking for air below is to prevent some ugly bugs (incomplete trunks of neighbouring trees), it's a bit slower, but worth the result @@ -86,7 +86,7 @@ abstract_ferns.grow_giant_tree_fern = function(pos) -- add leaves so long as the destination nodes are air for j = 1, 3 do if minetest.get_node(positions[j]).name == "air" then - minetest.set_node(positions[j], {name="ferns:tree_fern_leave_big"}) + minetest.swap_node(positions[j], {name="ferns:tree_fern_leave_big"}) else endpos = j break @@ -94,7 +94,7 @@ abstract_ferns.grow_giant_tree_fern = function(pos) end -- add the terminating leaf if required and possible if endpos == 4 and minetest.get_node(positions[endpos]).name == "air" then - minetest.set_node(positions[endpos], {name="ferns:tree_fern_leave_big_end", param2=rot}) + minetest.swap_node(positions[endpos], {name="ferns:tree_fern_leave_big_end", param2=rot}) end end end diff --git a/ferns/treefern.lua b/ferns/treefern.lua index 144d584..20a3d87 100644 --- a/ferns/treefern.lua +++ b/ferns/treefern.lua @@ -35,11 +35,11 @@ abstract_ferns.grow_tree_fern = function(pos) brk = true break end - minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" }) + minetest.swap_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" }) i = i + 1 end if not brk then - minetest.set_node({x = pos.x, y = pos.y + i - 1, z = pos.z}, { name = crown }) + minetest.swap_node({x = pos.x, y = pos.y + i - 1, z = pos.z}, { name = crown }) end end diff --git a/flowers_plus/init.lua b/flowers_plus/init.lua index d60dcab..9119d36 100644 --- a/flowers_plus/init.lua +++ b/flowers_plus/init.lua @@ -115,10 +115,10 @@ for i in ipairs(lilies_list) do elseif waterlily == 8 then nodename = "flowers:waterlily_s4" end - minetest.set_node(place_pos, {name = nodename, param2 = math.random(0,3) }) + minetest.swap_node(place_pos, {name = nodename, param2 = math.random(0,3) }) else local fdir = minetest.dir_to_facedir(placer:get_look_dir()) - minetest.set_node(place_pos, {name = "flowers:waterlily", param2 = fdir}) + minetest.swap_node(place_pos, {name = "flowers:waterlily", param2 = fdir}) end if not biome_lib.expect_infinite_stacks then @@ -207,10 +207,10 @@ for i in ipairs(algae_list) do elseif seaweed == 4 then nodename = "flowers:seaweed_4" end - minetest.set_node(place_pos, {name = nodename, param2 = math.random(0,3) }) + minetest.swap_node(place_pos, {name = nodename, param2 = math.random(0,3) }) else local fdir = minetest.dir_to_facedir(placer:get_look_dir()) - minetest.set_node(place_pos, {name = "flowers:seaweed", param2 = fdir}) + minetest.swap_node(place_pos, {name = "flowers:seaweed", param2 = fdir}) end if not biome_lib.expect_infinite_stacks then @@ -294,7 +294,7 @@ flowers_plus.grow_waterlily = function(pos) end if chance == num then - minetest.set_node(right_here, {name="flowers:waterlily"..ext, param2=math.random(0,3)}) + minetest.swap_node(right_here, {name="flowers:waterlily"..ext, param2=math.random(0,3)}) end end end @@ -318,7 +318,7 @@ biome_lib:register_generate_plant({ flowers_plus.grow_seaweed = function(pos) local right_here = {x=pos.x, y=pos.y+1, z=pos.z} - minetest.set_node(right_here, {name="along_shore:seaweed_"..math.random(1,4), param2=math.random(1,3)}) + minetest.swap_node(right_here, {name="along_shore:seaweed_"..math.random(1,4), param2=math.random(1,3)}) end biome_lib:register_generate_plant({ diff --git a/molehills/init.lua b/molehills/init.lua index cd8a0e3..c3e5a66 100644 --- a/molehills/init.lua +++ b/molehills/init.lua @@ -58,7 +58,7 @@ abstract_molehills.place_molehill = function(pos) and minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z-1}).name ~= "air" and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z+1}).name ~= "air" and minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z-1}).name ~= "air" then - minetest.set_node(right_here, {name="molehills:molehill"}) + minetest.swap_node(right_here, {name="molehills:molehill"}) end end diff --git a/moretrees/cocos_palm.lua b/moretrees/cocos_palm.lua index 8dea25f..391819b 100644 --- a/moretrees/cocos_palm.lua +++ b/moretrees/cocos_palm.lua @@ -28,7 +28,7 @@ ftrunk.after_destruct = function(pos, oldnode) -- minetest.dig_node(coconutpos) does not cause nearby coconuts to be dropped :-( ... --minetest.dig_node(coconutpos) local items = minetest.get_node_drops(minetest.get_node(coconutpos).name) - minetest.remove_node(coconutpos) + minetest.swap_node(coconutpos, biome_lib.air) for _, itemname in pairs(items) do minetest.add_item(coconutpos, itemname) end @@ -56,7 +56,7 @@ local coconut_regrow_abm_spec = { local coconutpos = {x=pos.x+dx, y=pos.y, z=pos.z+dz} local coconutnode = minetest.get_node(coconutpos) if coconutnode.name == "air" then - minetest.set_node(coconutpos, {name="moretrees:coconut_0"}) + minetest.swap_node(coconutpos, {name="moretrees:coconut_0"}) end end end @@ -85,7 +85,7 @@ minetest.register_abm({ local gen local count = 0 for _,gen in pairs(genlist) do - minetest.set_node(gen.pos, {name = "moretrees:coconut_3"}) + minetest.swap_node(gen.pos, {name = "moretrees:coconut_3"}) count = count + 1 if count == 4 then break @@ -115,7 +115,7 @@ local coconut_growfn = function(pos, elapsed) minetest.add_item(pos, itemname) end end - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) end else -- Grow coconuts to the next stage @@ -240,7 +240,7 @@ if moretrees.coconuts_convert_existing_palms then minetest.swap_node(tpos, {name = "moretrees:palm_fruit_trunk"}) coconuts = minetest.find_nodes_in_area({x=tpos.x-1, y=tpos.y, z=tpos.z-1}, {x=tpos.x+1, y=tpos.y, z=tpos.z+1}, "moretrees:coconut") for _, coconutpos in pairs(coconuts) do - minetest.set_node(coconutpos, {name = "moretrees:coconut_3"}) + minetest.swap_node(coconutpos, {name = "moretrees:coconut_3"}) end end end, diff --git a/moretrees/date_palm.lua b/moretrees/date_palm.lua index f8b3e42..6e6cc4b 100644 --- a/moretrees/date_palm.lua +++ b/moretrees/date_palm.lua @@ -49,7 +49,7 @@ ftrunk.after_destruct = function(pos, oldnode) for _,datespos in pairs(dates) do -- minetest.dig_node(datespos) does not cause nearby dates to be dropped :-( ... local items = minetest.get_node_drops(minetest.get_node(datespos).name) - minetest.remove_node(datespos) + minetest.swap_node(datespos, biome_lib.air) for _, itemname in pairs(items) do minetest.add_item(datespos, itemname) end @@ -92,9 +92,9 @@ local date_regrow_abm_spec = { local datenode = minetest.get_node(datepos) if datenode.name == "air" then if node.name == "moretrees:date_palm_ffruit_trunk" then - minetest.set_node(datepos, {name="moretrees:dates_f0"}) + minetest.swap_node(datepos, {name="moretrees:dates_f0"}) else - minetest.set_node(datepos, {name="moretrees:dates_m0"}) + minetest.swap_node(datepos, {name="moretrees:dates_m0"}) end end end @@ -126,9 +126,9 @@ minetest.register_abm({ for _,genpos in pairs(dates1) do if math.random(100) <= 20 then if type == "m" then - minetest.set_node(genpos, {name = "moretrees:dates_n"}) + minetest.swap_node(genpos, {name = "moretrees:dates_n"}) else - minetest.set_node(genpos, {name = "moretrees:dates_f4"}) + minetest.swap_node(genpos, {name = "moretrees:dates_f4"}) end end end @@ -136,9 +136,9 @@ minetest.register_abm({ for _,genpos in pairs(dates2) do if math.random(100) <= 5 then if type == "m" then - minetest.set_node(genpos, {name = "moretrees:dates_n"}) + minetest.swap_node(genpos, {name = "moretrees:dates_n"}) else - minetest.set_node(genpos, {name = "moretrees:dates_f4"}) + minetest.swap_node(genpos, {name = "moretrees:dates_f4"}) end end end @@ -538,7 +538,7 @@ local dates_growfn = function(pos, elapsed) elseif string.find(node.name, "moretrees:dates_m") then minetest.swap_node(pos, {name="moretrees:dates_n"}) else - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) end return elseif node.name == "moretrees:dates_f0" and math.random(100) <= 100 * dates_regrow_prob then @@ -578,7 +578,7 @@ local dates_growfn = function(pos, elapsed) elseif string.match(node.name, "n$") then -- Remove stems. if math.random(stems_drop_ichance) == 1 then - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) return "stemdrop" end action = "nostemdrop" diff --git a/moretrees/init.lua b/moretrees/init.lua index f3f840f..6bad705 100644 --- a/moretrees/init.lua +++ b/moretrees/init.lua @@ -185,7 +185,7 @@ end -- Code to spawn a birch tree function moretrees.grow_birch(pos) - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) if math.random(1,2) == 1 then minetest.spawn_tree(pos, moretrees.birch_model1) else @@ -196,7 +196,7 @@ end -- Code to spawn a spruce tree function moretrees.grow_spruce(pos) - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) if math.random(1,2) == 1 then minetest.spawn_tree(pos, moretrees.spruce_model1) else @@ -250,10 +250,10 @@ function moretrees.grow_jungletree(pos) moretrees.jungletree_model.rules_b = moretrees.jt_rules_b2 end - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) local leaves = minetest.find_nodes_in_area({x = pos.x-1, y = pos.y, z = pos.z-1}, {x = pos.x+1, y = pos.y+10, z = pos.z+1}, "default:leaves") for leaf in ipairs(leaves) do - minetest.remove_node(leaves[leaf]) + minetest.swap_node(leaves[leaf], biome_lib.air) end minetest.spawn_tree(pos, moretrees.jungletree_model) end @@ -277,10 +277,10 @@ function moretrees.grow_fir(pos) moretrees.fir_model.iterations = 7 moretrees.fir_model.random_level = 5 - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) local leaves = minetest.find_nodes_in_area({x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, "default:leaves") for leaf in ipairs(leaves) do - minetest.remove_node(leaves[leaf]) + minetest.swap_node(leaves[leaf], biome_lib.air) end minetest.spawn_tree(pos,moretrees.fir_model) end @@ -304,10 +304,10 @@ function moretrees.grow_fir_snow(pos) moretrees.fir_model.iterations = 2 moretrees.fir_model.random_level = 2 - minetest.remove_node(pos) + minetest.swap_node(pos, biome_lib.air) local leaves = minetest.find_nodes_in_area({x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, "default:leaves") for leaf in ipairs(leaves) do - minetest.remove_node(leaves[leaf]) + minetest.swap_node(leaves[leaf], biome_lib.air) end minetest.spawn_tree(pos,moretrees.fir_model) end diff --git a/moretrees/saplings.lua b/moretrees/saplings.lua index 8004612..bd20988 100644 --- a/moretrees/saplings.lua +++ b/moretrees/saplings.lua @@ -16,13 +16,15 @@ for i in ipairs(moretrees.treelist) do grow_function = moretrees[tree_model], }) - biome_lib:grow_plants({ - grow_delay = 2, - grow_chance = 30, - grow_plant = "moretrees:"..treename.."_sapling_ongen", - grow_nodes = moretrees[tree_biome].surface, - grow_function = moretrees[tree_model], - }) + if moretrees.spawn_saplings then + biome_lib:grow_plants({ + grow_delay = 2, + grow_chance = 30, + grow_plant = "moretrees:"..treename.."_sapling_ongen", + grow_nodes = moretrees[tree_biome].surface, + grow_function = moretrees[tree_model], + }) + end end end @@ -35,13 +37,6 @@ biome_lib:grow_plants({ grow_function = "moretrees.grow_birch" }) -biome_lib:grow_plants({ - grow_delay = 2, - grow_chance = 30, - grow_plant = "moretrees:birch_sapling_ongen", - grow_nodes = moretrees.birch_biome.surface, - grow_function = "moretrees.grow_birch" -}) biome_lib:grow_plants({ grow_delay = moretrees.sapling_interval, @@ -52,14 +47,6 @@ biome_lib:grow_plants({ }) biome_lib:grow_plants({ - grow_delay = 2, - grow_chance = 30, - grow_plant = "moretrees:spruce_sapling_ongen", - grow_nodes = moretrees.spruce_biome.surface, - grow_function = "moretrees.grow_spruce" -}) - -biome_lib:grow_plants({ grow_delay = moretrees.sapling_interval, grow_chance = moretrees.sapling_chance, grow_plant = "moretrees:fir_sapling", @@ -68,14 +55,6 @@ biome_lib:grow_plants({ }) biome_lib:grow_plants({ - grow_delay = 2, - grow_chance = 30, - grow_plant = "moretrees:fir_sapling_ongen", - grow_nodes = moretrees.fir_biome.surface, - grow_function = "moretrees.grow_fir" -}) - -biome_lib:grow_plants({ grow_delay = moretrees.sapling_interval, grow_chance = moretrees.sapling_chance, grow_plant = "default:junglesapling", @@ -83,11 +62,37 @@ biome_lib:grow_plants({ grow_function = "moretrees.grow_jungletree" }) -biome_lib:grow_plants({ - grow_delay = 2, - grow_chance = 30, - grow_plant = "moretrees:jungletree_sapling_ongen", - grow_nodes = moretrees.jungletree_biome.surface, - grow_function = "moretrees.grow_jungletree" -}) +if moretrees.spawn_saplings then + biome_lib:grow_plants({ + grow_delay = 2, + grow_chance = 30, + grow_plant = "moretrees:jungletree_sapling_ongen", + grow_nodes = moretrees.jungletree_biome.surface, + grow_function = "moretrees.grow_jungletree" + }) + + biome_lib:grow_plants({ + grow_delay = 2, + grow_chance = 30, + grow_plant = "moretrees:fir_sapling_ongen", + grow_nodes = moretrees.fir_biome.surface, + grow_function = "moretrees.grow_fir" + }) + + biome_lib:grow_plants({ + grow_delay = 2, + grow_chance = 30, + grow_plant = "moretrees:spruce_sapling_ongen", + grow_nodes = moretrees.spruce_biome.surface, + grow_function = "moretrees.grow_spruce" + }) + + biome_lib:grow_plants({ + grow_delay = 2, + grow_chance = 30, + grow_plant = "moretrees:birch_sapling_ongen", + grow_nodes = moretrees.birch_biome.surface, + grow_function = "moretrees.grow_birch" + }) +end diff --git a/nature_classic/blossom.lua b/nature_classic/blossom.lua index 8bb68e0..7accd5e 100644 --- a/nature_classic/blossom.lua +++ b/nature_classic/blossom.lua @@ -9,7 +9,7 @@ local function spawn_apple_under(pos) z = pos.z, } if minetest.get_node(below).name == "air" then - minetest.set_node(below, { name = "default:apple" }) + minetest.swap_node(below, { name = "default:apple" }) end end diff --git a/nature_classic/global_function.lua b/nature_classic/global_function.lua index c6b158a..b83201c 100644 --- a/nature_classic/global_function.lua +++ b/nature_classic/global_function.lua @@ -67,7 +67,7 @@ function nature:grow_node(pos, nodename) >= nature.minimum_growth_light if is_not_young(pos) and light_enough then - minetest.set_node(pos, { name = nodename }) + minetest.swap_node(pos, { name = nodename }) set_young_node(pos) minetest.log("info", nodename .. " has grown at " .. pos.x .. "," diff --git a/trunks/generating.lua b/trunks/generating.lua index 6595f2b..0e9bd24 100644 --- a/trunks/generating.lua +++ b/trunks/generating.lua @@ -37,7 +37,7 @@ abstract_trunks.place_twig = function(pos) local node_n_w = minetest.get_node(north_west) -- small twigs if twig_size <= 16 then - minetest.set_node(right_here, {name="trunks:twig_"..math.random(1,4), param2=math.random(0,3)}) + minetest.swap_node(right_here, {name="trunks:twig_"..math.random(1,4), param2=math.random(0,3)}) end -- big twigs if Big_Twigs == true then @@ -47,13 +47,13 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_5"}) + minetest.swap_node(right_here, {name="trunks:twig_5"}) end if minetest.registered_nodes[node_n_e.name].buildable_to then - minetest.set_node(north_east, {name="trunks:twig_7"}) + minetest.swap_node(north_east, {name="trunks:twig_7"}) end if minetest.registered_nodes[node_east.name].buildable_to then - minetest.set_node(east, {name="trunks:twig_8"}) + minetest.swap_node(east, {name="trunks:twig_8"}) end end elseif twig_size == 18 then @@ -61,13 +61,13 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_5", param2=1}) + minetest.swap_node(right_here, {name="trunks:twig_5", param2=1}) end if minetest.registered_nodes[node_s_e.name].buildable_to then - minetest.set_node(south_east, {name="trunks:twig_7", param2=1}) + minetest.swap_node(south_east, {name="trunks:twig_7", param2=1}) end if minetest.registered_nodes[node_south.name].buildable_to then - minetest.set_node(south, {name="trunks:twig_8", param2=1}) + minetest.swap_node(south, {name="trunks:twig_8", param2=1}) end end elseif twig_size == 19 then @@ -75,13 +75,13 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_5", param2=2}) + minetest.swap_node(right_here, {name="trunks:twig_5", param2=2}) end if minetest.registered_nodes[node_s_w.name].buildable_to then - minetest.set_node(south_west, {name="trunks:twig_7", param2=2}) + minetest.swap_node(south_west, {name="trunks:twig_7", param2=2}) end if minetest.registered_nodes[node_west.name].buildable_to then - minetest.set_node(west, {name="trunks:twig_8", param2=2}) + minetest.swap_node(west, {name="trunks:twig_8", param2=2}) end end elseif twig_size == 20 then @@ -89,13 +89,13 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_5", param2=3}) + minetest.swap_node(right_here, {name="trunks:twig_5", param2=3}) end if minetest.registered_nodes[node_n_w.name].buildable_to then - minetest.set_node(north_west, {name="trunks:twig_7", param2=3}) + minetest.swap_node(north_west, {name="trunks:twig_7", param2=3}) end if minetest.registered_nodes[node_north.name].buildable_to then - minetest.set_node(north, {name="trunks:twig_8", param2=3}) + minetest.swap_node(north, {name="trunks:twig_8", param2=3}) end end -- big twig 2 @@ -104,13 +104,13 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z+1}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_9"}) + minetest.swap_node(right_here, {name="trunks:twig_9"}) end if minetest.registered_nodes[node_north.name].buildable_to then - minetest.set_node(north, {name="trunks:twig_10"}) + minetest.swap_node(north, {name="trunks:twig_10"}) end if minetest.registered_nodes[node_n_e.name].buildable_to then - minetest.set_node(north_east, {name="trunks:twig_11"}) + minetest.swap_node(north_east, {name="trunks:twig_11"}) end end elseif twig_size == 22 then @@ -118,13 +118,13 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z-1}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_9", param2=1}) + minetest.swap_node(right_here, {name="trunks:twig_9", param2=1}) end if minetest.registered_nodes[node_east.name].buildable_to then - minetest.set_node(east, {name="trunks:twig_10", param2=1}) + minetest.swap_node(east, {name="trunks:twig_10", param2=1}) end if minetest.registered_nodes[node_s_e.name].buildable_to then - minetest.set_node(south_east, {name="trunks:twig_11", param2=1}) + minetest.swap_node(south_east, {name="trunks:twig_11", param2=1}) end end elseif twig_size == 23 then @@ -132,13 +132,13 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z-1}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_9", param2=2}) + minetest.swap_node(right_here, {name="trunks:twig_9", param2=2}) end if minetest.registered_nodes[node_south.name].buildable_to then - minetest.set_node(south, {name="trunks:twig_10", param2=2}) + minetest.swap_node(south, {name="trunks:twig_10", param2=2}) end if minetest.registered_nodes[node_s_w.name].buildable_to then - minetest.set_node(south_west, {name="trunks:twig_11", param2=2}) + minetest.swap_node(south_west, {name="trunks:twig_11", param2=2}) end end elseif twig_size == 24 then @@ -146,17 +146,17 @@ abstract_trunks.place_twig = function(pos) or minetest.registered_nodes[minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z+1}).name].buildable_to) then if minetest.registered_nodes[node_here.name].buildable_to then - minetest.set_node(right_here, {name="trunks:twig_9", param2=3}) + minetest.swap_node(right_here, {name="trunks:twig_9", param2=3}) end if minetest.registered_nodes[node_west.name].buildable_to then - minetest.set_node(west, {name="trunks:twig_10", param2=3}) + minetest.swap_node(west, {name="trunks:twig_10", param2=3}) end if minetest.registered_nodes[node_n_w.name].buildable_to then - minetest.set_node(north_west, {name="trunks:twig_11", param2=3}) + minetest.swap_node(north_west, {name="trunks:twig_11", param2=3}) end end elseif twig_size <= 25 then - minetest.set_node(right_here, {name="trunks:twig_"..math.random(12,13), param2=math.random(0,3)}) + minetest.swap_node(right_here, {name="trunks:twig_"..math.random(12,13), param2=math.random(0,3)}) end end end @@ -269,70 +269,70 @@ abstract_trunks.place_trunk = function(pos) local trunk_type = math.random(1,3) if trunk_type == 1 then if minetest.get_modpath(MoD) ~= nil then - minetest.set_node(right_here, {name=MoD..":"..TRuNK}) + minetest.swap_node(right_here, {name=MoD..":"..TRuNK}) else - minetest.set_node(right_here, {name="default:tree"}) + minetest.swap_node(right_here, {name="default:tree"}) end elseif trunk_type == 2 and Horizontal_Trunks == true then if minetest.get_modpath(MoD) ~= nil then if minetest.registered_nodes[node_north.name].buildable_to then - minetest.set_node(north, {name=MoD..":"..TRuNK, param2=4}) + minetest.swap_node(north, {name=MoD..":"..TRuNK, param2=4}) end if length >= 4 and minetest.registered_nodes[node_north2.name].buildable_to then - minetest.set_node(north2, {name=MoD..":"..TRuNK, param2=4}) + minetest.swap_node(north2, {name=MoD..":"..TRuNK, param2=4}) end - minetest.set_node(right_here, {name=MoD..":"..TRuNK, param2=4}) + minetest.swap_node(right_here, {name=MoD..":"..TRuNK, param2=4}) if minetest.registered_nodes[node_south.name].buildable_to then - minetest.set_node(south, {name=MoD..":"..TRuNK, param2=4}) + minetest.swap_node(south, {name=MoD..":"..TRuNK, param2=4}) end if length == 5 and minetest.registered_nodes[node_south2.name].buildable_to then - minetest.set_node(south2, {name=MoD..":"..TRuNK, param2=4}) + minetest.swap_node(south2, {name=MoD..":"..TRuNK, param2=4}) end else if minetest.registered_nodes[node_north.name].buildable_to then - minetest.set_node(north, {name="default:tree", param2=4}) + minetest.swap_node(north, {name="default:tree", param2=4}) end if length >= 4 and minetest.registered_nodes[node_north2.name].buildable_to then - minetest.set_node(north2, {name="default:tree", param2=4}) + minetest.swap_node(north2, {name="default:tree", param2=4}) end - minetest.set_node(right_here, {name="default:tree", param2=4}) + minetest.swap_node(right_here, {name="default:tree", param2=4}) if minetest.registered_nodes[node_south.name].buildable_to then - minetest.set_node(south, {name="default:tree", param2=4}) + minetest.swap_node(south, {name="default:tree", param2=4}) end if length == 5 and minetest.registered_nodes[node_south2.name].buildable_to then - minetest.set_node(south2, {name="default:tree", param2=4}) + minetest.swap_node(south2, {name="default:tree", param2=4}) end end elseif trunk_type == 3 and Horizontal_Trunks == true then if minetest.get_modpath(MoD) ~= nil then if minetest.registered_nodes[node_west.name].buildable_to then - minetest.set_node(west, {name=MoD..":"..TRuNK, param2=12}) + minetest.swap_node(west, {name=MoD..":"..TRuNK, param2=12}) end if length >= 4 and minetest.registered_nodes[node_west2.name].buildable_to then - minetest.set_node(west2, {name=MoD..":"..TRuNK, param2=12}) + minetest.swap_node(west2, {name=MoD..":"..TRuNK, param2=12}) end - minetest.set_node(right_here, {name=MoD..":"..TRuNK, param2=12}) + minetest.swap_node(right_here, {name=MoD..":"..TRuNK, param2=12}) if minetest.registered_nodes[node_east.name].buildable_to then - minetest.set_node(east, {name=MoD..":"..TRuNK, param2=12}) + minetest.swap_node(east, {name=MoD..":"..TRuNK, param2=12}) end if length == 5 and minetest.registered_nodes[node_east2.name].buildable_to then - minetest.set_node(east2, {name=MoD..":"..TRuNK, param2=12}) + minetest.swap_node(east2, {name=MoD..":"..TRuNK, param2=12}) end else if minetest.registered_nodes[node_west.name].buildable_to then - minetest.set_node(west, {name="default:tree", param2=12}) + minetest.swap_node(west, {name="default:tree", param2=12}) end if length >= 4 and minetest.registered_nodes[node_west2.name].buildable_to then - minetest.set_node(west2, {name="default:tree", param2=12}) + minetest.swap_node(west2, {name="default:tree", param2=12}) end - minetest.set_node(right_here, {name="default:tree", param2=12}) + minetest.swap_node(right_here, {name="default:tree", param2=12}) if minetest.registered_nodes[node_east.name].buildable_to then - minetest.set_node(east, {name="default:tree", param2=12}) + minetest.swap_node(east, {name="default:tree", param2=12}) end if length == 5 and minetest.registered_nodes[node_east2.name].buildable_to then - minetest.set_node(east2, {name="default:tree", param2=12}) + minetest.swap_node(east2, {name="default:tree", param2=12}) end end end @@ -367,9 +367,9 @@ abstract_trunks.grow_moss_on_ground = function(pos) local moss_type = math.random(1,21) if moss_type == 1 then - minetest.set_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3)}) + minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3)}) else - minetest.set_node(on_ground, {name="trunks:moss", param2=math.random(0,3)}) + minetest.swap_node(on_ground, {name="trunks:moss", param2=math.random(0,3)}) end end @@ -418,41 +418,41 @@ abstract_trunks.grow_moss_on_trunk = function(pos) local moss_type = math.random(1,41) if minetest.registered_nodes[node_here.name].buildable_to then -- instead of check_air = true, if moss_type == 1 then - minetest.set_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3) --[[1]]}) + minetest.swap_node(on_ground, {name="trunks:moss_fungus", param2=math.random(0,3) --[[1]]}) elseif moss_type < 22 then - minetest.set_node(on_ground, {name="trunks:moss", param2=math.random(0,3) --[[1]]}) + minetest.swap_node(on_ground, {name="trunks:moss", param2=math.random(0,3) --[[1]]}) end end local moss_type = math.random(1,31) -- cliche of more moss at north if minetest.registered_nodes[node_north.name].buildable_to then -- instead of check_air = true, if moss_type == 1 then - minetest.set_node(at_side_n, {name="trunks:moss_fungus", param2=math.random(4,7)}) -- 5,4,6,7 + minetest.swap_node(at_side_n, {name="trunks:moss_fungus", param2=math.random(4,7)}) -- 5,4,6,7 elseif moss_type < 22 then - minetest.set_node(at_side_n, {name="trunks:moss", param2=math.random(4,7)}) + minetest.swap_node(at_side_n, {name="trunks:moss", param2=math.random(4,7)}) end end local moss_type = math.random(1,41) if minetest.registered_nodes[node_east.name].buildable_to then -- instead of check_air = true, if moss_type == 1 then - minetest.set_node(at_side_e, {name="trunks:moss_fungus", param2=math.random(12,15)}) + minetest.swap_node(at_side_e, {name="trunks:moss_fungus", param2=math.random(12,15)}) elseif moss_type < 22 then - minetest.set_node(at_side_e, {name="trunks:moss", param2=math.random(12,15)}) + minetest.swap_node(at_side_e, {name="trunks:moss", param2=math.random(12,15)}) end end local moss_type = math.random(1,41) if minetest.registered_nodes[node_south.name].buildable_to then -- instead of check_air = true, if moss_type == 1 then - minetest.set_node(at_side_s, {name="trunks:moss_fungus", param2=math.random(8,11)}) + minetest.swap_node(at_side_s, {name="trunks:moss_fungus", param2=math.random(8,11)}) elseif moss_type < 22 then - minetest.set_node(at_side_s, {name="trunks:moss", param2=math.random(8,11)}) + minetest.swap_node(at_side_s, {name="trunks:moss", param2=math.random(8,11)}) end end local moss_type = math.random(1,41) if minetest.registered_nodes[node_west.name].buildable_to then -- instead of check_air = true, if moss_type == 1 then - minetest.set_node(at_side_w, {name="trunks:moss_fungus", param2=math.random(16,19)}) + minetest.swap_node(at_side_w, {name="trunks:moss_fungus", param2=math.random(16,19)}) elseif moss_type < 22 then - minetest.set_node(at_side_w, {name="trunks:moss", param2=math.random(16,19)}) + minetest.swap_node(at_side_w, {name="trunks:moss", param2=math.random(16,19)}) end end --end @@ -520,16 +520,16 @@ abstract_trunks.grow_roots = function(pos) and string.find(node_below.name, "dirt") and node_here.param2 == 0 then if minetest.registered_nodes[node_north.name].buildable_to then - minetest.set_node(north, {name="trunks:"..TRuNK.."root", param2=2}) + minetest.swap_node(north, {name="trunks:"..TRuNK.."root", param2=2}) end if minetest.registered_nodes[node_east.name].buildable_to then - minetest.set_node(east, {name="trunks:"..TRuNK.."root", param2=3}) + minetest.swap_node(east, {name="trunks:"..TRuNK.."root", param2=3}) end if minetest.registered_nodes[node_south.name].buildable_to then - minetest.set_node(south, {name="trunks:"..TRuNK.."root", param2=0}) + minetest.swap_node(south, {name="trunks:"..TRuNK.."root", param2=0}) end if minetest.registered_nodes[node_west.name].buildable_to then - minetest.set_node(west, {name="trunks:"..TRuNK.."root", param2=1}) + minetest.swap_node(west, {name="trunks:"..TRuNK.."root", param2=1}) end end end diff --git a/trunks/nodes.lua b/trunks/nodes.lua index d46d2e5..b5bafa9 100644 --- a/trunks/nodes.lua +++ b/trunks/nodes.lua @@ -44,7 +44,7 @@ for i in pairs(NoDe) do local pt = pointed_thing local direction = minetest.dir_to_facedir(placer:get_look_dir()) if minetest.get_node(pt.above).name=="air" then - minetest.set_node(pt.above, {name="trunks:twig_"..math.random(1,4), param2=direction}) + minetest.swap_node(pt.above, {name="trunks:twig_"..math.random(1,4), param2=direction}) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end @@ -227,7 +227,7 @@ if Auto_Roof_Corner == true then and ((node_north.name == roof and node_north.param2 == 3) or (node_north.name == corner and node_north.param2 == 3)) then - minetest.set_node(pos, {name=corner, param2=0}) + minetest.swap_node(pos, {name=corner, param2=0}) end if ((node_north.name == roof and node_north.param2 == 1) @@ -235,7 +235,7 @@ if Auto_Roof_Corner == true then and ((node_east.name == roof and node_east.param2 == 0) or (node_east.name == corner and node_east.param2 == 0)) then - minetest.set_node(pos, {name=corner, param2=1}) + minetest.swap_node(pos, {name=corner, param2=1}) end if ((node_east.name == roof and node_east.param2 == 2) @@ -243,7 +243,7 @@ if Auto_Roof_Corner == true then and ((node_south.name == roof and node_south.param2 == 1) or (node_south.name == corner and node_south.param2 == 1)) then - minetest.set_node(pos, {name=corner, param2=2}) + minetest.swap_node(pos, {name=corner, param2=2}) end if ((node_south.name == roof and node_south.param2 == 3) @@ -251,7 +251,7 @@ if Auto_Roof_Corner == true then and ((node_west.name == roof and node_west.param2 == 2) or (node_west.name == corner and node_west.param2 == 2)) then - minetest.set_node(pos, {name=corner, param2=3}) + minetest.swap_node(pos, {name=corner, param2=3}) end -- corner 2 if ((node_west.name == roof and node_west.param2 == 2) @@ -259,7 +259,7 @@ if Auto_Roof_Corner == true then and ((node_north.name == roof and node_north.param2 == 1) or (node_north.name == corner_2 and node_north.param2 == 3)) then - minetest.set_node(pos, {name=corner_2, param2=0}) + minetest.swap_node(pos, {name=corner_2, param2=0}) end if ((node_north.name == roof and node_north.param2 == 3) @@ -267,7 +267,7 @@ if Auto_Roof_Corner == true then and ((node_east.name == roof and node_east.param2 == 2) or (node_east.name == corner_2 and node_east.param2 == 0)) then - minetest.set_node(pos, {name=corner_2, param2=1}) + minetest.swap_node(pos, {name=corner_2, param2=1}) end if ((node_east.name == roof and node_east.param2 == 0) @@ -275,7 +275,7 @@ if Auto_Roof_Corner == true then and ((node_south.name == roof and node_south.param2 == 3) or (node_south.name == corner_2 and node_south.param2 == 1)) then - minetest.set_node(pos, {name=corner_2, param2=2}) + minetest.swap_node(pos, {name=corner_2, param2=2}) end if ((node_south.name == roof and node_south.param2 == 1) @@ -283,7 +283,7 @@ if Auto_Roof_Corner == true then and ((node_west.name == roof and node_west.param2 == 0) or (node_west.name == corner_2 and node_west.param2 == 2)) then - minetest.set_node(pos, {name=corner_2, param2=3}) + minetest.swap_node(pos, {name=corner_2, param2=3}) end end, diff --git a/vines/.luacheckrc b/vines/.luacheckrc deleted file mode 100644 index bf99780..0000000 --- a/vines/.luacheckrc +++ /dev/null @@ -1,13 +0,0 @@ - -unused_args = false - -read_globals = { - "minetest", - "default", - "ItemStack", - "biome_lib", -} - -globals = { - "vines", -} diff --git a/vines/LICENSE.md b/vines/LICENSE.md deleted file mode 100644 index fb67788..0000000 --- a/vines/LICENSE.md +++ /dev/null @@ -1,4 +0,0 @@ -License -======= -- Code WTFPL -- Texture CC diff --git a/vines/README.md b/vines/README.md index 89fdb27..31006c7 100644 --- a/vines/README.md +++ b/vines/README.md @@ -1,9 +1,11 @@ -# Vines +# Vines Mod by Bas80 (Edited by TenPlus1) + +### License: MIT for code, CC for textures ## Features - Rope block for spawning rope that slowly drops into the deep. - Vines are climbable and slowly grow downward. -- Shears that allow the collecting of vines. +- Shears that allow the faster collecting of vines. - Spawns vines on jungletree leaves. - Roots on the bottom of dirt and dirt with grass nodes. - Spawns vines on trees located in swampy area. @@ -48,9 +50,3 @@ table. |average_length|int| The average length of vines| For biome definitions please see the [plants_lib API documentation](https://github.com/VanessaE/plantlife_modpack/blob/master/API.txt) - -## Notice -Vines use after_destruct on registered leave nodes to remove vines from which -the leaves are removed. This is done by using the override function. -Malfunctions may occur if other mods override the after_destruct of these nodes -also. diff --git a/vines/aliases.lua b/vines/aliases.lua deleted file mode 100644 index fce7218..0000000 --- a/vines/aliases.lua +++ /dev/null @@ -1,11 +0,0 @@ --- used to remove the old vine nodes. This gives room for the new nodes -minetest.register_alias( 'vines:root', 'air' ) -minetest.register_alias( 'vines:root_rotten', 'air' ) -minetest.register_alias( 'vines:vine', 'air' ) -minetest.register_alias( 'vines:vine_rotten', 'air' ) -minetest.register_alias( 'vines:side', 'air' ) -minetest.register_alias( 'vines:side_rotten', 'air' ) -minetest.register_alias( 'vines:jungle', 'air' ) -minetest.register_alias( 'vines:jungle_rotten', 'air' ) -minetest.register_alias( 'vines:willow', 'air' ) -minetest.register_alias( 'vines:willow_rotten', 'air' ) diff --git a/vines/bower.json b/vines/bower.json deleted file mode 100644 index 108a7c1..0000000 --- a/vines/bower.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "vines", - "description": "Vines that spawn on trees and rope", - "keywords": [ - "vines", - "trees", - "rope", - "jungle" - ], - "homepage": "https://github.com/bas080/vines/", - "screenshots": [ - "https://raw.githubusercontent.com/bas080/vines/forum/screenshot.png" - ], - "authors": [ - "bas080" - ], - "license": "WTFPL" -} diff --git a/vines/crafts.lua b/vines/crafts.lua deleted file mode 100644 index 80a6a65..0000000 --- a/vines/crafts.lua +++ /dev/null @@ -1,17 +0,0 @@ --- support for i18n -local S = plantlife_i18n.gettext - -minetest.register_craft({ - output = 'vines:rope_block', - recipe = vines.recipes['rope_block'] -}) - -minetest.register_craft({ - output = 'vines:shears', - recipe = vines.recipes['shears'] -}) - -minetest.register_craftitem("vines:vines", { - description = S("Vines"), - inventory_image = "vines_item.png", -}) diff --git a/vines/functions.lua b/vines/functions.lua deleted file mode 100644 index 2d2f529..0000000 --- a/vines/functions.lua +++ /dev/null @@ -1,132 +0,0 @@ --- support for i18n -local S = plantlife_i18n.gettext - -vines.register_vine = function( name, defs, biome ) - local groups = { vines=1, snappy=3, flammable=2 } - - local vine_name_end = 'vines:'..name..'_end' - local vine_name_middle = 'vines:'..name..'_middle' - - local vine_image_end = "vines_"..name.."_end.png" - local vine_image_middle = "vines_"..name.."_middle.png" - - local drop_node = vine_name_end - - biome.spawn_plants = { vine_name_end } - - local vine_group = 'group:'..name..'_vines' - biome.spawn_surfaces[ #biome.spawn_surfaces + 1 ] = vine_group - - local selection_box = { type = "wallmounted", } - local drawtype = 'signlike' - if ( not biome.spawn_on_side ) then - --different properties for bottom and side vines. - selection_box = { type = "fixed", fixed = { -0.4, -1/2, -0.4, 0.4, 1/2, 0.4 }, } - drawtype = 'plantlike' - end - - minetest.register_node( vine_name_end, { - description = defs.description, - walkable = false, - climbable = true, - wield_image = vine_image_end, - drop = "", - sunlight_propagates = true, - paramtype = "light", - paramtype2 = "wallmounted", - buildable_to = false, - tiles = { vine_image_end }, - drawtype = drawtype, - inventory_image = vine_image_end, - groups = groups, - sounds = default.node_sound_leaves_defaults(), - selection_box = selection_box, - on_construct = function( pos ) - local timer = minetest.get_node_timer( pos ) - timer:start( math.random(5, 10) ) - end, - on_timer = function( pos ) - local node = minetest.get_node( pos ) - local bottom = {x=pos.x, y=pos.y-1, z=pos.z} - local bottom_node = minetest.get_node( bottom ) - if bottom_node.name == "air" then - if not ( math.random( defs.average_length ) == 1 ) then - minetest.set_node( pos, { name = vine_name_middle, param2 = node.param2 } ) - minetest.set_node( bottom, { name = node.name, param2 = node.param2 } ) - local timer = minetest.get_node_timer( bottom_node ) - timer:start( math.random(5, 10) ) - end - end - end, - after_dig_node = function(pos, node, oldmetadata, user) - vines.dig_vine( pos, drop_node, user ) - end - }) - - minetest.register_node( vine_name_middle, { - description = S("Matured").." "..defs.description, - walkable = false, - climbable = true, - drop = "", - sunlight_propagates = true, - paramtype = "light", - paramtype2 = "wallmounted", - buildable_to = false, - tiles = { vine_image_middle }, - wield_image = vine_image_middle, - drawtype = drawtype, - inventory_image = vine_image_middle, - groups = groups, - sounds = default.node_sound_leaves_defaults(), - selection_box = selection_box, - on_destruct = function( pos ) - local bottom = {x=pos.x, y=pos.y-1, z=pos.z} - local bottom_node = minetest.get_node( bottom ) - if minetest.get_item_group( bottom_node.name, "vines") > 0 then - minetest.after( 0, minetest.remove_node, bottom ) - end - end, - after_dig_node = function( pos, node, oldmetadata, user ) - vines.dig_vine( pos, drop_node, user ) - end - }) - - biome_lib:spawn_on_surfaces( biome ) - - local override_nodes = function( nodes, def ) - local function override( index, registered ) - local node = nodes[ index ] - if index > #nodes then return registered end - if minetest.registered_nodes[node] then - minetest.override_item( node, def ) - registered[#registered+1] = node - end - override( index+1, registered ) - end - override( 1, {} ) - end - - override_nodes( biome.spawn_surfaces,{ - on_destruct = function( pos ) - local pos_min = { x = pos.x -1, y = pos.y - 1, z = pos.z - 1 } - local pos_max = { x = pos.x +1, y = pos.y + 1, z = pos.z + 1 } - local positions = minetest.find_nodes_in_area( pos_min, pos_max, "group:vines" ) - for index, position in pairs(positions) do - minetest.remove_node( position ) - end - end - }) - -end - -vines.dig_vine = function( pos, node_name, user ) - --only dig give the vine if shears are used - if not user then return false end - local wielded = user:get_wielded_item() - if 'vines:shears' == wielded:get_name() then - local inv = user:get_inventory() - if inv then - inv:add_item("main", ItemStack( node_name )) - end - end -end diff --git a/vines/init.lua b/vines/init.lua index 2abbda0..cce7cca 100644 --- a/vines/init.lua +++ b/vines/init.lua @@ -1,17 +1,406 @@ vines = { - name = 'vines', - recipes = {} + name = 'vines', + recipes = {} } -- support for i18n local S = plantlife_i18n.gettext -dofile( minetest.get_modpath( vines.name ) .. "/functions.lua" ) -dofile( minetest.get_modpath( vines.name ) .. "/aliases.lua" ) -dofile( minetest.get_modpath( vines.name ) .. "/recipes.lua" ) -dofile( minetest.get_modpath( vines.name ) .. "/crafts.lua" ) -dofile( minetest.get_modpath( vines.name ) .. "/nodes.lua" ) -dofile( minetest.get_modpath( vines.name ) .. "/shear.lua" ) -dofile( minetest.get_modpath( vines.name ) .. "/vines.lua" ) +-- ITEMS + +minetest.register_craftitem("vines:vines", { + description = S("Vines"), + inventory_image = "vines_item.png", + group = {vines = 1, flammable = 2} +}) + +-- FUNCTIONS + +local function dig_down(pos, node, digger) + + if digger == nil then return end + + local np = {x = pos.x, y = pos.y - 1, z = pos.z} + local nn = minetest.get_node(np) + + if minetest.get_item_group(nn.name, "vines") > 0 then + minetest.node_dig(np, nn, digger) + end +end + + +vines.register_vine = function( name, defs, biome ) + + local groups = {vines = 1, snappy = 3, flammable = 2, attached_node = 1} + local vine_name_end = 'vines:' .. name .. '_end' + local vine_name_middle = 'vines:' .. name .. '_middle' + local vine_image_end = "vines_" .. name .. "_end.png" + local vine_image_middle = "vines_" .. name .. "_middle.png" + local drop_node = vine_name_end + + biome.spawn_plants = {vine_name_end} + + local vine_group = 'group:' .. name .. '_vines' + + biome.spawn_surfaces[#biome.spawn_surfaces + 1] = vine_group + + local selection_box = {type = "wallmounted",} + local drawtype = 'signlike' + + -- different properties for bottom and side vines. + if not biome.spawn_on_side then + + selection_box = { + type = "fixed", fixed = { -0.4, -1/2, -0.4, 0.4, 1/2, 0.4 } + } + + drawtype = 'plantlike' + end + + minetest.register_node(vine_name_end, { + description = defs.description, + walkable = false, + climbable = true, + wield_image = vine_image_end, + drop = "vines:vines", + sunlight_propagates = true, + paramtype = "light", + paramtype2 = "wallmounted", + buildable_to = false, + tiles = {vine_image_end}, + drawtype = drawtype, + inventory_image = vine_image_end, + groups = groups, + sounds = default.node_sound_leaves_defaults(), + selection_box = selection_box, + + on_construct = function(pos) + + local timer = minetest.get_node_timer(pos) + + timer:start(math.random(5, 10)) + end, + + on_timer = function(pos) + + local node = minetest.get_node(pos) + local bottom = {x = pos.x, y = pos.y - 1, z = pos.z} + local bottom_node = minetest.get_node( bottom ) + + if bottom_node.name == "air" then + + if not math.random(defs.average_length) == 1 then + + minetest.set_node(pos, { + name = vine_name_middle, param2 = node.param2}) + + minetest.set_node(bottom, { + name = node.name, param2 = node.param2}) + + local timer = minetest.get_node_timer(bottom_node) + + timer:start(math.random(5, 10)) + end + end + end, + + after_dig_node = function(pos, node, metadata, digger) + dig_down(pos, node, digger) + end, + }) + + minetest.register_node( vine_name_middle, { + description = S("Matured") .. " " .. defs.description, + walkable = false, + climbable = true, + drop = "vines:vines", + sunlight_propagates = true, + paramtype = "light", + paramtype2 = "wallmounted", + buildable_to = false, + tiles = {vine_image_middle}, + wield_image = vine_image_middle, + drawtype = drawtype, + inventory_image = vine_image_middle, + groups = groups, + sounds = default.node_sound_leaves_defaults(), + selection_box = selection_box, + + after_dig_node = function(pos, node, metadata, digger) + dig_down(pos, node, digger) + end, + }) + + biome_lib:spawn_on_surfaces(biome) +end + +-- ALIASES + +-- used to remove the old vine nodes and give room for the new. +minetest.register_alias( 'vines:root', 'air' ) +minetest.register_alias( 'vines:root_rotten', 'air' ) +minetest.register_alias( 'vines:vine', 'air' ) +minetest.register_alias( 'vines:vine_rotten', 'air' ) +minetest.register_alias( 'vines:side', 'air' ) +minetest.register_alias( 'vines:side_rotten', 'air' ) +minetest.register_alias( 'vines:jungle', 'air' ) +minetest.register_alias( 'vines:jungle_rotten', 'air' ) +minetest.register_alias( 'vines:willow', 'air' ) +minetest.register_alias( 'vines:willow_rotten', 'air' ) + +-- CRAFTS + +minetest.register_craft({ + output = 'vines:rope_block', + recipe = { + {'group:vines', 'group:vines', 'group:vines'}, + {'group:vines', 'group:wood', 'group:vines'}, + {'group:vines', 'group:vines', 'group:vines'}, + } +}) + +if minetest.get_modpath("moreblocks") then + + minetest.register_craft({ + output = 'vines:rope_block', + recipe = { + {'moreblocks:rope', 'moreblocks:rope', 'moreblocks:rope'}, + {'moreblocks:rope', 'group:wood', 'moreblocks:rope'}, + {'moreblocks:rope', 'moreblocks:rope', 'moreblocks:rope'}, + } + }) +end + +minetest.register_craft({ + output = 'vines:shears', + recipe = { + {'', 'default:steel_ingot', ''}, + {'group:stick', 'group:wood', 'default:steel_ingot'}, + {'', '', 'group:stick'} + } +}) + +-- NODES + +minetest.register_node("vines:rope_block", { + description = S("Rope"), + sunlight_propagates = true, + paramtype = "light", + tiles = { + "default_wood.png^vines_rope.png", + "default_wood.png^vines_rope.png", + "default_wood.png", + "default_wood.png", + "default_wood.png^vines_rope.png", + "default_wood.png^vines_rope.png", + }, + groups = {flammable = 2, choppy = 2, oddly_breakable_by_hand = 1}, + + after_place_node = function(pos) + + local p = {x = pos.x, y = pos.y - 1, z = pos.z} + local n = minetest.get_node(p) + + if n.name == "air" then + minetest.add_node(p, {name = "vines:rope_end"}) + end + end, + + after_dig_node = function(pos, node, digger) + + local p = {x = pos.x, y = pos.y - 1, z = pos.z} + local n = minetest.get_node(p) + + while n.name == 'vines:rope' or n.name == 'vines:rope_end' do + + minetest.remove_node(p) + + p = {x = p.x, y = p.y - 1, z = p.z} + n = minetest.get_node(p) + end + end +}) + +minetest.register_node("vines:rope", { + description = S("Rope"), + walkable = false, + climbable = true, + sunlight_propagates = true, + paramtype = "light", + drop = {}, + tiles = {"vines_rope.png"}, + drawtype = "plantlike", + groups = {flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_leaves_defaults(), + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, +}) + +minetest.register_node("vines:rope_end", { + description = S("Rope"), + walkable = false, + climbable = true, + sunlight_propagates = true, + paramtype = "light", + drop = {}, + tiles = {"vines_rope_end.png"}, + drawtype = "plantlike", + groups = {flammable = 2, not_in_creative_inventory = 1}, + sounds = default.node_sound_leaves_defaults(), + + after_place_node = function(pos) + + local yesh = {x = pos.x, y = pos.y - 1, z = pos.z} + + minetest.add_node(yesh, {name = "vines:rope"}) + end, + + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + + on_construct = function(pos) + + local timer = minetest.get_node_timer(pos) + + timer:start(1) + end, + + on_timer = function( pos, elapsed ) + + local p = {x = pos.x, y = pos.y - 1, z = pos.z} + local n = minetest.get_node(p) + + if n.name == "air" then + + minetest.set_node(pos, {name = "vines:rope"}) + minetest.add_node(p, {name = "vines:rope_end"}) + else + + local timer = minetest.get_node_timer(pos) + + timer:start(1) + end + end +}) + +-- SHEARS + +minetest.register_tool("vines:shears", { + description = S("Shears"), + inventory_image = "vines_shears.png", + wield_image = "vines_shears.png", + stack_max = 1, + max_drop_level = 3, + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level = 1, + groupcaps = { + snappy = {times = {[3] = 0.2}, uses = 60, maxlevel = 3}, + } + }, +}) + +-- VINES + +vines.register_vine('root', + {description = S("Roots"), average_length = 9}, { + choose_random_wall = true, + avoid_nodes = {"vines:root_middle"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 10, + spawn_surfaces = { + "default:dirt_with_grass", + "default:dirt" + }, + spawn_on_bottom = true, + plantlife_limit = -0.6, + humidity_min = 0.4, +}) + +vines.register_vine('vine', + {description = S("Vines"), average_length = 5}, { + choose_random_wall = true, + avoid_nodes = {"group:vines"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 100, + spawn_surfaces = { +-- "default:leaves", + "default:jungleleaves", + "moretrees:jungletree_leaves_red", + "moretrees:jungletree_leaves_yellow", + "moretrees:jungletree_leaves_green" + }, + spawn_on_bottom = true, + plantlife_limit = -0.9, + humidity_min = 0.7, +}) + +vines.register_vine('side', + {description = S("Vines"), average_length = 6}, { + choose_random_wall = true, + avoid_nodes = {"group:vines", "default:apple"}, + avoid_radius = 3, + spawn_delay = 500, + spawn_chance = 100, + spawn_surfaces = { +-- "default:leaves", + "default:jungleleaves", + "moretrees:jungletree_leaves_red", + "moretrees:jungletree_leaves_yellow", + "moretrees:jungletree_leaves_green" + }, + spawn_on_side = true, + plantlife_limit = -0.9, + humidity_min = 0.4, +}) + +vines.register_vine("jungle", + {description = S("Jungle Vines"), average_length = 7}, { + choose_random_wall = true, + neighbors = { + "default:jungleleaves", + "moretrees:jungletree_leaves_red", + "moretrees:jungletree_leaves_yellow", + "moretrees:jungletree_leaves_green" + }, + avoid_nodes = { + "vines:jungle_middle", + "vines:jungle_end", + }, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 100, + spawn_surfaces = { + "default:jungletree", + "moretrees:jungletree_trunk" + }, + spawn_on_side = true, + plantlife_limit = -0.9, + humidity_min = 0.2, +}) + +vines.register_vine( 'willow', + {description = S("Willow Vines"), average_length = 9}, { + choose_random_wall = true, + avoid_nodes = {"vines:willow_middle"}, + avoid_radius = 5, + near_nodes = {'default:water_source'}, + near_nodes_size = 1, + near_nodes_count = 1, + near_nodes_vertical = 7, + plantlife_limit = -0.8, + spawn_chance = 10, + spawn_delay = 500, + spawn_on_side = true, + spawn_surfaces = {"moretrees:willow_leaves"}, + humidity_min = 0.5 +}) + print(S("[Vines] Loaded!")) diff --git a/vines/nodes.lua b/vines/nodes.lua deleted file mode 100644 index 4e4d707..0000000 --- a/vines/nodes.lua +++ /dev/null @@ -1,86 +0,0 @@ --- support for i18n -local S = plantlife_i18n.gettext - -minetest.register_node("vines:rope_block", { - description = S("Rope"), - sunlight_propagates = true, - paramtype = "light", - tiles = { - "default_wood.png^vines_rope.png", - "default_wood.png^vines_rope.png", - "default_wood.png", - "default_wood.png", - "default_wood.png^vines_rope.png", - "default_wood.png^vines_rope.png", - }, - groups = { flammable=2, choppy=2, oddly_breakable_by_hand=1 }, - after_place_node = function(pos) - local p = {x=pos.x, y=pos.y-1, z=pos.z} - local n = minetest.get_node(p) - if n.name == "air" then - minetest.add_node(p, {name="vines:rope_end"}) - end - end, - after_dig_node = function(pos, node, digger) - local p = {x=pos.x, y=pos.y-1, z=pos.z} - local n = minetest.get_node(p) - while ( n.name == 'vines:rope' or n.name == 'vines:rope_end' ) do - minetest.remove_node(p) - p = {x=p.x, y=p.y-1, z=p.z} - n = minetest.get_node(p) - end - end -}) - -minetest.register_node("vines:rope", { - description = S("Rope"), - walkable = false, - climbable = true, - sunlight_propagates = true, - paramtype = "light", - drop = "", - tiles = { "vines_rope.png" }, - drawtype = "plantlike", - groups = {flammable=2, not_in_creative_inventory=1}, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, - }, -}) - -minetest.register_node("vines:rope_end", { - description = S("Rope"), - walkable = false, - climbable = true, - sunlight_propagates = true, - paramtype = "light", - drop = "", - tiles = { "vines_rope_end.png" }, - drawtype = "plantlike", - groups = {flammable=2, not_in_creative_inventory=1}, - sounds = default.node_sound_leaves_defaults(), - after_place_node = function(pos) - local yesh = {x = pos.x, y= pos.y-1, z=pos.z} - minetest.add_node(yesh, {name="vines:rope"}) - end, - selection_box = { - type = "fixed", - fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, - }, - on_construct = function( pos ) - local timer = minetest.get_node_timer( pos ) - timer:start( 1 ) - end, - on_timer = function( pos, elapsed ) - local p = {x=pos.x, y=pos.y-1, z=pos.z} - local n = minetest.get_node(p) - if n.name == "air" then - minetest.set_node(pos, {name="vines:rope"}) - minetest.add_node(p, {name="vines:rope_end"}) - else - local timer = minetest.get_node_timer( pos ) - timer:start( 1 ) - end - end -}) diff --git a/vines/recipes.lua b/vines/recipes.lua deleted file mode 100644 index 991712b..0000000 --- a/vines/recipes.lua +++ /dev/null @@ -1,11 +0,0 @@ -vines.recipes['rope_block'] = { - {'', 'group:wood', ''}, - {'', 'group:vines', ''}, - {'', 'group:vines', ''} -} - -vines.recipes['shears'] = { - {'', 'default:steel_ingot', ''}, - {'group:stick', 'group:wood', 'default:steel_ingot'}, - {'', '', 'group:stick'} -} diff --git a/vines/shear.lua b/vines/shear.lua deleted file mode 100644 index 6ce498e..0000000 --- a/vines/shear.lua +++ /dev/null @@ -1,18 +0,0 @@ --- support for i18n -local S = plantlife_i18n.gettext - -minetest.register_tool("vines:shears", { - description = S("Shears"), - inventory_image = "vines_shears.png", - wield_image = "vines_shears.png", - stack_max = 1, - max_drop_level=3, - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=0, - groupcaps={ - snappy={times={[3]=0.2}, uses=60, maxlevel=3}, - wool={times={[3]=0.2}, uses=60, maxlevel=3} - } - }, -}) diff --git a/vines/vines.lua b/vines/vines.lua deleted file mode 100644 index 1643972..0000000 --- a/vines/vines.lua +++ /dev/null @@ -1,108 +0,0 @@ --- support for i18n -local S = plantlife_i18n.gettext - -vines.register_vine( 'root', { - description = S("Roots"), - average_length = 9, -},{ - choose_random_wall = true, - avoid_nodes = {"vines:root_middle"}, - avoid_radius = 5, - spawn_delay = 500, - spawn_chance = 10, - spawn_surfaces = { - "default:dirt_with_grass", - "default:dirt" - }, - spawn_on_bottom = true, - plantlife_limit = -0.6, - humidity_min = 0.4, -}) - -vines.register_vine( 'vine', { - description = S("Vines"), - average_length = 5, -},{ - choose_random_wall = true, - avoid_nodes = {"group:vines"}, - avoid_radius = 5, - spawn_delay = 500, - spawn_chance = 100, - spawn_surfaces = { - "default:leaves", - "default:jungleleaves", - "moretrees:jungletree_leaves_red", - "moretrees:jungletree_leaves_yellow", - "moretrees:jungletree_leaves_green" - }, - spawn_on_bottom = true, - plantlife_limit = -0.9, - humidity_min = 0.7, -}) - -vines.register_vine( 'side', { - description = S("Vines"), - average_length = 6, -},{ - choose_random_wall = true, - avoid_nodes = {"group:vines", "default:apple"}, - avoid_radius = 3, - spawn_delay = 500, - spawn_chance = 100, - spawn_surfaces = { - "default:leaves", - "default:jungleleaves", - "moretrees:jungletree_leaves_red", - "moretrees:jungletree_leaves_yellow", - "moretrees:jungletree_leaves_green" - }, - spawn_on_side = true, - plantlife_limit = -0.9, - humidity_min = 0.4, -}) - -vines.register_vine( "jungle", { - description = S("Jungle Vines"), - average_length = 7, -},{ - choose_random_wall = true, - neighbors = { - "default:jungleleaves", - "moretrees:jungletree_leaves_red", - "moretrees:jungletree_leaves_yellow", - "moretrees:jungletree_leaves_green" - }, - avoid_nodes = { - "vines:jungle_middle", - "vines:jungle_end", - }, - avoid_radius = 5, - spawn_delay = 500, - spawn_chance = 100, - spawn_surfaces = { - "default:jungletree", - "moretrees:jungletree_trunk" - }, - spawn_on_side = true, - plantlife_limit = -0.9, - humidity_min = 0.2, -}) - -vines.register_vine( 'willow', { - description = S("Willow Vines"), - average_length = 9, -},{ - choose_random_wall = true, - avoid_nodes = { "vines:willow_middle" }, - avoid_radius = 5, - near_nodes = { 'default:water_source' }, - near_nodes_size = 1, - near_nodes_count = 1, - near_nodes_vertical = 7, - plantlife_limit = -0.8, - spawn_chance = 10, - spawn_delay = 500, - spawn_on_side = true, - spawn_surfaces = {"moretrees:willow_leaves"}, - humidity_min = 0.5 -}) diff --git a/woodsoils/generating.lua b/woodsoils/generating.lua index 087e03c..a044a9b 100644 --- a/woodsoils/generating.lua +++ b/woodsoils/generating.lua @@ -50,24 +50,24 @@ abstract_woodsoils.place_soil = function(pos) local node_3b = minetest.get_node(radius_3b) -- Dirt with Leaves 1 if minetest.get_item_group(minetest.get_node(radius_1a).name, "soil") > 0 then - minetest.set_node(radius_1a, {name="woodsoils:dirt_with_leaves_1"}) + minetest.swap_node(radius_1a, {name="woodsoils:dirt_with_leaves_1"}) end if minetest.get_item_group(minetest.get_node(radius_1b).name, "soil") > 0 then - minetest.set_node(radius_1b, {name="woodsoils:dirt_with_leaves_1"}) + minetest.swap_node(radius_1b, {name="woodsoils:dirt_with_leaves_1"}) end -- Grass with Leaves 2 if string.find(node_2a.name, "dirt_with_grass") then - minetest.set_node(radius_2a, {name="woodsoils:grass_with_leaves_2"}) + minetest.swap_node(radius_2a, {name="woodsoils:grass_with_leaves_2"}) end if string.find(node_2b.name, "dirt_with_grass") then - minetest.set_node(radius_2b, {name="woodsoils:grass_with_leaves_2"}) + minetest.swap_node(radius_2b, {name="woodsoils:grass_with_leaves_2"}) end -- Grass with Leaves 1 if string.find(node_3a.name, "dirt_with_grass") then - minetest.set_node(radius_3a, {name="woodsoils:grass_with_leaves_1"}) + minetest.swap_node(radius_3a, {name="woodsoils:grass_with_leaves_1"}) end if string.find(node_3b.name, "dirt_with_grass") then - minetest.set_node(radius_3b, {name="woodsoils:grass_with_leaves_1"}) + minetest.swap_node(radius_3b, {name="woodsoils:grass_with_leaves_1"}) end end end @@ -143,7 +143,7 @@ minetest.register_abm({ end if height < 4 then if minetest.get_node(pos).name == "air" then - minetest.set_node(pos, {name="default:papyrus"}) + minetest.swap_node(pos, {name="default:papyrus"}) end end end diff --git a/youngtrees/init.lua b/youngtrees/init.lua index ddd4637..ae4f9e6 100644 --- a/youngtrees/init.lua +++ b/youngtrees/init.lua @@ -117,17 +117,17 @@ abstract_youngtrees.grow_youngtree_node = function(pos, height) if minetest.get_node(right_here).name == "air" -- instead of check_air = true, or minetest.get_node(right_here).name == "default:junglegrass" then if height == 1 then - minetest.set_node(right_here, {name="youngtrees:youngtree_top"}) + minetest.swap_node(right_here, {name="youngtrees:youngtree_top"}) end if height == 2 then - minetest.set_node(right_here, {name="youngtrees:youngtree_bottom"}) - minetest.set_node(above_right_here, {name="youngtrees:youngtree_top"}) + minetest.swap_node(right_here, {name="youngtrees:youngtree_bottom"}) + minetest.swap_node(above_right_here, {name="youngtrees:youngtree_top"}) end if height == 3 then local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z} - minetest.set_node(right_here, {name="youngtrees:youngtree_bottom"}) - minetest.set_node(above_right_here, {name="youngtrees:youngtree_middle"}) - minetest.set_node(two_above_right_here, {name="youngtrees:youngtree_top"}) + minetest.swap_node(right_here, {name="youngtrees:youngtree_bottom"}) + minetest.swap_node(above_right_here, {name="youngtrees:youngtree_middle"}) + minetest.swap_node(two_above_right_here, {name="youngtrees:youngtree_top"}) end end end |