TTT: Added 2 hooks for custom body search icons #1040

Merged
merged 1 commit into from Aug 16, 2015

Projects

None yet

4 participants

@Shendow
Contributor
Shendow commented Aug 14, 2015

TTTBodySearchEquipment passes search (table containing search data right before processing), eq (integer with equipment bitflags) - use that to define custom fields in the search table.
TTTBodySearchPopulate passes search (PROCESSED table that will be displayed in the body search results), raw (unprocessed table - the one above)

Example:

EQUIP_HELMET = 8

table.insert(EquipmentItems[ROLE_DETECTIVE], {
    id       = EQUIP_HELMET,
    type     = "item_passive",
    material = "vgui/ttt/icon_helmet",
    name     = "Helmet",
    desc     = "Reduces any damage received to the\nhead by 50%."
})

hook.Add("TTTBodySearchEquipment", "body_eq_helmet", function(search, eq)
    search.eq_helmet = util.BitSet(eq, EQUIP_HELMET)
end)

hook.Add("TTTBodySearchPopulate", "body_eq_helmet_icon", function(search, raw)
    if (!raw.eq_helmet) then
        return end

    local highest = 0
    for _, v in pairs (search) do
        highest = math.max(highest, v.p)
    end

    search.eq_helmet = {img = "vgui/ttt/icon_helmet", text = "They had a helmet on.", p = highest + 1}
end)

4vglscl

@Shendow Shendow TTT: Added 2 hooks for custom body search icons
TTTBodySearchEquipment passes search (table containing search data right before processing), eq (integer with equipment bitflags) - use use that to define custom fields in the search table.
TTTBodySearchPopulate passes search (PROCESSED table that will be displayed in the body search results), raw (unprocessed table - the one above)
afcf909
@robotboy655 robotboy655 added the TTT label Aug 14, 2015
@robotboy655
Collaborator

👍 I needed this when adding Nyan Gun support for TTT.

@Exho1
Contributor
Exho1 commented Aug 16, 2015

Oh perfect, I was wondering how to do this the other day with my passive items.

@svdm svdm merged commit 31efb14 into garrynewman:master Aug 16, 2015
@Shendow Shendow deleted the unknown repository branch Aug 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment