Module
WorldPills
From Dogcraft Wiki
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
for key,value in ipairs(subworlds) do | for key,value in ipairs(subworlds) do | ||
if (mw.ustring.find(input, value, 1, true) ~= nil) then | if (mw.ustring.find(input, value, 1, true) ~= nil) then | ||
return mw.language. | return mw.language.ucfirst(value) | ||
end | end | ||
end | end | ||
Line 17: | Line 17: | ||
for key,value in ipairs(worlds) do | for key,value in ipairs(worlds) do | ||
if (mw.ustring.find(input, value, 1, true) ~= nil) then | if (mw.ustring.find(input, value, 1, true) ~= nil) then | ||
return mw.language. | return mw.language.ucfirst(value) | ||
end | end | ||
end | end | ||
if (mw.ustring.find(input, 'survival', 1, true) ~= nil) then | if (mw.ustring.find(input, 'survival', 1, true) ~= nil) then | ||
return mw.language. | return mw.language.ucfirst('survival 1') | ||
end | end | ||
return ''--return 'not found' | return ''--return 'not found' |
Revision as of 01:26, 29 June 2022
Documentation for this module may be created at Module:WorldPills/doc
local p = {} --p stands for package
function subworld(world, subworld)
input = mw.ustring.lower(world .. subworld)
subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd"}
for key,value in ipairs(subworlds) do
if (mw.ustring.find(input, value, 1, true) ~= nil) then
return mw.language.ucfirst(value)
end
end
return ''--return 'not found'
end
function world(world, subworld)
input = mw.ustring.lower(world .. subworld)
worlds = {"survival 1", "survival 2", "survival 3", "survival 4", "survival 5", "creative", "patreon", "hub", "amplified", "MCMMO", "skyblock"}
for key,value in ipairs(worlds) do
if (mw.ustring.find(input, value, 1, true) ~= nil) then
return mw.language.ucfirst(value)
end
end
if (mw.ustring.find(input, 'survival', 1, true) ~= nil) then
return mw.language.ucfirst('survival 1')
end
return ''--return 'not found'
end
function p.single(frame)
color = frame.args[color] or 'lightslategray'
world = world(frame.args[1], frame.args[2])
subworld = subworld(frame.args[1], frame.args[2])
if (subworld ~= '') then
return ('[[' .. world .. '|<span class="world-pill" style="background:' .. color ..
'; padding: 3px 7px; color: white; font-weight: bold; border-radius: 7.5px; display: inline-block;">' .. world ..
'</span>]] [[' .. subworld .. '|<span class="world-pill" style="background:' .. color ..
'; padding: 3px 7px; color: white; font-weight: bold; border-radius: 7.5px; display: inline-block;">' .. subworld .. '</span>]]')
elseif (world ~= '') then
return ('[[' .. world .. '|<span class="world-pill" style="background:' .. color ..
'; padding: 3px 7px; color: white; font-weight: bold; border-radius: 7.5px; display: inline-block;">' .. world .. '</span>]]')
else
return ''
end
end
return p
This page was last modified on 29 June 2022, at 01:26. (2 months ago)