Created page with "-- test in console: -- =p.main(mw.getCurrentFrame():newChild{title="Template:Table ComponentFields",args={"FixTransformsEnabled", "Bool", "Clamps IK transforms to reasonable values and Resets IK every update."}}:newChild{title="Module:Test",args={}}) local p = {} function p.main(frame) local body = "" local templateFrame = frame:getParent() local i = 0 while true do local argI = i * 3 + 1 local name = templateFrame.args[argI] local type = templateFrame.arg..." |
don't fill Fields with stub. I see you |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
-- test in console: | -- test in console: | ||
-- =p.main(mw.getCurrentFrame():newChild{title="Template:Table ComponentFields",args={"FixTransformsEnabled", "Bool", "Clamps IK transforms to reasonable values and Resets IK every update."}}:newChild{title="Module:Test",args={}}) | -- =p.main(mw.getCurrentFrame():newChild{title="Template:Table ComponentFields",args={"FixTransformsEnabled", "Bool", "Clamps IK transforms to reasonable values and Resets IK every update."}}:newChild{title="Module:Test",args={}}) | ||
-- =p.main(mw.getCurrentFrame():newChild{title="Template:Table ComponentFields",args={"FixTransformsEnabled", "Bool", "Clamps IK transforms to reasonable values and Resets IK every update.", ["TypeStringAdvanced0"] = "true"}}:newChild{title="Module:Test",args={}}) | |||
local p = {} | local p = {} | ||
Line 6: | Line 7: | ||
function p.main(frame) | function p.main(frame) | ||
local body = "" | local body = "" | ||
local isStub = false | |||
local templateFrame = frame:getParent() | local templateFrame = frame:getParent() | ||
local i = 0 | local i = 0 | ||
Line 16: | Line 17: | ||
local description = templateFrame.args[argI + 2] | local description = templateFrame.args[argI + 2] | ||
local typeString = templateFrame.args["TypeString"..i] or type | local typeString = templateFrame.args["TypeString"..i] or type | ||
local typeStringAdvanced = templateFrame.args["TypeAdv"..i] | |||
if name == nil then | if name == nil then | ||
Line 21: | Line 23: | ||
end | end | ||
description = mw.text.trim(description) | |||
if description == "{{stub}}" then isStub = true end | |||
if description == "" then | |||
isStub = true | |||
else | |||
--description = "<translate>" .. description .. "</translate>" | |||
end | |||
body = body.."|-\n" | body = body.."|-\n" | ||
body = body.."|<code>"..name.."</code>\n" | body = body.."|<code>"..name.."</code>\n" | ||
body = body.."|'''[[Type:"..type.."|"..typeString.."]]'''\n" | if typeStringAdvanced == "true" then | ||
body = body.."|"..typeString.."\n" | |||
else | |||
body = body.."|'''[[Type:"..type.."|"..typeString.."]]'''\n" | |||
end | |||
body = body.."|"..description.."\n" | body = body.."|"..description.."\n" | ||
i = i + 1 | i = i + 1 | ||
end | end | ||
if isStub then body = body.."[[Category:ComponentStubs]]" end | |||
return body | return body | ||
end | end | ||
return p | return p |
Latest revision as of 19:40, 10 February 2025
This module is used to implement the logic of Template:Table ComponentFields and Template:Table TypeFields. Don't use it anywhere else please thank.
-- test in console:
-- =p.main(mw.getCurrentFrame():newChild{title="Template:Table ComponentFields",args={"FixTransformsEnabled", "Bool", "Clamps IK transforms to reasonable values and Resets IK every update."}}:newChild{title="Module:Test",args={}})
-- =p.main(mw.getCurrentFrame():newChild{title="Template:Table ComponentFields",args={"FixTransformsEnabled", "Bool", "Clamps IK transforms to reasonable values and Resets IK every update.", ["TypeStringAdvanced0"] = "true"}}:newChild{title="Module:Test",args={}})
local p = {}
function p.main(frame)
local body = ""
local isStub = false
local templateFrame = frame:getParent()
local i = 0
while true do
local argI = i * 3 + 1
local name = templateFrame.args[argI]
local type = templateFrame.args[argI + 1]
local description = templateFrame.args[argI + 2]
local typeString = templateFrame.args["TypeString"..i] or type
local typeStringAdvanced = templateFrame.args["TypeAdv"..i]
if name == nil then
break
end
description = mw.text.trim(description)
if description == "{{stub}}" then isStub = true end
if description == "" then
isStub = true
else
--description = "<translate>" .. description .. "</translate>"
end
body = body.."|-\n"
body = body.."|<code>"..name.."</code>\n"
if typeStringAdvanced == "true" then
body = body.."|"..typeString.."\n"
else
body = body.."|'''[[Type:"..type.."|"..typeString.."]]'''\n"
end
body = body.."|"..description.."\n"
i = i + 1
end
if isStub then body = body.."[[Category:ComponentStubs]]" end
return body
end
return p