Module:PlantDetails: Difference between revisions
From Eco - English Wiki
[unchecked revision] | [unchecked revision] |
Remove old data and add new data |
Undo revision 3243 by ZeelNightwolf (talk) Tag: Undo |
||
Line 16: | Line 16: | ||
return args | return args | ||
end | end | ||
-- Main entry point for the Module | -- Main entry point for the Module | ||
function p.main() | function p.main() | ||
-- get args from the Template | |||
local args = norm() | local args = norm() | ||
if args.plant == nil or args.plant == '' then | |||
return '\'plant\' must be specified.' | |||
end | |||
-- assign variables for plant | -- assign variables for plant | ||
local plant = args.plant | |||
-- load list of recipes | |||
local plantData = require( "Module:PlantData" ) | |||
local plantTable = plantData.plants[plant] | |||
if plantTable == nil then | |||
return plant .. ' could not be found in Module:PlantData.' | |||
end | |||
local wikibox = '=== Plant Properties===\n' | |||
if plantTable.isDecorative == 'Decorative' then | |||
wikibox = wikibox .. 'This plant is decorative only. \n' | |||
end | |||
if plantTable.isWater == 'Underwater' then | |||
wikibox = wikibox .. 'This plant grows underwater. \n' | |||
end | |||
if plantTable.scytheKills =='Yes' then | |||
wikibox = wikibox .. 'Scything this plant will kill it. \n' | |||
end | end | ||
-- | wikibox = wikibox .. '\n===Environmental Conditions===\n' | ||
if | wikibox = wikibox .. '{| class=\"wikitable\"\n' | ||
-- | |||
-- Temperature row | |||
wikibox = wikibox .. '| rowspan="4" | Temperature Ranges \n' | |||
wikibox = wikibox .. '| Ideal Minimum : ' .. plantTable.idealTempMin .. '\n' | |||
wikibox = wikibox .. '| rowspan="2" | Ideal Range: The plant\'s preferred temperature range. Temperatures in this range won\'t inhibit population growth or reduce yield.\n' | |||
wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. plantTable.idealTempMax .. '\n' | |||
wikibox = wikibox .. '|- \n| Extreme Minimum : ' .. plantTable.extremeTempMin .. '\n' | |||
wikibox = wikibox .. '| rowspan="2" | Extreme Range : The temperature range that can support this plant (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 : ' .. plantTable.extremeTempMax .. '\n' | |||
-- Moisture row | |||
wikibox = wikibox .. '|- \n| rowspan="4" | Moisture Ranges \n' | |||
wikibox = wikibox .. '| Ideal Minimum : ' .. plantTable.idealMoistureMin .. '\n' | |||
wikibox = wikibox .. '| rowspan="2" | Ideal Range: The plant\'s preferred moisture range. Moisture in this range won\'t inhibit population growth or reduce yield.\n' | |||
wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. plantTable.idealMoistureMax .. '\n' | |||
wikibox = wikibox .. '|- \n| Extreme Minimum : ' .. plantTable.extremeMoistureMin .. '\n' | |||
wikibox = wikibox .. '| rowspan="2" | Extreme Range : The moisture range that can support this plant (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 : ' .. plantTable.extremeMoistureMax .. '\n' | |||
-- Salt row | |||
wikibox = wikibox .. '|- \n| rowspan="4" | Salt Ranges \n' | |||
wikibox = wikibox .. '| Ideal Minimum : ' .. plantTable.idealSaltMin .. '\n' | |||
wikibox = wikibox .. '| rowspan="2" | Ideal Range: The plant\'s preferred sale range. Salt in this range won\'t inhibit population growth or reduce yield.\n' | |||
wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. plantTable.idealSaltMax .. '\n' | |||
wikibox = wikibox .. '|- \n| Extreme Minimum : ' .. plantTable.extremeSaltMin .. '\n' | |||
wikibox = wikibox .. '| rowspan="2" | Extreme Range : The salt range that can support this plant (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 : ' .. plantTable.extremeSaltMax .. '\n' | |||
-- Soil Restrictions | |||
wikibox = wikibox .. '|- \n| rowspan="4" | Soil Conditions \n' | |||
if plantTable.nitrogenHalfSpeed == nil then | |||
wikibox = wikibox .. '| Nitrogen minimum : None \n' | |||
else | |||
wikibox = wikibox .. '| Nitrogen minimum : ' .. plantTable.nitrogenHalfSpeed .. '\n' | |||
end | |||
wikibox = wikibox .. '| rowspan="4" | Any nutirent dropping below its minimum will reduce the growth of the plant to half speed\n' | |||
if plantTable.phosphorusHalfSpeed == nil then | |||
wikibox = wikibox .. '|- \n| Phosphorus minimum : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Phosphorus minimum : ' .. plantTable.phosphorusHalfSpeed .. '\n' | |||
end | |||
if plantTable.potassiumHalfSpeed == nil then | |||
wikibox = wikibox .. '|- \n| Potassium minimum : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Potassium minimum : ' .. plantTable.potassiumHalfSpeed .. '\n' | |||
end | |||
if plantTable.soilMoistureHalfSpeed == nil then | |||
wikibox = wikibox .. '|- \n| Soil Moisture minimum : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Soil Moisture minimum : ' .. plantTable.soilMoistureHalfSpeed .. '\n' | |||
end | end | ||
wikibox = wikibox .. '|}\n\n' | |||
wikibox = wikibox .. '===Plant Harvest===\n' | |||
wikibox = wikibox .. '{| class=\"wikitable\"\n' | |||
-- | -- Growth Details | ||
if | wikibox = wikibox .. '|- \n| rowspan="3" | Growth Stages \n' | ||
wikibox = wikibox .. '| Mature in ' .. plantTable.maturity .. ' days\n' | |||
wikibox = wikibox .. '| How many days it takes for this plant to mature \n' | |||
wikibox = wikibox .. '|- \n| Pickable at ' .. plantTable.pickableAtPercent .. '% growth\n' | |||
wikibox = wikibox .. '| The percent it is possible to pick this plant \n' | |||
if plantTable.killOnHarvest == 'Yes' then | |||
wikibox = wikibox .. '|- \n| Harvesting Kills \n' | |||
wikibox = wikibox .. '| This plant must be replanted from seeds after harvesting \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Returns to ' .. plantTable.postHarvestGrowth .. '% growth\n' | |||
wikibox = wikibox .. '| This plant will return to an immature state on harvesting \n' | |||
end | end | ||
-- | -- Resource Yields | ||
wikibox = wikibox .. '|- \n| rowspan="3" | Resource Yield \n' | |||
wikibox = wikibox .. '| Minimum yield : ' .. plantTable.resourceMin .. '\n' | |||
wikibox = wikibox .. '| The minimum yield from harvesting this plant at maturity \n' | |||
wikibox = wikibox .. '|- \n| Maximum Yield : ' .. plantTable.resourceMax .. '\n' | |||
wikibox = wikibox .. '| The maximum yield from harvesting this plant at maturity \n' | |||
wikibox = wikibox .. '|- \n| Yield Bonus : ' .. plantTable.resourceBonus .. '% growth\n' | |||
wikibox = wikibox .. '| The growth at which you get a yield 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 plantTable.nitrogenContent == nil then | |||
wikibox = wikibox .. '| Nitrogen absorbed : None \n' | |||
else | |||
wikibox = wikibox .. '| Nitrogen absorbed : ' .. plantTable.nitrogenContent .. '\n' | |||
end | |||
wikibox = wikibox .. '| rowspan="4" | The amount of nutrients an adult plant absorbs from the soil\n' | |||
if plantTable.phosphorusContent == nil then | |||
wikibox = wikibox .. '|- \n| Phosphorus absorbed : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Phosphorus absorbed : ' .. plantTable.phosphorusContent .. '\n' | |||
end | |||
if plantTable.potassiumContent == nil then | |||
wikibox = wikibox .. '|- \n| Potassium absorbed : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Potassium absorbed : ' .. plantTable.potassiumContent .. '\n' | |||
end | |||
if plantTable.soilMoistureContent == nil then | |||
wikibox = wikibox .. '|- \n| Soil Moisture absorbed : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Soil Moisture absorbed : ' .. plantTable.soilMoistureContent .. '\n' | |||
end | end | ||
-- ' | -- Overcrowding Effects | ||
wikibox = wikibox .. '|- \n| rowspan="4" | Space Required \n' | |||
if plantTable.consumedFertileGround == nil then | |||
wikibox = wikibox .. '| Fertile ground occupied : None \n' | |||
else | |||
wikibox = wikibox .. '| Fertile ground occupied : ' .. plantTable.consumedFertileGround .. '\n' | |||
end | |||
wikibox = wikibox .. '| rowspan="4" | The amount of each space occupied by each plant\n' | |||
if plantTable.consumedUnderwaterFertileGround == nil then | |||
wikibox = wikibox .. '|- \n| Underwater fertile ground occupied : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Underwater fertile ground occupied : ' .. plantTable.consumedUnderwaterFertileGround .. '\n' | |||
end | |||
if plantTable.consumedShrubSpace == nil then | |||
wikibox = wikibox .. '|- \n| Shrub space occupied : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Shrub space occupied : ' .. plantTable.consumedShrubSpace .. '\n' | |||
end | |||
if plantTable.consumedCanopySpace == nil then | |||
wikibox = wikibox .. '|- \n| Canopy space occupied : None \n' | |||
else | |||
wikibox = wikibox .. '|- \n| Canopy space occupied : ' .. plantTable.consumedCanopySpace .. '\n' | |||
end | |||
wikibox = wikibox .. '|}\n\n' | |||
return wikibox | |||
end | end | ||
return p | return p |
Revision as of 19:18, 14 August 2020
Documentation
This module provides the back end functionality of the Template:PlantDetails.
If the template is passed, this module creates a table using details from the following Modules:
local p = {}
-- Grabs args from the parent frame
-- Trims and parses the args into a table, then returns the table
function norm()
local origArgs = mw.getCurrentFrame():getParent().args
local args = {}
for k, v in pairs( origArgs ) do
v = mw.text.trim( tostring( v ) )
if v ~= '' then
args[k] = v
end
end
return args
end
-- Main entry point for the Module
function p.main()
-- get args from the Template
local args = norm()
if args.plant == nil or args.plant == '' then
return '\'plant\' must be specified.'
end
-- assign variables for plant
local plant = args.plant
-- load list of recipes
local plantData = require( "Module:PlantData" )
local plantTable = plantData.plants[plant]
if plantTable == nil then
return plant .. ' could not be found in Module:PlantData.'
end
local wikibox = '=== Plant Properties===\n'
if plantTable.isDecorative == 'Decorative' then
wikibox = wikibox .. 'This plant is decorative only. \n'
end
if plantTable.isWater == 'Underwater' then
wikibox = wikibox .. 'This plant grows underwater. \n'
end
if plantTable.scytheKills =='Yes' then
wikibox = wikibox .. 'Scything this plant 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 : ' .. plantTable.idealTempMin .. '\n'
wikibox = wikibox .. '| rowspan="2" | Ideal Range: The plant\'s preferred temperature range. Temperatures in this range won\'t inhibit population growth or reduce yield.\n'
wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. plantTable.idealTempMax .. '\n'
wikibox = wikibox .. '|- \n| Extreme Minimum : ' .. plantTable.extremeTempMin .. '\n'
wikibox = wikibox .. '| rowspan="2" | Extreme Range : The temperature range that can support this plant (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 : ' .. plantTable.extremeTempMax .. '\n'
-- Moisture row
wikibox = wikibox .. '|- \n| rowspan="4" | Moisture Ranges \n'
wikibox = wikibox .. '| Ideal Minimum : ' .. plantTable.idealMoistureMin .. '\n'
wikibox = wikibox .. '| rowspan="2" | Ideal Range: The plant\'s preferred moisture range. Moisture in this range won\'t inhibit population growth or reduce yield.\n'
wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. plantTable.idealMoistureMax .. '\n'
wikibox = wikibox .. '|- \n| Extreme Minimum : ' .. plantTable.extremeMoistureMin .. '\n'
wikibox = wikibox .. '| rowspan="2" | Extreme Range : The moisture range that can support this plant (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 : ' .. plantTable.extremeMoistureMax .. '\n'
-- Salt row
wikibox = wikibox .. '|- \n| rowspan="4" | Salt Ranges \n'
wikibox = wikibox .. '| Ideal Minimum : ' .. plantTable.idealSaltMin .. '\n'
wikibox = wikibox .. '| rowspan="2" | Ideal Range: The plant\'s preferred sale range. Salt in this range won\'t inhibit population growth or reduce yield.\n'
wikibox = wikibox .. '|- \n| Ideal Maximum : ' .. plantTable.idealSaltMax .. '\n'
wikibox = wikibox .. '|- \n| Extreme Minimum : ' .. plantTable.extremeSaltMin .. '\n'
wikibox = wikibox .. '| rowspan="2" | Extreme Range : The salt range that can support this plant (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 : ' .. plantTable.extremeSaltMax .. '\n'
-- Soil Restrictions
wikibox = wikibox .. '|- \n| rowspan="4" | Soil Conditions \n'
if plantTable.nitrogenHalfSpeed == nil then
wikibox = wikibox .. '| Nitrogen minimum : None \n'
else
wikibox = wikibox .. '| Nitrogen minimum : ' .. plantTable.nitrogenHalfSpeed .. '\n'
end
wikibox = wikibox .. '| rowspan="4" | Any nutirent dropping below its minimum will reduce the growth of the plant to half speed\n'
if plantTable.phosphorusHalfSpeed == nil then
wikibox = wikibox .. '|- \n| Phosphorus minimum : None \n'
else
wikibox = wikibox .. '|- \n| Phosphorus minimum : ' .. plantTable.phosphorusHalfSpeed .. '\n'
end
if plantTable.potassiumHalfSpeed == nil then
wikibox = wikibox .. '|- \n| Potassium minimum : None \n'
else
wikibox = wikibox .. '|- \n| Potassium minimum : ' .. plantTable.potassiumHalfSpeed .. '\n'
end
if plantTable.soilMoistureHalfSpeed == nil then
wikibox = wikibox .. '|- \n| Soil Moisture minimum : None \n'
else
wikibox = wikibox .. '|- \n| Soil Moisture minimum : ' .. plantTable.soilMoistureHalfSpeed .. '\n'
end
wikibox = wikibox .. '|}\n\n'
wikibox = wikibox .. '===Plant Harvest===\n'
wikibox = wikibox .. '{| class=\"wikitable\"\n'
-- Growth Details
wikibox = wikibox .. '|- \n| rowspan="3" | Growth Stages \n'
wikibox = wikibox .. '| Mature in ' .. plantTable.maturity .. ' days\n'
wikibox = wikibox .. '| How many days it takes for this plant to mature \n'
wikibox = wikibox .. '|- \n| Pickable at ' .. plantTable.pickableAtPercent .. '% growth\n'
wikibox = wikibox .. '| The percent it is possible to pick this plant \n'
if plantTable.killOnHarvest == 'Yes' then
wikibox = wikibox .. '|- \n| Harvesting Kills \n'
wikibox = wikibox .. '| This plant must be replanted from seeds after harvesting \n'
else
wikibox = wikibox .. '|- \n| Returns to ' .. plantTable.postHarvestGrowth .. '% growth\n'
wikibox = wikibox .. '| This plant will return to an immature state on harvesting \n'
end
-- Resource Yields
wikibox = wikibox .. '|- \n| rowspan="3" | Resource Yield \n'
wikibox = wikibox .. '| Minimum yield : ' .. plantTable.resourceMin .. '\n'
wikibox = wikibox .. '| The minimum yield from harvesting this plant at maturity \n'
wikibox = wikibox .. '|- \n| Maximum Yield : ' .. plantTable.resourceMax .. '\n'
wikibox = wikibox .. '| The maximum yield from harvesting this plant at maturity \n'
wikibox = wikibox .. '|- \n| Yield Bonus : ' .. plantTable.resourceBonus .. '% growth\n'
wikibox = wikibox .. '| The growth at which you get a yield 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 plantTable.nitrogenContent == nil then
wikibox = wikibox .. '| Nitrogen absorbed : None \n'
else
wikibox = wikibox .. '| Nitrogen absorbed : ' .. plantTable.nitrogenContent .. '\n'
end
wikibox = wikibox .. '| rowspan="4" | The amount of nutrients an adult plant absorbs from the soil\n'
if plantTable.phosphorusContent == nil then
wikibox = wikibox .. '|- \n| Phosphorus absorbed : None \n'
else
wikibox = wikibox .. '|- \n| Phosphorus absorbed : ' .. plantTable.phosphorusContent .. '\n'
end
if plantTable.potassiumContent == nil then
wikibox = wikibox .. '|- \n| Potassium absorbed : None \n'
else
wikibox = wikibox .. '|- \n| Potassium absorbed : ' .. plantTable.potassiumContent .. '\n'
end
if plantTable.soilMoistureContent == nil then
wikibox = wikibox .. '|- \n| Soil Moisture absorbed : None \n'
else
wikibox = wikibox .. '|- \n| Soil Moisture absorbed : ' .. plantTable.soilMoistureContent .. '\n'
end
-- Overcrowding Effects
wikibox = wikibox .. '|- \n| rowspan="4" | Space Required \n'
if plantTable.consumedFertileGround == nil then
wikibox = wikibox .. '| Fertile ground occupied : None \n'
else
wikibox = wikibox .. '| Fertile ground occupied : ' .. plantTable.consumedFertileGround .. '\n'
end
wikibox = wikibox .. '| rowspan="4" | The amount of each space occupied by each plant\n'
if plantTable.consumedUnderwaterFertileGround == nil then
wikibox = wikibox .. '|- \n| Underwater fertile ground occupied : None \n'
else
wikibox = wikibox .. '|- \n| Underwater fertile ground occupied : ' .. plantTable.consumedUnderwaterFertileGround .. '\n'
end
if plantTable.consumedShrubSpace == nil then
wikibox = wikibox .. '|- \n| Shrub space occupied : None \n'
else
wikibox = wikibox .. '|- \n| Shrub space occupied : ' .. plantTable.consumedShrubSpace .. '\n'
end
if plantTable.consumedCanopySpace == nil then
wikibox = wikibox .. '|- \n| Canopy space occupied : None \n'
else
wikibox = wikibox .. '|- \n| Canopy space occupied : ' .. plantTable.consumedCanopySpace .. '\n'
end
wikibox = wikibox .. '|}\n\n'
return wikibox
end
return p