kiopho Posted December 24, 2015 Share Posted December 24, 2015 (edited) -- SOLVED -- Hi guys, I hope you're having a good time ! I need some help to remove woodie's badge when he turns into a beaver. The function I need to modify is in woodie.lua. The line I need to add is line 33. Any help is appreciated and have a good holiday ! local function SetHUDState(inst) if inst.HUD then if inst.components.beaverness:IsBeaver() and not inst.HUD.controls.beaverbadge then inst.HUD.controls.beaverbadge = GetPlayer().HUD.controls.sidepanel:AddChild(BeaverBadge(inst)) inst.HUD.controls.beaverbadge:SetPosition(0,-100,0) inst.HUD.controls.beaverbadge:SetPercent(1) inst.HUD.controls.beaverbadge.inst:ListenForEvent("beavernessdelta", function(_, data) inst.HUD.controls.beaverbadge:SetPercent(inst.components.beaverness:GetPercent(), inst.components.beaverness.max) if not data.overtime then if data.newpercent > data.oldpercent then inst.HUD.controls.beaverbadge:PulseGreen() TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/health_up") elseif data.newpercent < data.oldpercent then TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/health_down") inst.HUD.controls.beaverbadge:PulseRed() end end end, inst) inst.HUD.controls.crafttabs:Hide() inst.HUD.controls.inv:Hide() inst.HUD.controls.status:Hide() inst.HUD.controls.mapcontrols.minimapBtn:Hide() inst.HUD.beaverOL = inst.HUD.under_root:AddChild(Image("images/woodie.xml", "beaver_vision_OL.tex")) inst.HUD.beaverOL:SetVRegPoint(ANCHOR_MIDDLE) inst.HUD.beaverOL:SetHRegPoint(ANCHOR_MIDDLE) inst.HUD.beaverOL:SetVAnchor(ANCHOR_MIDDLE) inst.HUD.beaverOL:SetHAnchor(ANCHOR_MIDDLE) inst.HUD.beaverOL:SetScaleMode(SCALEMODE_FILLSCREEN) inst.HUD.beaverOL:SetClickable(false) inst.HUD.controls.beaverbadge:Hide() elseif not inst.components.beaverness:IsBeaver() and inst.HUD.controls.beaverbadge then if inst.HUD.controls.beaverbadge then inst.HUD.controls.beaverbadge:Kill() inst.HUD.controls.beaverbadge = nil end if inst.HUD.beaverOL then inst.HUD.beaverOL:Kill() inst.HUD.beaverOL = nil end inst.HUD.controls.crafttabs:Show() inst.HUD.controls.inv:Show() inst.HUD.controls.status:Show() inst.HUD.controls.mapcontrols.minimapBtn:Show() end endend Edited December 25, 2015 by kiopho Link to comment https://forums.kleientertainment.com/forums/topic/61334-removing-woodie-beaver-badge/ Share on other sites More sharing options...
Mobbstar Posted December 24, 2015 Share Posted December 24, 2015 If it were a component function (or any function referenced through a table value), you could "extend" it by copying it, overwriting it and calling the old one in the new one, alongside your code.local sethudfn = SetHUDStateSetHUDState = function(...)sethudfn(...)--your code hereend Of course, this is not working with "local" variables. You would have to override the file, or overwrite the functions calling this function. Link to comment https://forums.kleientertainment.com/forums/topic/61334-removing-woodie-beaver-badge/#findComment-701701 Share on other sites More sharing options...
Rincevvind Posted December 24, 2015 Share Posted December 24, 2015 (edited) like any other badge or interface elemnt in this game you can simple disable it and hide.but there some events in HUD.controls, so you have also override Show/Hide function like i did in StatusPlus mod. local function TweakBadge(inst) inst.OldHide = inst.Hide or function() end inst.OldDeactivate = inst.Deactivate or function() end inst.OldScaleTo = inst.ScaleTo or function() end function inst:Hide() end function inst:Deactivate() end function inst:DoHide() if self.OldHide then self:OldHide() end end function inst:DoDeactivate() if self.OldDeactivate then self:OldDeactivate() end end function inst:OnLoseFocus() end function inst:OnGainFocus() end function inst:ShowWidget(enable) if enable then self:Enable() self:Show() else self:DoHide() self:Disable() end endend local function TweakBeaverBadge(inst) inst.initstarted = true TweakBadge(inst) local p = GetPlayer() inst.dmin = 0 inst.dmax = 0.8 if p.components.beaverness then inst.vmax = p.components.beaverness.max end function inst:DrawBeaver(val,data) inst:DrawTempValue(val) inst:SetAnimValue(val) if data then if not data.overtime then if data.newpercent > data.oldpercent then inst:PulseGreen() TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/health_up") elseif data.newpercent < data.oldpercent then TheFrontEnd:GetSound():PlaySound("dontstarve/HUD/health_down") inst:PulseRed() end end end end inst:DrawBeaver(0) inst.initfinished = trueend local function BeavernessStatus(Health,inst) inst:ListenForEvent("beavernessdelta", function(inst, data) local p = GetPlayer() if (p.prefab~="woodie") then return end if p and p.HUD and p.HUD.controls and p.HUD.controls.status and p.HUD.controls.status.beaver and p.HUD.controls.status.beaver.initfinished then p.HUD.controls.status.beaver:DrawBeaver(p.components.beaverness.current,data) end if p and p.HUD and p.HUD.controls and p.HUD.controls.beaverbadge and p.HUD.controls.beaverbadge:IsEnabled() then p.HUD.controls.beaverbadge:Disable() p.HUD.controls.beaverbadge:Hide() p.HUD.controls.status:Show() end end )end AddComponentPostInit("beaverness",BeavernessStatus)that's part of code that i am using, but you probably can simply do something like this:local function TweakBadge(inst) inst.OldHide = inst.Hide or function() end inst.OldDeactivate = inst.Deactivate or function() end function inst:Hide() end function inst:Deactivate() end function inst:DoHide() if self.OldHide then self:OldHide() end end function inst:DoDeactivate() if self.OldDeactivate then self:OldDeactivate() end end function inst:OnLoseFocus() end function inst:OnGainFocus() end inst.Disable() inst.DoHide() endAddClassPostConstruct("widgets/beaverbadge", TweakBadge)but needs test, i am done this year ago and don't remember all troubles that i had.Maybe also require to handle Show() and Enable() methods, just put empty functions. Edited December 24, 2015 by Rincevvind Link to comment https://forums.kleientertainment.com/forums/topic/61334-removing-woodie-beaver-badge/#findComment-701753 Share on other sites More sharing options...
kiopho Posted December 25, 2015 Author Share Posted December 25, 2015 @Mobbstar @Rincevvind Thanks for the help guys. I actually want to get rid of the badge to use my own one. I'm finally gonna use a DoPeriodicTask command to check for the existence of the badge and hide it when it's created. I think that's the easier way around this mess.Again, thanks a lot, and have a good one.Cheers ! Link to comment https://forums.kleientertainment.com/forums/topic/61334-removing-woodie-beaver-badge/#findComment-701865 Share on other sites More sharing options...
Blueberrys Posted December 25, 2015 Share Posted December 25, 2015 @kiophomakebeaver_old = inst.components.beaverness.makebeaverinst.components.beaverness.makebeaver = function(inst) r = makebeaver_old(inst) -- you can put an if statement here just in case inst.HUD.controls.beaverbadge:Hide() return rend Link to comment https://forums.kleientertainment.com/forums/topic/61334-removing-woodie-beaver-badge/#findComment-702005 Share on other sites More sharing options...
kiopho Posted December 25, 2015 Author Share Posted December 25, 2015 @Blueberrys Thanks for your help pal, but that's one of the first things I tried. The creation of the beaver badge is somehow delayed and I'm not sure why. The badge doesn't exist when the function checks. That's why I'm sticking to a DoPeriodicTask function instead.Cheers ! Link to comment https://forums.kleientertainment.com/forums/topic/61334-removing-woodie-beaver-badge/#findComment-702046 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now