Module:Inventory: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(support 'piercing' PV arrow in inventory list) |
||
Line 25: | Line 25: | ||
end | end | ||
local result = cargo.query('ItemsTable=IT,GeneralData=GD', | local result = cargo.query('ItemsTable=IT,GeneralData=GD,MissileWeaponData=MWD', | ||
'PlainName,Vibro,MaxPV,BasePV,Damage,GD.JoinKey=Page', | 'PlainName,Vibro,MaxPV,BasePV,Damage,PenetratingAmmo,GD.JoinKey=Page', | ||
{ where='(GD._pageNamespace="0" OR GD._pageNamespace="10002") AND GD.ObjectID="' .. objname .. '"', | { where='(GD._pageNamespace="0" OR GD._pageNamespace="10002") AND GD.ObjectID="' .. objname .. '"', | ||
default='0', | default='0', | ||
limit='1', | limit='1', | ||
join='GD.JoinKey=IT.JoinKey'} ) | join='GD.JoinKey=IT.JoinKey,GD.JoinKey=MWD.JoinKey'} ) | ||
if not next(result) then | if not next(result) then | ||
Line 42: | Line 42: | ||
--[If damage, return weapon html that specifies damage, PV and max PV]-- | --[If damage, return weapon html that specifies damage, PV and max PV]-- | ||
local damage= result[1]['Damage'] | local damage = result[1]['Damage'] | ||
local piercingTemplate = '' | |||
if result[1]['PenetratingAmmo'] ~= nil and result[1]['PenetratingAmmo'] == '1' then | |||
piercingTemplate = frame:expandTemplate{title='PV', args={'pierce'}} | |||
else | |||
piercingTemplate = frame:expandTemplate{title='PV'} | |||
end | |||
if damage ~= nil and damage ~= '' then | if damage ~= nil and damage ~= '' then | ||
Line 63: | Line 69: | ||
:addClass('qud-inline-damage') | :addClass('qud-inline-damage') | ||
:wikitext(frame:expandTemplate{title='Heart'} .. '<span class="qud-inline-damage">' .. | :wikitext(frame:expandTemplate{title='Heart'} .. '<span class="qud-inline-damage">' .. | ||
damage .. '</span>'.. | damage .. '</span> '.. piercingTemplate .. | ||
'<span class="qud-inline-pv">' .. pv ..'</span>' .. pvstr) ) | '<span class="qud-inline-pv">' .. pv ..'</span>' .. pvstr) ) | ||
end | end |
Revision as of 20:20, 5 October 2021
local p = {}
local cargo= mw.ext.cargo
local favilink = require'Module:Favilink'
function p.main(frame)
local frame = mw.getCurrentFrame()
local pv = ''
local maxpv = ''
local quantity = frame.args[2] or '1'
local chance = frame.args[4] or '100'
local weaponhtml
--[Getting query results...]
local objname
local name
if frame.args[1] ~= nil and frame.args[1] ~= '' then
objname = mw.text.trim(frame.args[1])
--return name
else
error "There is no argument specified! [[Category:pages with inventory errors]]"
end
local result = cargo.query('ItemsTable=IT,GeneralData=GD,MissileWeaponData=MWD',
'PlainName,Vibro,MaxPV,BasePV,Damage,PenetratingAmmo,GD.JoinKey=Page',
{ where='(GD._pageNamespace="0" OR GD._pageNamespace="10002") AND GD.ObjectID="' .. objname .. '"',
default='0',
limit='1',
join='GD.JoinKey=IT.JoinKey,GD.JoinKey=MWD.JoinKey'} )
if not next(result) then
return '[[' .. objname.. ']][[Category:pages with inventory errors]]'
else
name = result[1]['PlainName']
end
local favilinked = frame:expandTemplate{title='Favilink id', args={objname,'displayname-tooltip-override'}}
--[If damage, return weapon html that specifies damage, PV and max PV]--
local damage = result[1]['Damage']
local piercingTemplate = ''
if result[1]['PenetratingAmmo'] ~= nil and result[1]['PenetratingAmmo'] == '1' then
piercingTemplate = frame:expandTemplate{title='PV', args={'pierce'}}
else
piercingTemplate = frame:expandTemplate{title='PV'}
end
if damage ~= nil and damage ~= '' then
if result[1]['Vibro'] == '1' then
pv = '≈'
elseif result[1]['BasePV'] ~= nil then
pv = result[1]['BasePV']
maxpv = result[1]['MaxPV']
end
local pvstr = ''
if maxpv ~= nil and maxpv ~= '' then
pvstr = '<span style="color:#155352;">/' .. maxpv.. '</span>'
end
--[Define weaponhtml]
weaponhtml = mw.html.create('span')
:addClass('qud-inline-weap-stats')
:node(mw.html.create('span')
:addClass('qud-inline-damage')
:wikitext(frame:expandTemplate{title='Heart'} .. '<span class="qud-inline-damage">' ..
damage .. '</span> '.. piercingTemplate ..
'<span class="qud-inline-pv">' .. pv ..'</span>' .. pvstr) )
end
--[Define html...]--
local favilinkhtml = mw.html.create('div')
:addClass('qud-inv-favilink-wrapper')
:wikitext(favilinked)
if weaponhtml ~= nil then
favilinkhtml:node(weaponhtml)
end
local inventoryhtml = mw.html.create('div')
inventoryhtml
:addClass('qud-inventory-item')
:node(favilinkhtml)
:node(mw.html.create('span')
:addClass('qud-item-qty')
:wikitext('x' .. quantity)
:node(mw.html.create('span')
:addClass('qud-item-chance chance-' .. chance)
:wikitext('(' .. chance .. '%)')))
return tostring(inventoryhtml)
end
return p