ATTENTION! The process of updating WiKi to version Eco 10.x has begun. Those wishing to participate can find out more Information on our ECO Contribution Wiki Discord.
From April 26 to May 12, errors may occur in the Wiki, as we will be carrying out a major update to the information processing modules.

Module:TreeDetails

From Eco - English Wiki

Documentation[edit source]

This module provides the back end functionality of the Template:TreeDetails.

If the template is passed, this module creates a table using details from the following Modules:


local p = {}

local Utils = require('Module:Utils')

-- Main entry point for the Module
function p.main(frame)
    -- get args from the Template
    local args = Utils.normaliseArgs(frame)
    
	if args.tree == nil or args.tree == '' then
        return '\'tree\' must be specified.'
    end
	
    -- assign variables for tree
    local tree = args.tree
   
    -- load list of recipes
    local treeData = require( "Module:TreeData" )
    local treeTable = treeData.trees[tree]
    if treeTable == nil then
		return tree .. ' could not be found in Module:TreeData.'
	end    
	
	local wikibox = '=== Tree Properties===\n'
	
	if treeTable.isDecorative == 'Decorative' then
		wikibox = wikibox .. 'This tree is decorative only. \n'
	end
	if treeTable.isWater == 'Underwater' then
		wikibox = wikibox .. 'This tree grows underwater. \n'
	end
	if treeTable.scytheKills =='Yes' then
		wikibox = wikibox .. 'Scything this tree will kill it. \n'
	end
	
	wikibox = wikibox .. '\n===Environmental Conditions===\n'	
	wikibox = wikibox .. '{| class=\"wikitable\"\n'
	
	-- Temperature row
	wikibox = wikibox .. '| rowspan="4" | Temperature Ranges \n'
	wikibox = wikibox .. '| Ideal Minimum : ' .. treeTable.idealTempMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" |  Ideal Range: The tree\'s preferred temperature range.  Temperatures in this range won\'t inhibit population growth or reduce yield.\n'
	wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. treeTable.idealTempMax .. '\n'
	wikibox = wikibox .. '|- \n| Extreme Minimum  : ' .. treeTable.extremeTempMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Extreme Range : The temperature range that can support this tree (albeit at reduced efficiency if the temperature is not also within the ideal range).  Temperatures outside this range prohibit reproduction entirely and prevent any yield at all. \n'
	wikibox = wikibox .. '|- \n| Extreme Maximum : ' .. treeTable.extremeTempMax .. '\n'
	
	-- Moisture row
	wikibox = wikibox .. '|- \n| rowspan="4" | Moisture Ranges \n'
	wikibox = wikibox .. '| Ideal Minimum : ' .. treeTable.idealMoistureMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" |  Ideal Range: The tree\'s preferred moisture range.  Moisture in this range won\'t inhibit population growth or reduce yield.\n'
	wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. treeTable.idealMoistureMax .. '\n'
	wikibox = wikibox .. '|- \n| Extreme Minimum  : ' .. treeTable.extremeMoistureMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Extreme Range : The moisture range that can support this tree (albeit at reduced efficiency if the moisture is not also within the ideal range).  Moisture outside this range prohibits reproduction entirely and prevent any yield at all. \n'
	wikibox = wikibox .. '|- \n| Extreme Maximum : ' .. treeTable.extremeMoistureMax .. '\n'

	-- Salt row
	wikibox = wikibox .. '|- \n| rowspan="4" | Salt Ranges \n'
	wikibox = wikibox .. '| Ideal Minimum : ' .. treeTable.idealSaltMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" |  Ideal Range: The tree\'s preferred sale range.  Salt in this range won\'t inhibit population growth or reduce yield.\n'
	wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. treeTable.idealSaltMax .. '\n'
	wikibox = wikibox .. '|- \n| Extreme Minimum  : ' .. treeTable.extremeSaltMin .. '\n'
	wikibox = wikibox .. '| rowspan="2" | Extreme Range : The salt range that can support this tree (albeit at reduced efficiency if the salt is not also within the ideal range).  Salt outside this range prohibits reproduction entirely and prevent any yield at all. \n'
	wikibox = wikibox .. '|- \n| Extreme Maximum : ' .. treeTable.extremeSaltMax .. '\n'	
	
	-- Soil Restrictions
	wikibox = wikibox .. '|- \n| rowspan="4" | Soil Conditions \n'
	if treeTable.nitrogenHalfSpeed == nil then
		wikibox = wikibox .. '| Nitrogen minimum : None \n'
	else
		wikibox = wikibox .. '| Nitrogen minimum : ' .. treeTable.nitrogenHalfSpeed .. '\n'
	end
	wikibox = wikibox .. '| rowspan="4" | Any nutirent dropping below its minimum will reduce the growth of the tree to half speed\n'
	if treeTable.phosphorusHalfSpeed == nil then
		wikibox = wikibox .. '|- \n| Phosphorus minimum : None \n'
	else
		wikibox = wikibox .. '|- \n| Phosphorus minimum : ' .. treeTable.phosphorusHalfSpeed .. '\n'
	end
	if treeTable.potassiumHalfSpeed == nil then
		wikibox = wikibox .. '|- \n| Potassium minimum : None \n'
	else
		wikibox = wikibox .. '|- \n| Potassium minimum  : ' .. treeTable.potassiumHalfSpeed .. '\n'
	end
	if treeTable.soilMoistureHalfSpeed == nil then
		wikibox = wikibox .. '|- \n| Soil Moisture minimum : None \n'
	else
		wikibox = wikibox .. '|- \n| Soil Moisture minimum : ' .. treeTable.soilMoistureHalfSpeed .. '\n'
	end
	wikibox = wikibox .. '|}\n\n'
	
	wikibox = wikibox .. '===Tree Harvest===\n'
	wikibox = wikibox .. '{| class=\"wikitable\"\n'
	
	-- Growth Details
	wikibox = wikibox .. '|- \n| rowspan="3" | Growth Stages \n'
	wikibox = wikibox .. '| Mature in ' .. treeTable.maturity .. ' days\n'
	wikibox = wikibox .. '| How many days it takes for this tree to mature \n'
	wikibox = wikibox .. '|- \n| Chopable at ' .. treeTable.pickableAtPercent .. '% growth\n'
	wikibox = wikibox .. '| The percent it is possible to chop this tree \n'
	if treeTable.killOnHarvest == 'Yes' then
		wikibox = wikibox .. '|- \n| Harvesting Kills \n'
		wikibox = wikibox .. '| This tree must be planted from seeds after harvesting \n'
	else
		wikibox = wikibox .. '|- \n| Returns to ' .. treeTable.postHarvestGrowth .. '% growth\n'
		wikibox = wikibox .. '| This tree will return to an immature state on harvesting \n'
	end
	
	-- Resource Yields (Logs)
	wikibox = wikibox .. '|- \n| rowspan="4" | Resource Yield \n'
	if treeTable.resourceItem == nil and treeTable.debrisResources == nil then
		wikibox = wikibox .. '| Resource Yeilds : None \n'
	else
		wikibox = wikibox .. '| Resource Yeilds : \n'
		wikibox = wikibox .. '| ' .. treeTable.resourceItem .. ' from logs'	
		
        local listDebris = ''
		local debrisResources = treeTable.debrisResources	
        -- for each item in the list (a is position, b is value)            
        for e,d in ipairs(debrisResources) do
            --if not these tags listed here
            if d ~='[[]]'  then
                -- add the tag to the list
                listDebris = listDebris .. d
			end
            -- if not the last item in the list
            if (d ~= debrisResources[#debrisResources]) then
                -- add a comma
                listDebris = listDebris .. ', '
            end
        end			
        -- Now the list is made add it to the table
		wikibox = wikibox ..  ' and ' .. listDebris .. ' from debris \n'
	end

	wikibox = wikibox .. '|- \n| Minimum Item Yield : ' .. treeTable.resourceMin .. '\n'
	wikibox = wikibox .. '| The minimum item yield from harvesting this tree at maturity \n'
	wikibox = wikibox .. '|- \n| Maximum Item Yield : ' .. treeTable.resourceMax .. '\n'
	wikibox = wikibox .. '| The maximum item yield from harvesting this tree at maturity \n'
	wikibox = wikibox .. '|- \n| Yield Bonus : ' .. treeTable.resourceBonus .. '% growth\n'
	wikibox = wikibox .. '| The growth at which you get a Resource bonus from the minimum \n'
	wikibox = wikibox .. '|}\n\n'
	
	wikibox = wikibox .. '===Environmental Effects===\n'
	wikibox = wikibox .. '{| class=\"wikitable\"\n'
	
	-- Soil Effects
	wikibox = wikibox .. '| rowspan="4" | Nutrients Depleted \n'
	if treeTable.nitrogenContent == nil then
		wikibox = wikibox .. '| Nitrogen absorbed : None \n'
	else
		wikibox = wikibox .. '| Nitrogen absorbed : ' .. treeTable.nitrogenContent .. '\n'
	end
	wikibox = wikibox .. '| rowspan="4" | The amount of nutrients an adult tree absorbs from the soil\n'
	if treeTable.phosphorusContent == nil then
		wikibox = wikibox .. '|- \n| Phosphorus absorbed : None \n'
	else
		wikibox = wikibox .. '|- \n| Phosphorus absorbed : ' .. treeTable.phosphorusContent .. '\n'
	end
	if treeTable.potassiumContent == nil then
		wikibox = wikibox .. '|- \n| Potassium absorbed : None \n'
	else
		wikibox = wikibox .. '|- \n| Potassium absorbed  : ' .. treeTable.potassiumContent .. '\n'
	end
	if treeTable.soilMoistureContent == nil then
		wikibox = wikibox .. '|- \n| Soil Moisture absorbed : None \n'
	else
		wikibox = wikibox .. '|- \n| Soil Moisture absorbed : ' .. treeTable.soilMoistureContent .. '\n'
	end
	
	-- Overcrowding Effects
	wikibox = wikibox .. '|- \n| rowspan="4" | Space Required \n'
	if treeTable.consumedFertileGround == nil then
		wikibox = wikibox .. '| Fertile ground occupied : None \n'
	else
		wikibox = wikibox .. '| Fertile ground occupied : ' .. treeTable.consumedFertileGround .. '\n'
	end
	wikibox = wikibox .. '| rowspan="4" | The amount of each space occupied by each tree\n'
	if treeTable.consumedUnderwaterFertileGorund == nil then
		wikibox = wikibox .. '|- \n| Underwater fertile ground occupied : None \n'
	else
		wikibox = wikibox .. '|- \n| Underwater fertile ground occupied : ' .. treeTable.consumedUnderwaterFertileGorund .. '\n'
	end
	if treeTable.consumedShrubSpace == nil then
		wikibox = wikibox .. '|- \n| Shrub space occupied : None \n'
	else
		wikibox = wikibox .. '|- \n| Shrub space occupied : ' .. treeTable.consumedShrubSpace .. '\n'
	end
	if treeTable.consumedCanopySpace == nil then
		wikibox = wikibox .. '|- \n| Canopy space occupied : None \n'
	else
		wikibox = wikibox .. '|- \n| Canopy space occupied : ' .. treeTable.consumedCanopySpace .. '\n'
	end
	wikibox = wikibox .. '|}\n\n'
	
	return wikibox
	
end

return p