Module:Misc: Difference between revisions
From Exiled Kingdoms Wiki
mNo edit summary |
mNo edit summary |
||
(15 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
]] | ]] | ||
p = {} | p = {} | ||
local Comp = require( "Module:ValComp" ) | |||
Traits ={'Strength', 'Endurance', 'Agility', 'Intellect', 'Awareness', 'Personality'} | |||
Arg1 = mw.getCurrentFrame().args[1] | Arg1 = mw.getCurrentFrame().args[1] | ||
Line 8: | Line 12: | ||
Arg3 = mw.getCurrentFrame().args[3] | Arg3 = mw.getCurrentFrame().args[3] | ||
Arg4 = mw.getCurrentFrame().args[4] | Arg4 = mw.getCurrentFrame().args[4] | ||
function p.imgLink() | |||
size = mw.getCurrentFrame().args['size'] | |||
nolink = mw.getCurrentFrame().args['ln'] | |||
icon = mw.getCurrentFrame().args['icon'] | |||
addcolor = mw.getCurrentFrame().args['Colo'] | |||
if (size == nil or size == '') then | |||
if (Arg3 == nil or Arg3 == '') then | |||
size = 32 | |||
else | |||
size = Arg3 | |||
end | |||
end | |||
if (Arg2 == nil or Arg2 == '') then | |||
Arg2 = 'png' | |||
end | |||
linktxt = '' | |||
dirlink = string.format('[[%s]]',Arg1) | |||
if (icon == '1') then | |||
argtbl = { 'genSel', 'Icon'} | |||
inm = string.format(':%s',Arg1) | |||
tmpicon = mw.getCurrentFrame():expandTemplate{ title = inm, args = argtbl } | |||
linktxt = string.format('[[File:%s|%spx|link=%s]]', tmpicon,size,Arg1) | |||
elseif (icon ~= 0 and icon == nil) then | |||
linktxt = string.format('[[File:%s.%s|%spx|link=%s]]',Arg1,Arg2,size,Arg1) | |||
else | |||
linktxt = string.format('[[File:%s|%spx|link=%s]]',icon,size,Arg1) | |||
end | |||
if (nolink ~= true) then | |||
if (addcolor == '1') then | |||
dirlink = string.format('<span style="background-color:Black">%s</span>', dirlink) | |||
linktxt = string.format('%s %s',linktxt,dirlink) | |||
else | |||
linktxt = string.format('%s %s',linktxt,dirlink) | |||
end | |||
end | |||
return linktxt | |||
end | |||
function p.Rarity() | function p.Rarity() | ||
Line 16: | Line 58: | ||
Common = 'Lime'} | Common = 'Lime'} | ||
longtxt = '' | longtxt = '' | ||
if rarities[Arg1] == nil then | if (rarities[Arg1] == nil) then | ||
Arg1 = 'Common' | Arg1 = 'Common' | ||
end | end | ||
Line 22: | Line 64: | ||
spantag:css('color', rarities[Arg1]) | spantag:css('color', rarities[Arg1]) | ||
spantag:wikitext(Arg1) | spantag:wikitext(Arg1) | ||
spantag = spantag:allDone() | spantag = tostring(spantag:allDone()) | ||
shorttxt = spantag | shorttxt = spantag | ||
if (Arg2 ~= nil and Arg2 ~= '') then | if (Arg2 ~= nil and Arg2 ~= '') then | ||
if Arg1 == 'Unique' then | if (Arg1 == 'Unique') then | ||
longtxt = string.format('This is a %s item, found only once.', spantag) | longtxt = string.format('This is a %s item, found only once.', spantag) | ||
elseif Arg1 == 'Common' then | elseif (Arg1 == 'Common') then | ||
longtxt = string.format('This is a %s item, a frequent drop or obtainable from merchants.', spantag) | longtxt = string.format('This is a %s item, a frequent drop or obtainable from merchants.', spantag) | ||
elseif Arg1 == 'Uncommon' then | elseif (Arg1 == 'Uncommon') then | ||
longtxt = string.format('This is an %s item, a rare drop or obtainable from faction specific merchants.', spantag) | longtxt = string.format('This is an %s item, a rare drop or obtainable from faction specific merchants.', spantag) | ||
elseif Arg1 == 'Limited' then | elseif (Arg1 == 'Limited') then | ||
longtxt = string.format('This is a %s item that can only be obtained a set amount of times.', spantag) | longtxt = string.format('This is a %s item that can only be obtained a set amount of times.', spantag) | ||
elseif Arg1 == 'Crafted' then | elseif (Arg1 == 'Crafted') then | ||
longtxt = string.format('This is a %s item, obtainable as a rare drop or by the player interacting with certain NPCs.', spantag) | longtxt = string.format('This is a %s item, obtainable as a rare drop or by the player interacting with certain NPCs.', spantag) | ||
end | end | ||
Line 40: | Line 82: | ||
return shorttxt | return shorttxt | ||
end | end | ||
function p.Cost() | |||
retval = 0 | |||
if (Arg3 ~= '' and Arg3 ~= nil) then | |||
if (Arg1 ~= nil and Arg1 ~= '') then | |||
return Arg1 | |||
end | |||
retval = Arg2 * 4 | |||
else | |||
if Arg2 ~= nil and Arg2 ~= '' then | |||
return Arg2 | |||
end | |||
retval = Arg1 / 4 | |||
end | |||
return string.format('%i',retval) | |||
end | |||
function p.traitDisp() | |||
txtout = '' | |||
RawTraits = mw.text.split(Arg1,',',true) | |||
size = mw.getCurrentFrame().args[2] | |||
if (size == nil or size == '') then | |||
size = 16 | |||
end | |||
for i, trt in pairs(RawTraits) do | |||
if (tonumber(trt) > 0) then | |||
trlnk = string.format('[[File:%s.png|%spx|link=%s]] %s ', Traits[i], size, Traits[i], trt) | |||
txtout = txtout .. trlnk | |||
end | |||
end | |||
return txtout | |||
end | |||
function p.traitSel() | |||
trsel = 0 | |||
RawTraits = mw.text.split(Arg1,',',true) | |||
Utrt = mw.getCurrentFrame().args[2] | |||
Symb = mw.getCurrentFrame().args[3] | |||
Chkval = mw.getCurrentFrame().args[4] | |||
if (Utrt == nil or Utrt == '') then | |||
return 0 | |||
end | |||
if (Symb == nil or Symb == '') then | |||
Symb = 'gt' | |||
end | |||
if (Chkval == nil or Chkval == '') then | |||
Chkval = 0 | |||
end | |||
Rawind = Comp.getIndex(Traits, Utrt) | |||
if (Comp.Compare(RawTraits[Rawind], Symb, Chkval) == true) then | |||
trsel = 1 | |||
end | |||
return trsel | |||
end | |||
return p | return p |
Latest revision as of 21:42, 7 June 2017
--[[ Module for Miscellaneous smaller functions ]] p = {}
local Comp = require( "Module:ValComp" )
Traits ={'Strength', 'Endurance', 'Agility', 'Intellect', 'Awareness', 'Personality'}
Arg1 = mw.getCurrentFrame().args[1] Arg2 = mw.getCurrentFrame().args[2] Arg3 = mw.getCurrentFrame().args[3] Arg4 = mw.getCurrentFrame().args[4]
function p.imgLink()
size = mw.getCurrentFrame().args['size'] nolink = mw.getCurrentFrame().args['ln'] icon = mw.getCurrentFrame().args['icon'] addcolor = mw.getCurrentFrame().args['Colo'] if (size == nil or size == ) then if (Arg3 == nil or Arg3 == ) then size = 32 else size = Arg3 end end if (Arg2 == nil or Arg2 == ) then Arg2 = 'png' end linktxt = dirlink = string.format('%s',Arg1) if (icon == '1') then argtbl = { 'genSel', 'Icon'} inm = string.format(':%s',Arg1) tmpicon = mw.getCurrentFrame():expandTemplate{ title = inm, args = argtbl } linktxt = string.format('%spx', tmpicon,size,Arg1) elseif (icon ~= 0 and icon == nil) then linktxt = string.format('%spx',Arg1,Arg2,size,Arg1) else linktxt = string.format('%spx',icon,size,Arg1) end if (nolink ~= true) then if (addcolor == '1') then dirlink = string.format('%s', dirlink) linktxt = string.format('%s %s',linktxt,dirlink) else linktxt = string.format('%s %s',linktxt,dirlink) end end return linktxt
end
function p.Rarity()
rarities = {Unique = 'Red', Uncommon = 'Violet', Limited = 'rgb(220,0,0)', Crafted = 'DeepSkyBlue', Common = 'Lime'} longtxt = if (rarities[Arg1] == nil) then Arg1 = 'Common' end spantag = mw.html.create( 'span' ) spantag:css('color', rarities[Arg1]) spantag:wikitext(Arg1) spantag = tostring(spantag:allDone()) shorttxt = spantag if (Arg2 ~= nil and Arg2 ~= ) then if (Arg1 == 'Unique') then longtxt = string.format('This is a %s item, found only once.', spantag) elseif (Arg1 == 'Common') then longtxt = string.format('This is a %s item, a frequent drop or obtainable from merchants.', spantag) elseif (Arg1 == 'Uncommon') then longtxt = string.format('This is an %s item, a rare drop or obtainable from faction specific merchants.', spantag) elseif (Arg1 == 'Limited') then longtxt = string.format('This is a %s item that can only be obtained a set amount of times.', spantag) elseif (Arg1 == 'Crafted') then longtxt = string.format('This is a %s item, obtainable as a rare drop or by the player interacting with certain NPCs.', spantag) end return longtxt end return shorttxt
end
function p.Cost()
retval = 0 if (Arg3 ~= and Arg3 ~= nil) then if (Arg1 ~= nil and Arg1 ~= ) then return Arg1 end retval = Arg2 * 4 else if Arg2 ~= nil and Arg2 ~= then return Arg2 end retval = Arg1 / 4 end return string.format('%i',retval)
end
function p.traitDisp()
txtout = RawTraits = mw.text.split(Arg1,',',true) size = mw.getCurrentFrame().args[2] if (size == nil or size == ) then size = 16 end for i, trt in pairs(RawTraits) do if (tonumber(trt) > 0) then trlnk = string.format('%spx %s ', Traits[i], size, Traits[i], trt) txtout = txtout .. trlnk end end return txtout
end
function p.traitSel()
trsel = 0 RawTraits = mw.text.split(Arg1,',',true) Utrt = mw.getCurrentFrame().args[2] Symb = mw.getCurrentFrame().args[3] Chkval = mw.getCurrentFrame().args[4] if (Utrt == nil or Utrt == ) then return 0 end if (Symb == nil or Symb == ) then Symb = 'gt' end if (Chkval == nil or Chkval == ) then Chkval = 0 end Rawind = Comp.getIndex(Traits, Utrt) if (Comp.Compare(RawTraits[Rawind], Symb, Chkval) == true) then trsel = 1 end return trsel
end
return p