Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Aug 16, 2015
Merged

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

merged 1 commit into from Aug 16, 2015

Conversation

dearmochi
Copy link
Contributor

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

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)
@robotboy655 robotboy655 added the TTT The pull request is for TTT and will be handled by svdm. label Aug 14, 2015
@robotboy655
Copy link
Collaborator

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

@Exho1
Copy link
Contributor

Exho1 commented Aug 16, 2015

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

svdm added a commit that referenced this pull request Aug 16, 2015
TTT: Added 2 hooks for custom body search icons
@svdm svdm merged commit 31efb14 into Facepunch:master Aug 16, 2015
@dearmochi dearmochi deleted the ttt-bodysearch-hooks branch August 17, 2015 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TTT The pull request is for TTT and will be handled by svdm.
Projects
None yet
4 participants