From 87031b60518731f62dbce0ffb1601b0c34d506c9 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Thu, 21 Jan 2016 14:59:28 +0000 Subject: [PATCH] Optimize code, allfaces leaves by default, leaves walkable by default --- crystal.lua | 41 +++++++++++++++------------ dirt.lua | 52 +++++++++++++++++++---------------- extra.lua | 20 +++++++------- fences.lua | 48 ++++++++++++++++---------------- fishing.lua | 9 ++++-- flowers.lua | 4 +-- gates.lua | 12 ++++++-- init.lua | 5 ++-- leaves.lua | 28 +++++++++---------- mushroom.lua | 8 ++++-- papyrus.lua | 6 +++- plantlife.lua | 21 ++++++-------- sapling.lua | 13 ++++++--- sealife.lua | 45 +++++++++++++++++++----------- textures/banana_leaf.png | Bin 444 -> 421 bytes textures/banana_leaf_old.png | Bin 0 -> 444 bytes water.lua | 10 +++++++ 17 files changed, 187 insertions(+), 135 deletions(-) create mode 100644 textures/banana_leaf_old.png diff --git a/crystal.lua b/crystal.lua index 3d0f37c..f5eb490 100644 --- a/crystal.lua +++ b/crystal.lua @@ -6,7 +6,7 @@ minetest.register_node("ethereal:crystal_spike", { inventory_image = "crystal_spike.png", wield_image = "crystal_spike.png", paramtype = "light", - light_source = default.LIGHT_MAX - 7, + light_source = 7, sunlight_propagates = true, walkable = false, damage_per_second = 1, @@ -38,7 +38,7 @@ minetest.register_craft({ minetest.register_node("ethereal:crystal_block", { description = "Crystal Block", tiles = {"crystal_block.png"}, - light_source = default.LIGHT_MAX - 5, + light_source = 9, is_ground_content = false, groups = {cracky = 1, level = 2, puts_out_fire = 1}, sounds = default.node_sound_glass_defaults(), @@ -152,28 +152,33 @@ minetest.register_tool("ethereal:shovel_crystal", { on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type ~= "node" then return end + if pointed_thing.type ~= "node" then + return + end -- Check if node protected - if not minetest.is_protected(pointed_thing.under, user:get_player_name()) then + if minetest.is_protected(pointed_thing.under, user:get_player_name()) then + return + end - local pos = pointed_thing.under - local nn = minetest.get_node_or_nil(pos) - if nn then nn = nn.name else return end + local pos = pointed_thing.under + local nn = minetest.get_node(pos).name - -- Is node dirt, sand or gravel - if minetest.get_item_group(nn, "crumbly") > 0 then + -- Is node dirt, sand or gravel + if minetest.get_item_group(nn, "crumbly") > 0 then - local inv = user:get_inventory() + local inv = user:get_inventory() - minetest.remove_node(pointed_thing.under) - nodeupdate(pos) - - inv:add_item("main", {name = nn}) - itemstack:add_wear(65535 / 100) -- 111 uses - minetest.sound_play("default_dirt_footstep", {pos = pos, gain = 0.35}) - return itemstack - end + minetest.remove_node(pointed_thing.under) + + nodeupdate(pos) + + inv:add_item("main", {name = nn}) + itemstack:add_wear(65535 / 100) -- 111 uses + + minetest.sound_play("default_dirt_footstep", {pos = pos, gain = 0.35}) + + return itemstack end end, }) diff --git a/dirt.lua b/dirt.lua index 3884919..ae0f6cd 100644 --- a/dirt.lua +++ b/dirt.lua @@ -36,15 +36,14 @@ minetest.register_craft({ cooktime = 3, }) -local dirt = {} -dirt.type = { - {"Bamboo"}, {"Jungle"}, {"Grove"}, {"Prairie"}, {"Cold"}, - {"Crystal"}, {"Mushroom"}, {"Fiery"}, {"Gray"}, +local dirts = { + "Bamboo", "Jungle", "Grove", "Prairie", "Cold", + "Crystal", "Mushroom", "Fiery", "Gray" } -for _, row in pairs(dirt.type) do +for n = 1, #dirts do - local desc = row[1] + local desc = dirts[n] local name = desc:lower() minetest.register_node("ethereal:"..name.."_dirt", { @@ -80,31 +79,34 @@ minetest.register_abm({ chance = 2, catch_up = false, action = function(pos, node) + local count_grasses = {} local curr_max = 0 local curr_type = "ethereal:green_dirt" -- fallback - local positions = minetest.find_nodes_in_area_under_air( - {x = (pos.x - 2), y = (pos.y - 1), z = (pos.z - 2)}, - {x = (pos.x + 2), y = (pos.y + 1), z = (pos.z + 2)}, + local positions = minetest.find_nodes_in_area( + {x = (pos.x - 1), y = (pos.y - 2), z = (pos.z - 1)}, + {x = (pos.x + 1), y = (pos.y + 2), z = (pos.z + 1)}, "group:ethereal_grass") - local n + -- count new grass nodes for _,p in pairs(positions) do - n = minetest.get_node_or_nil(p) - if n and n.name then - count_grasses[n.name] = (count_grasses[n.name] or 0) + 1 - -- we found a grass type with more than current max - if count_grasses[n.name] > curr_max then - curr_max = count_grasses[n.name] - curr_type = n.name - end + + local n = minetest.get_node(p).name + + count_grasses[n] = (count_grasses[n] or 0) + 1 + + -- we found a grass type with more than current max + if count_grasses[n] > curr_max then + curr_max = count_grasses[n] + curr_type = n end end + minetest.swap_node(pos, {name = curr_type}) end }) --- make dirt with dry grass spreads like ethereal grasses +-- have dirt with dry grass spreads like ethereal grasses minetest.override_item("default:dirt_with_dry_grass", { groups = {crumbly = 3, soil = 1, ethereal_grass = 1}, }) @@ -116,21 +118,25 @@ minetest.register_abm({ chance = 20, catch_up = false, action = function(pos, node) + local name = minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }).name + local nodedef = minetest.registered_nodes[name] - if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or - nodedef.paramtype == "light") and - nodedef.liquidtype == "none") then + + if name ~= "ignore" and nodedef + and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") + and nodedef.liquidtype == "none") then + minetest.swap_node(pos, {name = "default:dirt"}) end end }) --- If Baked Clay mod not active, make Red and Orange nodes +-- If Baked Clay mod not active, make Red, Orange and Grey nodes if not minetest.get_modpath("bakedclay") then minetest.register_node(":bakedclay:red", { diff --git a/extra.lua b/extra.lua index 888b6f8..240a47f 100644 --- a/extra.lua +++ b/extra.lua @@ -1,4 +1,4 @@ --- Vines +-- vines minetest.register_node("ethereal:vine", { description = "Vine", drawtype = "signlike", @@ -106,8 +106,6 @@ minetest.register_craft({ output = "ethereal:glostone", recipe = { {"default:torch", "default:stone", "dye:yellow"}, - {"", "", ""}, - {"", "", ""}, } }) @@ -287,15 +285,17 @@ minetest.register_tool("ethereal:light_staff", { return end - local node = minetest.get_node_or_nil(pos) - if node then node = node.name else return end + local node = minetest.get_node(pos).name if node == "default:stone" or node == "default:desert_stone" then - minetest.swap_node(pos, {name="ethereal:glostone"}) + + minetest.swap_node(pos, {name = "ethereal:glostone"}) + if not minetest.setting_getbool("creative_mode") then itemstack:add_wear(65535 / 149) -- 150 uses end + return itemstack end @@ -319,13 +319,13 @@ minetest.register_on_generated(function(minp, maxp) end local bpos + local coal = minetest.find_nodes_in_area_under_air(minp, maxp, "default:stone_with_coal") - for key, pos in pairs(minetest.find_nodes_in_area_under_air(minp, maxp, "default:stone_with_coal")) do + for n = 1, #coal do - bpos = {x = pos.x, y = pos.y + 1, z = pos.z } + bpos = {x = coal[n].x, y = coal[n].y + 1, z = coal[n].z } - if math.random(1, 2) == 1 - and minetest.get_node(bpos).name == "air" then + if math.random(1, 2) == 1 then if bpos.y > -3000 and bpos.y < -2000 then minetest.swap_node(bpos, {name = "ethereal:illumishroom3"}) diff --git a/fences.lua b/fences.lua index fbe76f8..a013462 100644 --- a/fences.lua +++ b/fences.lua @@ -15,29 +15,31 @@ local fences = { for _, row in pairs(fences) do -minetest.register_node("ethereal:fence_"..row[1], { - description = row[2].." Fence", - drawtype = "fencelike", - is_ground_content = false, - tiles = {row[3]}, - inventory_image = "default_fence_overlay.png^"..row[3].."^default_fence_overlay.png^[makealpha:255,126,126", - wield_image = "default_fence_overlay.png^"..row[3].."^default_fence_overlay.png^[makealpha:255,126,126", - paramtype = "light", - sunlight_propagates = true, - selection_box = { - type = "fixed", - fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, - }, - groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, - sounds = default.node_sound_wood_defaults(), -}) + minetest.register_node("ethereal:fence_"..row[1], { + description = row[2].." Fence", + drawtype = "fencelike", + is_ground_content = false, + tiles = {row[3]}, + inventory_image = "default_fence_overlay.png^" .. row[3] + .. "^default_fence_overlay.png^[makealpha:255,126,126", + wield_image = "default_fence_overlay.png^" .. row[3] + .. "^default_fence_overlay.png^[makealpha:255,126,126", + paramtype = "light", + sunlight_propagates = true, + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + sounds = default.node_sound_wood_defaults(), + }) -minetest.register_craft({ - output = "ethereal:fence_"..row[1].." 4", - recipe = { - {row[4], "group:stick", row[4]}, - {row[4], "group:stick", row[4]}, - } -}) + minetest.register_craft({ + output = "ethereal:fence_"..row[1].." 4", + recipe = { + {row[4], "group:stick", row[4]}, + {row[4], "group:stick", row[4]}, + } + }) end diff --git a/fishing.lua b/fishing.lua index c8d1cbf..dbcf205 100644 --- a/fishing.lua +++ b/fishing.lua @@ -87,10 +87,11 @@ minetest.register_craftitem("ethereal:fishing_rod_baited", { liquids_pointable = true, on_use = function (itemstack, user, pointed_thing) - if pointed_thing.type ~= "node" then return end + if pointed_thing.type ~= "node" then + return + end - local node = minetest.get_node_or_nil(pointed_thing.under) - if node then node = node.name else return end + local node = minetest.get_node(pointed_thing.under).name if (node == "default:water_source" or node == "default:river_water_source") @@ -100,7 +101,9 @@ minetest.register_craftitem("ethereal:fishing_rod_baited", { local inv = user:get_inventory() if inv:room_for_item("main", {name = type}) then + inv:add_item("main", {name = type}) + return {name = "ethereal:fishing_rod"} else minetest.chat_send_player(user:get_player_name(), diff --git a/flowers.lua b/flowers.lua index cf9af0b..1f902a0 100644 --- a/flowers.lua +++ b/flowers.lua @@ -90,9 +90,7 @@ minetest.register_abm({ return end - if minetest.get_node(seedling).name == "air" then - minetest.swap_node(seedling, {name = node.name}) - end + minetest.swap_node(seedling, {name = node.name}) end end, }) diff --git a/gates.lua b/gates.lua index f669615..b351582 100644 --- a/gates.lua +++ b/gates.lua @@ -26,6 +26,7 @@ function gate_rightclick(pos, node) end node.name = split[1] .. "_" .. split[2] .. "_" .. name + minetest.swap_node(pos, node) minetest.sound_play("doors_door_"..sound, { @@ -60,7 +61,10 @@ minetest.register_node("ethereal:fencegate_"..row[1].."_open", { sunlight_propagates = true, is_ground_content = false, walkable = true, - groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_inventory = 1}, + groups = { + snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, + flammable = 2, not_in_inventory = 1 + }, drop = "ethereal:fencegate_"..row[1].."_closed", drawtype = "nodebox", node_box = { @@ -93,8 +97,10 @@ minetest.register_alias("ethereal:"..row[1].."gate_open", "ethereal:fencegate_". minetest.register_node("ethereal:fencegate_"..row[1].."_closed", { description = row[2].." Gate", tiles = {row[3]}, - inventory_image = "default_gate_overlay.png^"..row[3].."^default_gate_overlay.png^[makealpha:255,126,126", - wield_image = "default_gate_overlay.png^"..row[3].."^default_gate_overlay.png^[makealpha:255,126,126", + inventory_image = "default_gate_overlay.png^" .. row[3] + .. "^default_gate_overlay.png^[makealpha:255,126,126", + wield_image = "default_gate_overlay.png^" .. row[3] + .. "^default_gate_overlay.png^[makealpha:255,126,126", paramtype = "light", paramtype2 = "facedir", sunlight_propagates = true, diff --git a/init.lua b/init.lua index 3db774a..bab3852 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ --[[ - Minetest Ethereal Mod 1.19 (13th December 2015) + Minetest Ethereal Mod 1.19 (21st January 2016) Created by ChinChow @@ -9,7 +9,8 @@ ]] ethereal = {} -ethereal.leaftype = 0 -- 0 for 2D plantlike, 1 for 3D allfaces +ethereal.leaftype = 1 -- 0 for 2D plantlike, 1 for 3D allfaces +ethereal.leafwalk = true -- true for walkable leaves, false to fall through -- Set following to 1 to enable biome or 0 to disable ethereal.glacier = 1 -- Ice glaciers with snow diff --git a/leaves.lua b/leaves.lua index 2d36675..f4db22e 100644 --- a/leaves.lua +++ b/leaves.lua @@ -16,7 +16,7 @@ minetest.register_node("ethereal:acacia_leaves", { inventory_image = "moretrees_acacia_leaves.png", wield_image = "moretrees_acacia_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, visual_scale = 1.2, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, @@ -37,7 +37,7 @@ minetest.override_item("default:acacia_leaves", { inventory_image = "moretrees_acacia_leaves.png", wield_image = "moretrees_acacia_leaves.png", visual_scale = 1.2, - walkable = false, + walkable = ethereal.leafwalk, drop = { max_items = 1, items = { @@ -57,7 +57,7 @@ minetest.register_node("ethereal:willow_twig", { inventory_image = "willow_twig.png", wield_image = "willow_twig.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, visual_scale = 1.2, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, @@ -81,7 +81,7 @@ minetest.register_node("ethereal:redwood_leaves", { inventory_image = "redwood_leaves.png", wield_image = "redwood_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, drop = { @@ -101,7 +101,7 @@ minetest.override_item("default:leaves", { visual_scale = 1.2, inventory_image = "default_leaves.png", wield_image = "default_leaves.png", - walkable = false, + walkable = ethereal.leafwalk, drop = { max_items = 1, items = { @@ -120,7 +120,7 @@ minetest.register_node("ethereal:orange_leaves", { inventory_image = "orange_leaves.png", wield_image = "orange_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, drop = { @@ -140,7 +140,7 @@ minetest.override_item("default:jungleleaves", { visual_scale = 1.2, inventory_image = "default_jungleleaves.png", wield_image = "default_jungleleaves.png", - walkable = false, + walkable = ethereal.leafwalk, drop = { max_items = 1, items = { @@ -159,7 +159,7 @@ minetest.register_node("ethereal:bananaleaves", { inventory_image = "banana_leaf.png", wield_image = "banana_leaf.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, drop = { @@ -182,7 +182,7 @@ minetest.register_node("ethereal:yellowleaves", { inventory_image = "yellow_leaves.png", wield_image = "yellow_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1}, drop = { @@ -208,7 +208,7 @@ minetest.register_node("ethereal:palmleaves", { inventory_image = "moretrees_palm_leaves.png", wield_image = "moretrees_palm_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, drop = { @@ -231,7 +231,7 @@ minetest.register_node("ethereal:birch_leaves", { inventory_image = "moretrees_birch_leaves.png", wield_image = "moretrees_birch_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, drop = { @@ -252,7 +252,7 @@ minetest.override_item("default:pine_needles", { tiles = {"pine_leaves.png"}, inventory_image = "pine_leaves.png", wield_image = "pine_leaves.png", - walkable = false, + walkable = ethereal.leafwalk, drop = { max_items = 1, items = { @@ -273,7 +273,7 @@ minetest.register_node("ethereal:frost_leaves", { inventory_image = "ethereal_frost_leaves.png", wield_image = "ethereal_frost_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, puts_out_fire = 1}, drop = { @@ -347,7 +347,7 @@ minetest.register_node("ethereal:bamboo_leaves", { inventory_image = "bamboo_leaves.png", wield_image = "bamboo_leaves.png", paramtype = "light", - walkable = false, + walkable = ethereal.leafwalk, waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, drop = { diff --git a/mushroom.lua b/mushroom.lua index 39e14d2..8de756a 100644 --- a/mushroom.lua +++ b/mushroom.lua @@ -59,14 +59,16 @@ minetest.register_abm({ action = function(pos, node) if minetest.get_node_light(pos, nil) > 14 then + minetest.remove_node(pos) + return end local random = { - x = pos.x + math.random(-2,2), - y = pos.y + math.random(-1,1), - z = pos.z + math.random(-2,2) + x = pos.x + math.random(-2, 2), + y = pos.y + math.random(-1, 1), + z = pos.z + math.random(-2, 2) } local random_node = minetest.get_node_or_nil(random) diff --git a/papyrus.lua b/papyrus.lua index 24bc0a1..fe245b2 100644 --- a/papyrus.lua +++ b/papyrus.lua @@ -14,6 +14,7 @@ minetest.register_abm({ local high = 4 pos.y = pos.y - 1 + local nod = minetest.get_node_or_nil(pos) if not nod @@ -23,10 +24,11 @@ minetest.register_abm({ end if node.name == "ethereal:bamboo" then - high = 8 -- was 5 + high = 8 end pos.y = pos.y + 1 + local height = 0 while height < high @@ -40,8 +42,10 @@ minetest.register_abm({ if nod and nod.name == "air" and height < high then + if node.name == "ethereal:bamboo" and height == (high - 1) then + ethereal.add_tree({ x = pos.x, y = oripos, diff --git a/plantlife.lua b/plantlife.lua index 9395362..713b5ec 100644 --- a/plantlife.lua +++ b/plantlife.lua @@ -17,8 +17,7 @@ minetest.register_node("ethereal:fire_flower", { fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}, }, on_punch = function(pos, node, puncher) - --local item = puncher:get_wielded_item() - --local itemname = item:get_name() + puncher:punch(puncher, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 2} @@ -151,8 +150,9 @@ minetest.register_node("ethereal:crystalgrass", { -- Define Moss Types (Has grass textures on all sides) function ethereal.add_moss(typ, descr, texture, receipe_item) - minetest.register_node("ethereal:"..typ.."_moss", { - description = descr.." Moss", + + minetest.register_node("ethereal:" .. typ .. "_moss", { + description = descr .. " Moss", tiles = {texture}, groups = {crumbly = 3}, sounds = default.node_sound_dirt_defaults() @@ -170,7 +170,7 @@ ethereal.add_moss( "fiery", "Fiery", "ethereal_grass_fiery_top.png", "ethereal:d ethereal.add_moss( "gray", "Gray", "ethereal_grass_gray_top.png", "ethereal:snowygrass") ethereal.add_moss( "green", "Green", "default_grass.png", "default:jungleleaves") --- apple +-- fix apples hanging in sky when no tree around minetest.override_item("default:apple", { drop = "default:apple", }) @@ -341,7 +341,7 @@ minetest.register_node("ethereal:bamboo", { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} }, - groups = {choppy = 3, oddly_breakable_by_hand = 1, flammable = 2, tree = 1}, -- added tree + groups = {choppy = 3, oddly_breakable_by_hand = 1, flammable = 2, tree = 1}, sounds = default.node_sound_leaves_defaults(), after_dig_node = function(pos, node, metadata, digger) default.dig_up(pos, node, digger) @@ -364,13 +364,10 @@ minetest.register_node("ethereal:bamboo_sprout", { paramtype = "light", sunlight_propagates = true, walkable = false, - --buildable_to = true, - --groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 2}, groups = { snappy = 3, attached_node = 1, flammable = 2, dig_immediate = 3, ethereal_sapling = 1 }, - --sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_defaults(), selection_box = { type = "fixed", @@ -462,7 +459,7 @@ for _,items in pairs({ {"default:ice", "default:snow"}, {"ethereal:dry_dirt", "default:desert_sand"}, }) do - local a,b = unpack(items) + local a, b = unpack(items) minetest.register_craft({ output = b.." 5", recipe = { @@ -531,7 +528,7 @@ minetest.register_node("ethereal:candle", { }, }, paramtype = "light", - light_source = default.LIGHT_MAX - 3, + light_source = 11, sunlight_propagates = true, walkable = false, groups = {dig_immediate = 3, attached_node = 1}, @@ -543,7 +540,7 @@ minetest.register_node("ethereal:candle", { }) minetest.register_craft({ - output = "ethereal:candle 6", + output = "ethereal:candle 4", recipe = { {"","farming:cotton"}, {"","ethereal:palm_wax"}, diff --git a/sapling.lua b/sapling.lua index 05ba759..896cb69 100644 --- a/sapling.lua +++ b/sapling.lua @@ -57,8 +57,11 @@ local path = minetest.get_modpath("ethereal").."/schematics/" ethereal.grow_sapling = function (pos, node) - local under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z}) - if under then under = under.name else return end + local under = minetest.get_node({ + x = pos.x, + y = pos.y - 1, + z = pos.z + }).name -- Check if Sapling is growing on correct substrate if node.name == "ethereal:yellow_tree_sapling" @@ -139,13 +142,15 @@ minetest.register_craftitem("ethereal:tree_tool", { description = "Tree Tool", inventory_image = "default_stick.png", on_use = function(itemstack, user, pointed_thing) + if not pointed_thing or pointed_thing.type ~= "node" then return end + local pos = pointed_thing.under - local nod = minetest.get_node_or_nil(pos) - if not nod then return end + local nod = minetest.get_node(pos) + ethereal.grow_sapling(pos, nod) end, }) diff --git a/sealife.lua b/sealife.lua index 41de5d0..6db5742 100644 --- a/sealife.lua +++ b/sealife.lua @@ -138,11 +138,11 @@ minetest.register_ore({ clust_scarcity = 10*10*10, clust_num_ores = 24, clust_size = 4, - y_max = -14, + y_max = -12, y_min = -100, }) --- randomly generate coral or seaweed and have seaweed grow up to 10 high +-- randomly generate coral or seaweed and have seaweed grow up to 14 high minetest.register_abm({ nodenames = {"ethereal:sandy"}, neighbors = {"group:water"}, @@ -152,29 +152,42 @@ minetest.register_abm({ action = function(pos, node) local sel = math.random(1, 5) - if sel == 1 - or node.name == "ethereal:seaweed" then - local height = 0 - while (minetest.get_node(pos).name == "ethereal:seaweed" - or minetest.get_node(pos).name == "ethereal:sandy") - and height < 14 do + pos.y = pos.y + 1 + + local nod = minetest.get_node(pos).name + + if nod == "default:water_source" + and sel > 1 then + + if minetest.get_node(pos).name == "default:water_source" then + + minetest.swap_node(pos, {name = "ethereal:coral" .. sel}) + end + + return + end + + if nod == "ethereal:seaweed" + or sel == 1 then + + local height = 0 + local high = 14 + + while height < high + and minetest.get_node(pos).name == "ethereal:seaweed" do height = height + 1 pos.y = pos.y + 1 end - if height < 14 - and pos.y < 0 + if pos.y < 1 + and height < high and minetest.get_node(pos).name == "default:water_source" then + minetest.swap_node(pos, {name = "ethereal:seaweed"}) end - else - pos.y = pos.y + 1 - if minetest.get_node(pos).name == "default:water_source" then - minetest.swap_node(pos, {name = "ethereal:coral"..sel}) - end - end + end, }) diff --git a/textures/banana_leaf.png b/textures/banana_leaf.png index 0d744ec0690e9225f1069c50625aaaef31626d46..5800cbfc8b898eeaccaa89a86bb1ac34ea775541 100644 GIT binary patch delta 374 zcmV-+0g3*+1Em9yBn22yOjJdYEEs>u@M8i100BrzL_t(2&ppvSZrm^s1>h$}NLmh+ z^wc9)ZbMRtTZt<;2hau9yRdr~zJEqPPQw8PgZB+daQeH%B3&Cp_{%0sFpIHh!F$QgA&4G7 z5QmFC)-H59pqJxqEvH~T7N~J4hftE$#%8Sf5N6TP%?SE&oA6Sa8+N0VUC?!we^f?7 U#WvdcUjP6A07*qoM6N<$f(Y`fh5!Hn delta 418 zcmV;T0bTy31H1!}B!3%FOjJd1000|L85vX!E?y!rXck6pIZ%ToXNy*zw1-Qm%i;h4 z00DGTPE!Ct=GbNc00B=)L_t(2&ppvSj}$Qs24EM9mJ&}GK^tf2FY`_`l#qA@B{SJQ z@dH-WaC_3Vh=SjZ=VNh^NUtnEQA{*_CsOI!Gz_1}>R5E7XMd3bh<>x+5YAFwMB3O$ zrxsj__sxrDnVF#vMCUGZy;#tO0O)TzTqMGMer^nLZ4DQF)f0REu!mB2sP3! zSThe(s1vP1Nq-}3;KzVOn^5s9I>2t)h4obpV8JHbri)E+L!i6RCosP~3x!>nQ?hH! zq+u6;i8)ws7ZTDkg#PB~zhEsVdVTG~Cgj*Mza#pi*o0Y}=a%S|mSz*gj`y~RNBgW* z=sfeAWp`KI1s~Ude&{A>UT0Wc%O=dSbZaGkcC1;CPp0tNcsLSF20004WQchCjpt)=kw~vBKT%9H zeJ4`s+B6KG$m&>hq-T)=h<>x+5YAFwMB3O$rxsj__sxrDnVF#vMCUGZy;#tO0O)Tz zTqMGMer^nLZ4DQF)f0REu!mB2sP3!SThe(s1vP1Nh56F$ACneQ1L4|z;4=w z^;HdE!6w|Mi%oGupu5l~Fuy$ugf`>a*yJoB4ncURp7AJ>3>=q6}hXINd!Cd{&R m(7_hB2uE#xt^uju1^Nf|n^>FCz$z9100007`wUv literal 0 HcmV?d00001 diff --git a/water.lua b/water.lua index 952b3ca..e9f14b3 100644 --- a/water.lua +++ b/water.lua @@ -89,6 +89,7 @@ minetest.register_abm({ action = function(pos, node) local water_node = "default:water" + if pos.y > 2 then water_node = "default:river_water" end @@ -98,8 +99,10 @@ minetest.register_abm({ or node.name == "ethereal:icebrick" or node.name == "ethereal:snowbrick" then minetest.swap_node(pos, {name = water_node.."_source"}) + elseif node.name == "default:snow" then minetest.swap_node(pos, {name = water_node.."_flowing"}) + elseif node.name == "default:dirt_with_snow" then minetest.swap_node(pos, {name = "default:dirt_with_grass"}) end @@ -116,6 +119,7 @@ minetest.register_abm({ chance = 2, catch_up = false, action = function(pos, node) + if node == "ethereal:dry_dirt" then minetest.swap_node(pos, {name = "default:dirt"}) else @@ -132,20 +136,26 @@ minetest.register_abm({ chance = 1, catch_up = false, action = function(pos, node) + local num = #minetest.find_nodes_in_area( {x = pos.x - 1, y = pos.y, z = pos.z}, {x = pos.x + 1, y = pos.y, z = pos.z}, {"group:water"}) + num = num + #minetest.find_nodes_in_area( {x = pos.x, y = pos.y, z = pos.z - 1}, {x = pos.x, y = pos.y, z = pos.z + 1}, {"group:water"}) + num = num + #minetest.find_nodes_in_area( {x = pos.x, y = pos.y + 1, z = pos.z}, {x = pos.x, y = pos.y + 1, z = pos.z}, {"group:water"}) + if num > 0 then + minetest.swap_node(pos, {name = "default:water_flowing"}) + minetest.add_item(pos, {name = node.name}) end end,