Module:Inventory: Difference between revisions

409 bytes added ,  01:01, 27 January 2023
m
no edit summary
m (adjust previous fix)
mNo edit summary
 
Line 30: Line 30:
   --[logic for basic objects]--
   --[logic for basic objects]--


   --[Define favilink...]--
   --[special case for random items, ex: K-Goninon]--
   favilinked = frame:expandTemplate{title='Favilink id', args={objname,'displayname-tooltip-override'}}
   if objname == '$CALLBLUEPRINTMETHOD:Qud.API.EncountersAPI.GetAnItemBlueprint' then
  favilinkhtml = mw.html.create('div')  
    favilinkhtml = mw.html.create('div')
              :addClass('qud-inv-favilink-wrapper')
                :addClass('qud-inv-favilink-wrapper')
              :wikitext(favilinked)
                :node(mw.html.create('div')
                      :addClass('qud-inv-poptable-icon')
                      :wikitext('?'))
                      :node(mw.html.create('span')
                      :wikitext('Any random item'))


   --[If it can be found in the items or missle weapon table, define weapon html]--
   --[Otherwise, define typical favilink...]--
   local result = cargo.query('ItemsTable=IT,GeneralData=GD,MissileWeaponData=MWD',
   else
  'PlainName,Vibro,MaxPV,BasePV,Damage,PenetratingAmmo,GD.JoinKey=Page',
    favilinked = frame:expandTemplate{title='Favilink id', args={objname,'displayname-tooltip-override'}}
  { where='(GD._pageNamespace="0" OR GD._pageNamespace="10002") AND (GD.ObjectID="' .. objname .. '" OR GD.IDAliases HOLDS "' .. objname .. '")',
    favilinkhtml = mw.html.create('div')  
  default='0',
                :addClass('qud-inv-favilink-wrapper')
  limit='1',
                :wikitext(favilinked)
  join='GD.JoinKey=IT.JoinKey,GD.JoinKey=MWD.JoinKey'} )


  --[Exit if not found, it's an item that doesn't have combat data and only needs favilink and quantity]
    --[If it can be found in the items or missle weapon table, define weapon html]--
  if next(result) ~= nil then
    local result = cargo.query('ItemsTable=IT,GeneralData=GD,MissileWeaponData=MWD',
  --[If damage, return weapon html that specifies damage, PV and max PV]--
    'PlainName,Vibro,MaxPV,BasePV,Damage,PenetratingAmmo,GD.JoinKey=Page',
    { where='(GD._pageNamespace="0" OR GD._pageNamespace="10002") AND (GD.ObjectID="' .. objname .. '" OR GD.IDAliases HOLDS "' .. objname .. '")',
    default='0',
    limit='1',
    join='GD.JoinKey=IT.JoinKey,GD.JoinKey=MWD.JoinKey'} )


  local damage = result[1]['Damage']
    --[Exit if not found, it's an item that doesn't have combat data and only needs favilink and quantity]
  local piercingTemplate = ''
    if next(result) ~= nil then
  if result[1]['PenetratingAmmo'] ~= nil and result[1]['PenetratingAmmo'] == '1' then
     --[If damage, return weapon html that specifies damage, PV and max PV]--
     piercingTemplate = frame:expandTemplate{title='PV', args={'pierce'}}
  else
    piercingTemplate = frame:expandTemplate{title='PV'}
  end


  if damage ~= nil and damage ~= ''  then
    local damage = result[1]['Damage']
    if result[1]['Vibro'] == '1' then
    local piercingTemplate = ''
      pv = ''
     if result[1]['PenetratingAmmo'] ~= nil and result[1]['PenetratingAmmo'] == '1' then
     elseif result[1]['BasePV'] ~= nil then
      piercingTemplate = frame:expandTemplate{title='PV', args={'pierce'}}
      pv = result[1]['BasePV']
    else
       maxpv = result[1]['MaxPV']
       piercingTemplate = frame:expandTemplate{title='PV'}
     end
     end


     local pvstr = ''
     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


    if maxpv ~= nil and maxpv ~= '' then
      local pvstr = ''
      pvstr = '<span style="color:#155352;">/' .. maxpv.. '</span>'
 
      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
     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




  if weaponhtml ~= nil then
    if weaponhtml ~= nil then
    favilinkhtml:node(weaponhtml)
      favilinkhtml:node(weaponhtml)
  end
    end
    end
   end
   end
else
else
Line 96: Line 108:
                     :addClass('qud-inv-poptable-icon')
                     :addClass('qud-inv-poptable-icon')
                     :wikitext('?'))
                     :wikitext('?'))
  if objname == '$CALLBLUEPRINTMETHOD:Qud.API.EncountersAPI.GetAnItemBlueprint' then
                    :node(mw.html.create('span')
    favilinkhtml:node(mw.html.create('span')
                    :wikitext(descprefix .. '[[Population:' .. wikipagename .. '|' .. objname .. ']]'))
                    :wikitext('Any random item'))
  else
    favilinkhtml:node(mw.html.create('span')
                    :wikitext(descprefix .. '[[Population:' .. wikipagename .. '|' .. objname .. ']]'))
  end
end
end