TTT-2 / TTT2

Trouble in Terrorist Town 2 for Garry's Mod (gmod)
https://steamcommunity.com/sharedfiles/filedetails/?id=1357204556
178 stars 74 forks source link

HUD elements not rendering when contained in different addons #490

Closed Blast1113 closed 4 years ago

Blast1113 commented 4 years ago

TTT2 v0.6.3b

When using my custom HUD, Elements from other addons do not draw unless I use self:ForceElement(element name) in cl_init.lua. The other addon.

It does run the PreInitialize, Initialize, and GetDefaults functions, but never runs the Draw function.

This may not be a bug and could just be a mistake I made, but I can't find anything different about my HUD than the default ones, including the element defined in the original vampire HUD.

TimGoll commented 4 years ago

Your PreInit has to look like this:

function HUDELEMENT:PreInitialize()
    BaseClass.PreInitialize(self)

    local hud = huds.GetStored("octagonal")
    if hud then
        hud:ForceElement(self.id)
    end

    -- set as NOT fallback default
    self.disabledUnlessForced = true
end
TimGoll commented 4 years ago

BUt looking at your addon... why did you add so may convars for the size? You have seen our HUD editor?

Blast1113 commented 4 years ago

I probably should use the HUD editor (I might do that later). It currently doesn't because a lot of the code is directly copied from my older HUD.

That PreInit code worked perfectly! Thank you very much.

TimGoll commented 4 years ago

take a look at our documentation: https://docs.ttt2.neoxult.de/developers/content-creation/creating-a-hud-theme/ (still WIP) If you derive from the scaleable HUD all things needed for the dynamic scaling are already done

TimGoll commented 4 years ago

Another FYI: I don't know what you're doing with your addon, but it breaks all my HUDs

Blast1113 commented 4 years ago

It may need some other roles installed, but it seems to work fine for me with just the jester. asdfasdfasdfasdfasdf

TimGoll commented 4 years ago

Another question: You know about this addon, don't you?

https://steamcommunity.com/sharedfiles/filedetails/?id=1795267605

Blast1113 commented 4 years ago

I know mine looks very similar to that one (and was originally based off it) but there are a lot of things I don't like about it.

Blast1113 commented 4 years ago

Plus, there were some extra features I wanted.