From 9c6a91aa96acc59d305d887465eab504c48e3499 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sun, 30 Sep 2018 18:29:35 +0100 Subject: localize unecessary global functions --- plantlife.lua | 18 +++++++++--------- sapling.lua | 60 +++++++++++++++++++++++++++++----------------------------- strawberry.lua | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/plantlife.lua b/plantlife.lua index 2c677ce..ad60fb1 100644 --- a/plantlife.lua +++ b/plantlife.lua @@ -233,7 +233,7 @@ minetest.register_node("ethereal:crystalgrass", { }) -- Define Moss Types (Has grass textures on all sides) -function ethereal.add_moss(typ, descr, texture, receipe_item) +local add_moss = function(typ, descr, texture, receipe_item) minetest.register_node("ethereal:" .. typ .. "_moss", { description = S(descr .. " Moss"), @@ -250,11 +250,11 @@ function ethereal.add_moss(typ, descr, texture, receipe_item) }) end -ethereal.add_moss( "crystal", "Crystal", "ethereal_grass_crystal_top.png", "ethereal:frost_leaves") -ethereal.add_moss( "mushroom", "Mushroom", "ethereal_grass_mushroom_top.png", "ethereal:mushroom") -ethereal.add_moss( "fiery", "Fiery", "ethereal_grass_fiery_top.png", "ethereal:dry_shrub") -ethereal.add_moss( "gray", "Gray", "ethereal_grass_gray_top.png", "ethereal:snowygrass") -ethereal.add_moss( "green", "Green", "default_grass.png", "default:jungleleaves") +add_moss( "crystal", "Crystal", "ethereal_grass_crystal_top.png", "ethereal:frost_leaves") +add_moss( "mushroom", "Mushroom", "ethereal_grass_mushroom_top.png", "ethereal:mushroom") +add_moss( "fiery", "Fiery", "ethereal_grass_fiery_top.png", "ethereal:dry_shrub") +add_moss( "gray", "Gray", "ethereal_grass_gray_top.png", "ethereal:snowygrass") +add_moss( "green", "Green", "default_grass.png", "default:jungleleaves") -- Illuminated Cave Shrooms (Red, Green and Blue) minetest.register_node("ethereal:illumishroom", { @@ -267,7 +267,7 @@ minetest.register_node("ethereal:illumishroom", { light_source = 5, sunlight_propagates = true, walkable = false, - groups = {dig_immediate = 3, attached_node = 1,flammable = 3}, + groups = {dig_immediate = 3, attached_node = 1, flammable = 3}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -285,7 +285,7 @@ minetest.register_node("ethereal:illumishroom2", { light_source = 5, sunlight_propagates = true, walkable = false, - groups = {dig_immediate = 3, attached_node = 1,flammable = 3}, + groups = {dig_immediate = 3, attached_node = 1, flammable = 3}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", @@ -303,7 +303,7 @@ minetest.register_node("ethereal:illumishroom3", { light_source = 5, sunlight_propagates = true, walkable = false, - groups = {dig_immediate = 3, attached_node = 1,flammable = 3}, + groups = {dig_immediate = 3, attached_node = 1, flammable = 3}, sounds = default.node_sound_leaves_defaults(), selection_box = { type = "fixed", diff --git a/sapling.lua b/sapling.lua index 1ed8d4b..58fb9fb 100644 --- a/sapling.lua +++ b/sapling.lua @@ -25,7 +25,7 @@ minetest.register_node("ethereal:bamboo_sprout", { }) -- Register Saplings -ethereal.register_sapling = function(name, desc, texture, height) +local register_sapling = function(name, desc, texture, height) minetest.register_node(name .. "_sapling", { description = S(desc .. " Tree Sapling"), @@ -50,18 +50,18 @@ ethereal.register_sapling = function(name, desc, texture, height) }) end -ethereal.register_sapling("ethereal:willow", "Willow", "willow_sapling", 14) -ethereal.register_sapling("ethereal:yellow_tree", "Healing", "yellow_tree_sapling", 19) -ethereal.register_sapling("ethereal:big_tree", "Big", "ethereal_big_tree_sapling", 7) -ethereal.register_sapling("ethereal:banana_tree", "Banana", "banana_tree_sapling", 8) -ethereal.register_sapling("ethereal:frost_tree", "Frost", "ethereal_frost_tree_sapling", 19) -ethereal.register_sapling("ethereal:mushroom", "Mushroom", "ethereal_mushroom_sapling", 11) -ethereal.register_sapling("ethereal:palm", "Palm", "moretrees_palm_sapling", 9) -ethereal.register_sapling("ethereal:redwood", "Redwood", "redwood_sapling", 31) -ethereal.register_sapling("ethereal:orange_tree", "Orange", "orange_tree_sapling", 6) -ethereal.register_sapling("ethereal:birch", "Birch", "moretrees_birch_sapling", 7) - -ethereal.add_tree = function (pos, ofx, ofy, ofz, schem) +register_sapling("ethereal:willow", "Willow", "willow_sapling", 14) +register_sapling("ethereal:yellow_tree", "Healing", "yellow_tree_sapling", 19) +register_sapling("ethereal:big_tree", "Big", "ethereal_big_tree_sapling", 7) +register_sapling("ethereal:banana_tree", "Banana", "banana_tree_sapling", 8) +register_sapling("ethereal:frost_tree", "Frost", "ethereal_frost_tree_sapling", 19) +register_sapling("ethereal:mushroom", "Mushroom", "ethereal_mushroom_sapling", 11) +register_sapling("ethereal:palm", "Palm", "moretrees_palm_sapling", 9) +register_sapling("ethereal:redwood", "Redwood", "redwood_sapling", 31) +register_sapling("ethereal:orange_tree", "Orange", "orange_tree_sapling", 6) +register_sapling("ethereal:birch", "Birch", "moretrees_birch_sapling", 7) + +local add_tree = function (pos, ofx, ofy, ofz, schem) -- check for schematic if not schem then print (S("Schematic not found")) @@ -74,55 +74,55 @@ ethereal.add_tree = function (pos, ofx, ofy, ofz, schem) schem, 0, nil, false) end -local path = minetest.get_modpath("ethereal").."/schematics/" +local path = minetest.get_modpath("ethereal") .. "/schematics/" -- grow tree functions function ethereal.grow_yellow_tree(pos) - ethereal.add_tree(pos, 4, 0, 4, ethereal.yellowtree) + add_tree(pos, 4, 0, 4, ethereal.yellowtree) end function ethereal.grow_big_tree(pos) - ethereal.add_tree(pos, 4, 0, 4, ethereal.bigtree) + add_tree(pos, 4, 0, 4, ethereal.bigtree) end function ethereal.grow_banana_tree(pos) - ethereal.add_tree(pos, 3, 0, 3, ethereal.bananatree) + add_tree(pos, 3, 0, 3, ethereal.bananatree) end function ethereal.grow_frost_tree(pos) - ethereal.add_tree(pos, 4, 0, 4, ethereal.frosttrees) + add_tree(pos, 4, 0, 4, ethereal.frosttrees) end function ethereal.grow_mushroom_tree(pos) - ethereal.add_tree(pos, 4, 0, 4, ethereal.mushroomone) + add_tree(pos, 4, 0, 4, ethereal.mushroomone) end function ethereal.grow_palm_tree(pos) - ethereal.add_tree(pos, 4, 0, 4, ethereal.palmtree) + add_tree(pos, 4, 0, 4, ethereal.palmtree) end function ethereal.grow_willow_tree(pos) - ethereal.add_tree(pos, 5, 0, 5, ethereal.willow) + add_tree(pos, 5, 0, 5, ethereal.willow) end function ethereal.grow_redwood_tree(pos) - ethereal.add_tree(pos, 7, 0, 7, ethereal.redwood_tree) + add_tree(pos, 7, 0, 7, ethereal.redwood_tree) end function ethereal.grow_orange_tree(pos) - ethereal.add_tree(pos, 1, 0, 1, ethereal.orangetree) + add_tree(pos, 1, 0, 1, ethereal.orangetree) end function ethereal.grow_bamboo_tree(pos) - ethereal.add_tree(pos, 1, 0, 1, ethereal.bambootree) + add_tree(pos, 1, 0, 1, ethereal.bambootree) end function ethereal.grow_birch_tree(pos) - ethereal.add_tree(pos, 2, 0, 2, ethereal.birchtree) + add_tree(pos, 2, 0, 2, ethereal.birchtree) end -- check if sapling has enough height room to grow -local function enough_height(pos, height) +local enough_height = function(pos, height) local nod = minetest.line_of_sight( {x = pos.x, y = pos.y + 1, z = pos.z}, @@ -135,7 +135,7 @@ local function enough_height(pos, height) end end -ethereal.grow_sapling = function (pos, node) +local grow_sapling = function(pos, node) local under = minetest.get_node({ x = pos.x, @@ -211,12 +211,12 @@ minetest.register_abm({ catch_up = false, action = function(pos, node) - local light_level = minetest.get_node_light(pos) + local light_level = minetest.get_node_light(pos) or 0 - if not light_level or light_level < 13 then + if light_level < 13 then return end - ethereal.grow_sapling(pos, node) + grow_sapling(pos, node) end, }) diff --git a/strawberry.lua b/strawberry.lua index 8098ca3..3fe3fa7 100644 --- a/strawberry.lua +++ b/strawberry.lua @@ -28,7 +28,7 @@ local crop_def = { fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5} }, groups = { - snappy = 3, flammable =2, plant = 1, attached_node = 1, + snappy = 3, flammable = 2, plant = 1, attached_node = 1, not_in_creative_inventory = 1, growing = 1 }, sounds = default.node_sound_leaves_defaults(), -- cgit v1.2.3