|
|
| (16 intermediate revisions by 3 users not shown) |
| Line 1: |
Line 1: |
| local p = {} | | local p = {} |
|
| |
|
| -- Grabs args from the parent frame
| | local Utils = require('Module:Utils') |
| -- Trims and parses the args into a table, then returns the table
| | local IconUtils = require('Module:IconUtils') |
| function norm()
| | local InfoCardUtils = require('Module:InfoCardUtils') |
| local origArgs = mw.getCurrentFrame():getParent().args
| | local Lang = Utils.WikiLang |
| 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(frame) |
| function p.main() | | local PageName = frame.args[1] |
| -- get args from the Template
| | if (Lang == 'English') then TreeName = PageName else TreeName = Utils.TreeSearch(PageName) end |
| local args = norm()
| | local TreeData = mw.loadData( "Module:TreeData" ) |
|
| | local Tree = TreeData.trees[TreeName] |
| if args.tree == nil or args.tree == '' then | | local WikiText ='' |
| return '\'tree\' must be specified.'
| |
| end | |
| | | |
| -- assign variables for tree
| | WikiText = WikiText ..'__NOTOC__' |
| local tree = args.tree
| | WikiText = WikiText ..'Page name get test: ' .. PageName ..'</br>' |
|
| | WikiText = WikiText ..'Tree name get test: ' .. TreeName ..'</br>' |
| -- 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 | | if (Lang ~= 'English') then WikiText = WikiText .. '[[en:' .. Tree.Name.English .. ']]' end |
| wikibox = wikibox .. 'This tree is decorative only. \n'
| | if (Lang ~= 'Russian') then WikiText = WikiText .. '[[ru:' .. Tree.Name.Russian .. ']]' end |
| end | | if (Lang ~= 'German') then WikiText = WikiText .. '[[de:' .. Tree.Name.German .. ']]' end |
| if treeTable.isWater == 'Underwater' then | | if (Lang ~= 'French') then WikiText = WikiText .. '[[fr:' .. Tree.Name.French .. ']]' end |
| 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' | | local descriptionpage = Tree.Name[Lang] .. " - it is Tree." |
| wikibox = wikibox .. '{| class=\"wikitable\"\n'
| | WikiText = WikiText .. frame:callParserFunction{ name = '#description2', args = { descriptionpage }} |
|
| | WikiText = WikiText .. frame:callParserFunction{ name = '#setmainimage', args = { TreeName .. "_Tree.jpg" }} |
| -- 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
| |
| local resourceItem = treeTable.resourceItem
| |
| local debrisResources = treeTable.debrisResources
| |
| local listItem = ''
| |
| -- for each item in the list (a is position, b is value)
| |
| for a,r in ipairs(resourceItem) do
| |
| --if not these tags listed here
| |
| if r ~='[[]]' then
| |
| -- add the tag to the list
| |
| list = list .. r
| |
| end
| |
| -- if not the last item in the list
| |
| if (r ~= resourceItem[#resourceItem]) then
| |
| -- add a comma
| |
| listItem = listItem .. ', '
| |
| end
| |
| end
| |
|
| |
| local listDebris = ''
| |
| -- 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
| |
| list = list .. b
| |
| 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 .. '| Resource Yeilds : \n'
| |
| wikibox = wikibox .. '| ' .. listItem .. ' from logs 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
| |
| | | |
| | return WikiText |
| end | | end |
|
| |
|
| return p | | return p |