Defranco Posted December 29, 2015 Share Posted December 29, 2015 Hey, I've been trying to adapt as much scripts as possible to work with the 4.0 version, and I've come across some issues with the Health Bar script, The color function doesn't work. The bars stay black. Script.offset = Vec2(0,0) --Vec2 "Offset" Script.size = Vec2(160, 25) --Vec2 "Size" Script.backgroundColor = Vec4() --color "Background color" Script.healthbarColor = Vec4() --color "HealthBar color" Script.overlayPath = "" -- path "Overlay" "Tex file (*tex):tex" Script.overlay = nil Script.player = nil Script.backgroundColorFractioned = nil Script.healthbarColorFractioned = nil function Script:Start() self.player = self.entity:GetParent() if self.overlayPath ~= "" then self.overlay = Texture:Load(self.overlayPath) end --background local c = self.backgroundColor self.backgroundColorFractioned = Vec4(c.x/255, c.y/255, c.z/255, c.w/255) c = self.healthbarColor self.healthbarColorFractioned = Vec4(c.x/255, c.y/255, c.z/255, c.w/255) end function Script:PostRender(context) -- Background context:SetColor(self.backgroundColorFractioned) context:DrawRect(self.offset.x, context:GetHeight() - self.offset.y, self.size.x, self.size.y) -- Healthbar context:SetColor(self.healthbarColorFractioned) local healthFactor = self.player.script.health / self.player.script.maxHealth context:DrawRect(self.offset.x,context:GetHeight() - self.offset.y, self.size.x * healthFactor, self.size.y) --Draw overlay if self.overlay ~= nil then context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1,1) context:DrawImage(self.overlay, 0, context:GetHeight() - self.overlay:GetHeight()) context:SetBlendMode(Blend.Solid) end end Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 29, 2015 Share Posted December 29, 2015 Hi Erika, Leadwerks changed the API quite a while ago for the color settings. Colors no longer have to be divided by 255 in order for them to be processed correctly by Leadwerks. so this: self.backgroundColorFractioned = Vec4(c.x/255, c.y/255, c.z/255, c.w/255) becomes: self.backgroundColorFractioned = Vec4(c.x, c.y, c.z, c.w) 3 Quote Link to comment Share on other sites More sharing options...
Defranco Posted December 29, 2015 Author Share Posted December 29, 2015 Worked excellent, thank you, highly respect the video tutorials you've done on youtube, I hope to see many more! I'm just getting back into it, its been over a year since 3.1 / 3.2 was out that I last made anything. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 29, 2015 Share Posted December 29, 2015 No problem. I have been absent from Leadwerks for a while as well, so things like this are good to catch up to. 1 Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted December 30, 2015 Share Posted December 30, 2015 Welcome back Aggror. There is a same problem with FlowGui the text colours are all back now. Any chance of an update Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 30, 2015 Share Posted December 30, 2015 Welcome back Aggror. There is a same problem with FlowGui the text colours are all back now. Any chance of an update yes, i have an update for that. I want include some other fixes and features as well. When le 4.0 is out of beta I will release it. 3 Quote Link to comment Share on other sites More sharing options...
Roland Posted December 30, 2015 Share Posted December 30, 2015 Aggror ... WELCOME back It seems like every time any of us leaves for doing something else we come back as drug addicts. The Leadwerks Engine perhaps should be classified as a drug Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.