more FindMagSmart usage

This commit is contained in:
Fesiug 2023-12-06 02:27:15 -05:00
parent a502cae298
commit e98e1500f0
2 changed files with 4 additions and 15 deletions

View File

@ -501,19 +501,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local b2 = ss( 2 ) local b2 = ss( 2 )
local b3 = ss( 3 ) local b3 = ss( 3 )
local b4 = ss( 4 ) local b4 = ss( 4 )
local maglist = p:INV_FindMag( wep_table.Class, { [wep:D_GetMagID( hand )] = true, [wep:D_GetMagID( !hand )] = true, } ) local maglist = p:INV_FindMagSmart( wep_table.Class, wep:D_GetID( hand ) )
for id, tag in ipairs( maglist ) do
local newmaglist = {}
if wep:D_GetMagID( hand ) != "" then
table.insert( newmaglist, wep:D_GetMagID( hand ) )
end
if false and (wep_table.Class == wep:BTable( !hand ).Class) and wep:D_GetMagID( !hand ) != "" then
table.insert( newmaglist, wep:D_GetMagID( !hand ) )
end
for i, v in ipairs( maglist ) do
table.insert( newmaglist, v )
end
for id, tag in ipairs( newmaglist ) do
--assert( inv[tag], "That magazine doesn't exist. " .. tag ) --assert( inv[tag], "That magazine doesn't exist. " .. tag )
local chunk = ((ss(1)+m_w)*(id-1)) local chunk = ((ss(1)+m_w)*(id-1))
surface.SetDrawColor( scheme["bg"] ) surface.SetDrawColor( scheme["bg"] )
@ -763,7 +752,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
draw.SimpleText( invid, "Benny_10", b_x + bump + ss(6), b_y - ss(2+10), scheme["fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP ) draw.SimpleText( invid, "Benny_10", b_x + bump + ss(6), b_y - ss(2+10), scheme["fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP )
end end
local maginv = p:INV_FindMagSmart( item.Class, nil, id ) local maginv = p:INV_FindMagSmart( item.Class, id )
local magbump = 0 local magbump = 0
for _, mag in ipairs( maginv ) do for _, mag in ipairs( maginv ) do
local mitem = inv[mag] local mitem = inv[mag]

View File

@ -139,7 +139,7 @@ function PT:INV_FindMag( class, exclude )
return results return results
end end
function PT:INV_FindMagSmart( class, exclude, loader ) function PT:INV_FindMagSmart( class, loader )
local inv = self:INV_Get() local inv = self:INV_Get()
local loadm = inv[loader] local loadm = inv[loader]