Module:HabModuleSpecial: Difference between revisions

From Terra Invicta Official Wiki
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..."
 
Redwah (talk | contribs)
No edit summary
Line 11: Line 11:
     return 'No such Hab Module Special'
     return 'No such Hab Module Special'
     end
     end
      
-- hmsData[hmsName][1] is the text before the value.
     local valueString = ''
-- hmsData[hmsName][2] is the text after the value.
    if frame.args['specialRulesValue'] and frame.args['specialRulesValue'] ~= '' then
-- hmsData[hmsName][3] is the value type to insert.
     valueString = frame.args['specialRulesValue']
     if not hmsData[hmsName][3] then
     elseif frame.args['constructionTimeModifier'] and frame.args['constructionTimeModifier'] ~= '' then
    return hmsData[hmsName][1]
     valueString = frame.args['constructionTimeModifier']
     elseif hmsData[hmsName][3] == 'specialRulesValue' then
     elseif frame.args['controlPointCapacity'] and frame.args['controlPointCapacity'] ~= '' then
    return hmsData[hmsName][1]  .. frame.args['specialRulesValue'] .. hmsData[hmsName][2]
     valueString = frame.args['controlPointCapacity']
    elseif hmsData[hmsName][3] == 'specialRulesValue%' then
     elseif frame.args['techBonus'] and frame.args['techBonus'] ~= '' then
     return hmsData[hmsName][1]  .. tostring(tonumber(frame.args['specialRulesValue']) * 100) .. '%' .. hmsData[hmsName][2]  
     valueString = tostring(tonumber(frame.args['techBonus']) * 100)
     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']
     local techCat = frame.args['techCat']
     valueString = valueString .. '%' .. IconModule.Icon({args={techCat}}) .. techCat
     return hmsData[hmsName][1]  .. techBonus .. IconModule.Icon({args={techCat}}) .. techCat .. hmsData[hmsName][2]
     end
     end
 
return 'ERROR, this should never appear.'
-- 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
end


return p
return p

Revision as of 03:07, 22 September 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