Leaguepedia | League of Legends Esports Wiki
Register
[checked revision][checked revision]
((via Mediawiker ST3))
(finalExtends)
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
local util_args = require('Module:ArgsUtil')
+
local util_vars = require("Module:VarsUtil")
local LOOKUP = mw.loadData('Module:Regionnames')
 
   
  +
local p = require('Module:EntityAbstract'):finalExtends()
 
local h = {}
 
local h = {}
   
  +
p.objectType = 'Region'
function h.getInfo(str, settings)
 
  +
p.imagelength = 'link'
if not str then str = '' end
 
  +
p.defaultlength = 'medium'
settings.vars = util_args.lookupVars(str, LOOKUP)
 
  +
p.cssClass = 'region-object'
return
 
end
 
   
function h.makeImage(settings)
+
function p:image(opts)
  +
if self.is_nil then return nil end
 
if not opts then opts = {} end
 
local div = mw.html.create('div')
 
local div = mw.html.create('div')
 
:addClass('region-icon')
 
:addClass('region-icon')
:cssText(('color:%s'):format(settings.vars.hex))
+
:cssText(('color:%s'):format(self:get('hex')))
:wikitext(settings.vars.short)
+
:wikitext(self:get('short'))
return div
+
return tostring(div)
end
 
 
local p = {}
 
 
function p.main(frame)
 
local args = util_args.merge(true)
 
if not args[1] and not args.sub then
 
return ''
 
end
 
local style = args[2] or 'rightmedium'
 
return p[style](args[1], args)
 
end
 
 
function p.long(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
return settings.vars.long
 
end
 
 
function p.medium(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
return settings.vars.medium
 
end
 
 
function p.short(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
return settings.vars.short
 
end
 
 
function p.adjective(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
return settings.vars.adjective
 
end
 
 
function p.onlyimage(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
return tostring(h.makeImage(settings))
 
end
 
 
function p.rightshort(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
local tbl = mw.html.create('div')
 
:cssText('display:inline-block;')
 
tbl:node(h.makeImage(settings))
 
tbl:wikitext(' ' .. settings.vars.short)
 
return tostring(tbl)
 
end
 
 
function p.rightmedium(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
local tbl = mw.html.create('div')
 
:cssText('display:inline-block;')
 
tbl:node(h.makeImage(settings))
 
tbl:wikitext(' ' .. settings.vars.medium)
 
return tostring(tbl)
 
end
 
 
function p.rightlong(str, settings)
 
if not settings then settings = {} end
 
h.getInfo(str, settings)
 
local tbl = mw.html.create('div')
 
:cssText('display:inline-block;')
 
tbl:node(h.makeImage(settings))
 
tbl:wikitext(' ' .. settings.vars.long)
 
return tostring(tbl)
 
 
end
 
end
   

Revision as of 05:41, 24 August 2020

Edit the documentation or categories for this module.


local util_vars = require("Module:VarsUtil")

local p = require('Module:EntityAbstract'):finalExtends()
local h = {}

p.objectType = 'Region'
p.imagelength = 'link'
p.defaultlength = 'medium'
p.cssClass = 'region-object'

function p:image(opts)
	if self.is_nil then return nil end
	if not opts then opts = {} end
	local div = mw.html.create('div')
		:addClass('region-icon')
		:cssText(('color:%s'):format(self:get('hex')))
		:wikitext(self:get('short'))
	return tostring(div)
end

return p