From 9acbeb85c14a5b62b16eda7bab101066c09cf1e6 Mon Sep 17 00:00:00 2001 From: AntumDeluge Date: Sun, 7 Aug 2016 18:39:45 -0700 Subject: [PATCH] [stained_wood] Make "wood_colors" & "wood_colors_count" global & move to init.lua script. --- mods/materials/stained_wood/init.lua | 20 ++++++++++++++++++++ mods/materials/stained_wood/nodes.lua | 19 ------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/mods/materials/stained_wood/init.lua b/mods/materials/stained_wood/init.lua index 29000d0b..d7135979 100644 --- a/mods/materials/stained_wood/init.lua +++ b/mods/materials/stained_wood/init.lua @@ -46,6 +46,26 @@ titleize = function(string) end +-- Define function to retrieve total number of stained wood colors +getWoodColorsCount = function(colors) + local color_count = 0 + + for _ in pairs(colors) do + color_count = color_count + 1 + end + + return color_count +end + + +-- Set stained wood colors +wood_colors = {"blue", "brown", "gray", "green", "purple", "red", + "white", "yellow"} + +wood_colors_count = getWoodColorsCount(wood_colors) +logMessage("nodes.lua: " .. wood_colors_count .. " wood colors loaded") + + -- Load sub-scripts dofile(modpath .. "/nodes.lua") dofile(modpath .. "/crafting.lua") diff --git a/mods/materials/stained_wood/nodes.lua b/mods/materials/stained_wood/nodes.lua index 8845b8ab..b130020c 100644 --- a/mods/materials/stained_wood/nodes.lua +++ b/mods/materials/stained_wood/nodes.lua @@ -23,18 +23,6 @@ --- Define function to retrieve total number of stained wood colors -getWoodColorsCount = function(colors) - local color_count = 0 - - for _ in pairs(colors) do - color_count = color_count + 1 - end - - return color_count -end - - -- Define function for adding a stained wood addStainedWood = function(color) local node_name = "stained_wood:" .. color @@ -51,13 +39,6 @@ addStainedWood = function(color) end -local wood_colors = {"blue", "brown", "gray", "green", "purple", "red", - "white", "yellow"} - -local wood_colors_count = getWoodColorsCount(wood_colors) -logMessage("nodes.lua: " .. wood_colors_count .. " wood colors loaded") - - -- Register all stained wood for i = 1, wood_colors_count do addStainedWood(wood_colors[i])