use swap_node() where possible, for speed

This commit is contained in:
Vanessa Dannenberg 2018-10-25 10:27:54 -04:00
parent 2c7a776c7f
commit 77093e428a
22 changed files with 156 additions and 156 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,
})

View File

@ -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()

View File

@ -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({

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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({

View File

@ -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

View File

@ -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

View File

@ -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 .. ","

View File

@ -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

View File

@ -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,

View File

@ -51,8 +51,8 @@ vines.register_vine = function( name, defs, biome )
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 } )
minetest.swap_node( pos, { name = vine_name_middle, param2 = node.param2 } )
minetest.swap_node( bottom, { name = node.name, param2 = node.param2 } )
local timer = minetest.get_node_timer( bottom_node )
timer:start( math.random(5, 10) )
end
@ -83,7 +83,7 @@ vines.register_vine = function( name, defs, biome )
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 )
minetest.after( 0, minetest.swap_node, bottom, biome_lib.air )
end
end,
after_dig_node = function( pos, node, oldmetadata, user )
@ -112,7 +112,7 @@ vines.register_vine = function( name, defs, biome )
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 )
minetest.swap_node(position, biome_lib.air)
end
end
})

View File

@ -25,7 +25,7 @@ minetest.register_node("vines:rope_block", {
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)
minetest.swap_node(p, biome_lib.air)
p = {x=p.x, y=p.y-1, z=p.z}
n = minetest.get_node(p)
end
@ -76,7 +76,7 @@ minetest.register_node("vines:rope_end", {
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.swap_node(pos, {name="vines:rope"})
minetest.add_node(p, {name="vines:rope_end"})
else
local timer = minetest.get_node_timer( pos )

View File

@ -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

View File

@ -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