Module:HabModuleSpecial: Difference between revisions

From Terra Invicta Official Wiki
Redwah (talk | contribs)
No edit summary
Redwah (talk | contribs)
No edit summary
Line 25: Line 25:
     return hmsData[hmsName][1]  .. frame.args['controlPointCapacity'] .. hmsData[hmsName][2]  
     return hmsData[hmsName][1]  .. frame.args['controlPointCapacity'] .. hmsData[hmsName][2]  
     elseif hmsData[hmsName][3] == 'techBonus' then
     elseif hmsData[hmsName][3] == 'techBonus' then
     local techBonus = tostring(tonumber(frame.args['techBonus']) * 100) .. '%'
     local techBonus = tostring(tonumber(frame.args['techBonus']) * 100) .. '% '
     local techCat = frame.args['techCat']
     local techCat = frame.args['techCat']
     return hmsData[hmsName][1]  .. techBonus ..  IconModule.Icon({args={techCat}}) .. techCat .. hmsData[hmsName][2]
     return hmsData[hmsName][1]  .. techBonus ..  IconModule.Icon({args={techCat}}) .. techCat .. hmsData[hmsName][2]

Revision as of 20:23, 17 November 2025

Documentation for this module may be created at Module:HabModuleSpecial/doc

-- This is a LUA version of the Template:HabModuleSpecial page. 

local p = {}

local IconModule = require('Module:Icon')
local hmsData = mw.loadData( 'Module:HabModuleSpecial/data' )

function p.hms( frame )
    local hmsName = frame.args[1]
    if not hmsName or not hmsData[hmsName] then
    	return 'No such Hab Module Special'	
    end
	-- hmsData[hmsName][1] is the text before the value.
	-- hmsData[hmsName][2] is the text after the value.
	-- hmsData[hmsName][3] is the value type to insert.
    if not hmsData[hmsName][3] then
    	return hmsData[hmsName][1]
    elseif hmsData[hmsName][3] == 'specialRulesValue' then
    	return hmsData[hmsName][1]  .. frame.args['specialRulesValue'] .. hmsData[hmsName][2] 
    elseif hmsData[hmsName][3] == 'specialRulesValue%' then
    	return hmsData[hmsName][1]  .. tostring(tonumber(frame.args['specialRulesValue']) * 100) .. '%' .. hmsData[hmsName][2] 
    elseif hmsData[hmsName][3] == 'constructionTimeModifier' then
    	return hmsData[hmsName][1]  .. frame.args['constructionTimeModifier'] .. hmsData[hmsName][2] 
    elseif hmsData[hmsName][3] == 'controlPointCapacity' then
    	return hmsData[hmsName][1]  .. frame.args['controlPointCapacity'] .. hmsData[hmsName][2] 
    elseif hmsData[hmsName][3] == 'techBonus' then
    	local techBonus = tostring(tonumber(frame.args['techBonus']) * 100) .. '% '
    	local techCat = frame.args['techCat']
    	return hmsData[hmsName][1]  .. techBonus ..  IconModule.Icon({args={techCat}}) .. techCat .. hmsData[hmsName][2]
    end
	return 'ERROR, this should never appear.'
end

return p