Module:HabModuleSpecial

From Terra Invicta Official Wiki
Revision as of 01:55, 22 September 2025 by Redwah (talk | contribs) (Created page with "-- 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 local valueString = '' if frame.args['specialRulesValue'] and frame.args['specialRulesValue'] ~= '' then valueString...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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
    
    local valueString = ''
    if frame.args['specialRulesValue'] and frame.args['specialRulesValue'] ~= '' then
    	valueString = frame.args['specialRulesValue']
    elseif frame.args['constructionTimeModifier'] and frame.args['constructionTimeModifier'] ~= '' then
    	valueString = frame.args['constructionTimeModifier']
    elseif frame.args['controlPointCapacity'] and frame.args['controlPointCapacity'] ~= '' then
    	valueString = frame.args['controlPointCapacity']
    elseif frame.args['techBonus'] and frame.args['techBonus'] ~= '' then
    	valueString = tostring(tonumber(frame.args['techBonus']) * 100)
    	local techCat = frame.args['techCat']
    	valueString = valueString .. '%' .. IconModule.Icon({args={techCat}}) .. techCat
    end

	-- hmsData[hmsName][1] is the text before the value.
	-- hmsData[hmsName][2] is the text after the value.
    return hmsData[hmsName][1]  .. valueString .. hmsData[hmsName][2] 
end

return p