Module

WorldPills

From Dogcraft Wiki

No edit summary
m (smaller world pills)
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {} --p stands for package
local p = {} --p stands for package
local worldTools = require('Module:World')


function subworld(world, subworld)
local lang = mw.language.getContentLanguage()
input = mw.ustring.lower(world .. subworld)
 
subworlds = {"husky", "beagle", "akita", "corgi", "labrador", "shepherd"}
function pill (text, color)
for key,value in ipairs(subworlds) do
return ('[[' .. text .. '|<span class="world-pill" style="background:' .. color ..  
if (mw.ustring.find(input, value, 1, true) ~= nil) then
'; padding: 3px 7px; color: white; border-radius: 7.5px; display: inline-block; margin-bottom:3px; font-size: 12px; letter-spacing: .4px;">' .. text .. '</span>]]')
return mw.language.usfirst(value)
end
end
return ''--return 'not found'
end
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.usfirst(value)
end
end
if (mw.ustring.find(input, 'survival', 1, true) ~= nil) then
return mw.language.usfirst('survival 1')
end
return ''--return 'not found'
end


function p.single(frame)
function p.single(frame)
color = frame.args[color] or 'lightslategray'
color = frame.args[color] or 'lightslategray'
world = world(frame.args[1], frame.args[2])
world= worldTools.extractWorld(frame.args[1] .. frame.args[2])
subworld = subworld(frame.args[1], frame.args[2])
subworld = worldTools.extractSubworld(frame.args[1] .. frame.args[2])
if (subworld ~= '') then
if (subworld ~= '') then
return ('[[' .. world .. '|<span class="world-pill" style="background:' .. color ..
return (pill(lang:ucfirst(world), color) .. ' ' .. pill(lang:ucfirst(subworld), 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
elseif (world ~= '') then
return ('[[' .. world .. '|<span class="world-pill" style="background:' .. color ..
return (pill(lang:ucfirst(world), color))
'; padding: 3px 7px; color: white; font-weight: bold; border-radius: 7.5px; display: inline-block;">' .. world .. '</span>]]')
else  
else  
return ''
return ''
end
end
end
function p.multi(frame)
color = frame.args[color] or 'lightslategray'
frame.args[2] = frame.args[2] or ''
input = mw.ustring.lower(frame.args[1] .. frame.args[2])
out = ''
for key,value in ipairs(worldTools.worlds) do
if (mw.ustring.find(input, value, 1, true) ~= nil) then
value = lang:ucfirst(value)
out = out .. pill(value, color) .. ' '
end
end
return out
end
end


return p
return p

Latest revision as of 01:25, 6 September 2024

Documentation for this module may be created at Module:WorldPills/doc

local p = {} --p stands for package
local worldTools = require('Module:World')

local lang = mw.language.getContentLanguage()

function pill (text, color)
	return ('[[' .. text .. '|<span class="world-pill" style="background:' .. color .. 
			'; padding: 3px 7px; color: white; border-radius: 7.5px; display: inline-block; margin-bottom:3px; font-size: 12px; letter-spacing: .4px;">' .. text .. '</span>]]')
end


function p.single(frame)
	color = frame.args[color] or 'lightslategray'
	world= worldTools.extractWorld(frame.args[1] .. frame.args[2])
	subworld = worldTools.extractSubworld(frame.args[1] .. frame.args[2])
	
	if (subworld ~= '') then
		return (pill(lang:ucfirst(world), color) .. ' ' .. pill(lang:ucfirst(subworld), color))
	elseif (world ~= '') then
		return (pill(lang:ucfirst(world), color))
	else 
		return ''
	end
end


function p.multi(frame)
	color = frame.args[color] or 'lightslategray'
	frame.args[2] = frame.args[2] or ''
	input = mw.ustring.lower(frame.args[1] .. frame.args[2])
	out = ''
	
	for key,value in ipairs(worldTools.worlds) do 
		if (mw.ustring.find(input, value, 1, true) ~= nil) then
			value = lang:ucfirst(value)
			out = out .. pill(value, color) .. ' '
		end
	end
	
	return out
end


return p
Background SRN Opening by Montenator