Module:Inventory: Difference between revisions

64 bytes added ,  21:06, 19 January 2023
try to fix food not working
(fix characters that don't work as wiki page names)
(try to fix food not working)
Line 22: Line 22:
if frame.args[1] ~= nil and frame.args[1] ~= '' then
if frame.args[1] ~= nil and frame.args[1] ~= '' then
   objname = mw.text.trim(frame.args[1])
   objname = mw.text.trim(frame.args[1])
  --return name
else
else
   error "There is no argument specified! [[Category:pages with inventory errors]]"
   error "There is no argument specified! [[Category:pages with inventory errors]]"
Line 30: Line 29:
if ispop ~= 'yes' then
if ispop ~= 'yes' then
   --[logic for basic objects]--
   --[logic for basic objects]--
  --[Define favilink...]--
  favilinked = frame:expandTemplate{title='Favilink id', args={objname,'displayname-tooltip-override'}}
  favilinkhtml = mw.html.create('div')
              :addClass('qud-inv-favilink-wrapper')
              :wikitext(favilinked)
  --[If it can be found in the items or missle weapon table, define weapon html]--
   local result = cargo.query('ItemsTable=IT,GeneralData=GD,MissileWeaponData=MWD',
   local result = cargo.query('ItemsTable=IT,GeneralData=GD,MissileWeaponData=MWD',
   'PlainName,Vibro,MaxPV,BasePV,Damage,PenetratingAmmo,GD.JoinKey=Page',
   'PlainName,Vibro,MaxPV,BasePV,Damage,PenetratingAmmo,GD.JoinKey=Page',
Line 37: Line 44:
   join='GD.JoinKey=IT.JoinKey,GD.JoinKey=MWD.JoinKey'} )
   join='GD.JoinKey=IT.JoinKey,GD.JoinKey=MWD.JoinKey'} )


   if not next(result) then
   --[Exit if not found, it's an item that doesn't have combat data and only needs favilink and quantity]
    return '[[' .. objname.. ']][[Category:pages with inventory errors]]'
   if next(result) ~= nil then
   else
    name = result[1]['PlainName']
  end
 
  favilinked = frame:expandTemplate{title='Favilink id', args={objname,'displayname-tooltip-override'}}
 
   --[If damage, return weapon html that specifies damage, PV and max PV]--
   --[If damage, return weapon html that specifies damage, PV and max PV]--


Line 78: Line 79:
   end
   end


  --[Define html...]--
 
  favilinkhtml = mw.html.create('div')
              :addClass('qud-inv-favilink-wrapper')
              :wikitext(favilinked)
   if weaponhtml ~= nil then
   if weaponhtml ~= nil then
     favilinkhtml:node(weaponhtml)
     favilinkhtml:node(weaponhtml)
   end
   end
 
  end
else
else
   --[logic for population tables]--
   --[logic for population tables]--