mNo edit summary |
mNo edit summary |
||
Line 47: | Line 47: | ||
Container | Container | ||
:tag( 'tr' ) | :tag( 'tr' ) | ||
:attr( 'style', 'height: | :attr( 'style', 'height: 30px;') | ||
:tag( 'td' ) -- The Input binding post | :tag( 'td' ) -- The Input binding post | ||
:attr( 'rowspan', '2' ) | :attr( 'rowspan', '2' ) | ||
:attr( 'style', 'background-color: ' .. getIOColor(Input, 0.3) .. '; border: | :attr( 'style', 'background-color: ' .. getIOColor(Input, 0.3) .. '; border: 5px solid ' .. getIOColor(Input, 1.0) .. '; border-left: none;') | ||
:done() | :done() | ||
:tag( 'td' ) -- The Input name | :tag( 'td' ) -- The Input name | ||
:attr( 'style', 'text-align: left; border-right: | :attr( 'style', 'text-align: left; border-right: 20px solid #11151d; border-bottom: 10px solid #11151d; border-top: 2px solid #11151d; background-color:' .. getIOColor(Input, 0.6) .. ';') | ||
:wikitext( Input.Name ) | :wikitext( Input.Name ) | ||
:done() | :done() | ||
:tag( 'td' ) -- The Output binding post | :tag( 'td' ) -- The Output binding post | ||
:attr( 'rowspan', '2' ) | :attr( 'rowspan', '2' ) | ||
:attr( 'style', 'background-color: ' .. getIOColor(Output, 0.3) .. '; border: | :attr( 'style', 'background-color: ' .. getIOColor(Output, 0.3) .. '; border: 5px solid ' .. getIOColor(Output, 1.0) .. '; border-right: none;') | ||
:done() | :done() | ||
:done() | :done() | ||
:tag( 'tr') | :tag( 'tr') | ||
:attr( 'style', 'height: | :attr( 'style', 'height: 30px;') | ||
:tag( 'td' ) | :tag( 'td' ) | ||
:attr( 'style', 'text-align: right; border-left: | :attr( 'style', 'text-align: right; border-left: 20px solid #11151d; border-bottom: 2px solid #11151d; border-top: 10px solid #11151d; background-color: ' .. getIOColor(Output, 0.6) .. ';') | ||
:wikitext( Output and Output.Name or ' ' ) | :wikitext( Output and Output.Name or ' ' ) | ||
:done() | :done() |
Revision as of 05:21, 13 January 2024
Documentation for this module may be created at Module:Test/doc
local p = {}
local typeColor =
{
User = '255, 128, 255',
Impulse = '179, 255, 255',
Boolean = '115, 115, 115'
}
local mt = {__index = function () return "0,0,0" end}
setmetatable(typeColor, mt)
function p.ProtoFlux( frame )
local inputsDecode = mw.text.jsonDecode( frame.args.Inputs );
local outputsDecode = mw.text.jsonDecode( frame.args.Outputs );
local protofluxContainer = mw.html.create( 'table' )
protofluxContainer
:attr( 'cellspacing', '0px')
:attr( 'style', 'color: white; background-color: #11151d;' )
:attr( 'width', "256px" )
:tag( 'tr' )
:attr( 'style', 'height: 50px;')
:tag( 'th' )
:attr('width', '20%')
:done()
:tag( 'th' )
:attr('width', '60%')
:wikitext(frame.args.Name)
:done()
:tag( 'th')
:attr('width', '20%');
local maxRows = math.max(#inputsDecode, #outputsDecode)
for i=1,maxRows,1 do
CreateIORow(protofluxContainer, inputsDecode[i], outputsDecode[i]);
end
return tostring(protofluxContainer);
end
-- Each Input/Output row is really 2 rows high.
function CreateIORow(Container, Input, Output)
Container
:tag( 'tr' )
:attr( 'style', 'height: 30px;')
:tag( 'td' ) -- The Input binding post
:attr( 'rowspan', '2' )
:attr( 'style', 'background-color: ' .. getIOColor(Input, 0.3) .. '; border: 5px solid ' .. getIOColor(Input, 1.0) .. '; border-left: none;')
:done()
:tag( 'td' ) -- The Input name
:attr( 'style', 'text-align: left; border-right: 20px solid #11151d; border-bottom: 10px solid #11151d; border-top: 2px solid #11151d; background-color:' .. getIOColor(Input, 0.6) .. ';')
:wikitext( Input.Name )
:done()
:tag( 'td' ) -- The Output binding post
:attr( 'rowspan', '2' )
:attr( 'style', 'background-color: ' .. getIOColor(Output, 0.3) .. '; border: 5px solid ' .. getIOColor(Output, 1.0) .. '; border-right: none;')
:done()
:done()
:tag( 'tr')
:attr( 'style', 'height: 30px;')
:tag( 'td' )
:attr( 'style', 'text-align: right; border-left: 20px solid #11151d; border-bottom: 2px solid #11151d; border-top: 10px solid #11151d; background-color: ' .. getIOColor(Output, 0.6) .. ';')
:wikitext( Output and Output.Name or ' ' )
:done()
end
function getIOColor(Connector, alpha)
return (Connector and 'rgba(' .. typeColor[Connector.Type] .. ',' .. alpha .. ')' or 'rgba(0,0,0,0)')
end
return p