manve1 Posted January 5, 2013 Author Share Posted January 5, 2013 FancyProgress = {} FancyProgress.__index = FancyProgress function FancyProgress.create(minval, maxval, bgName, x, y, width, height, barName, barOffsetX, barOffsetY, barWidth, barHeight) local screenWidth, screenHeight = guiGetScreenSize() if screenWidth < 1280 and screenHeight < 1024 then x = resAdjust(x) y = resAdjust(y) width = resAdjust(width) height = resAdjust(height) barOffsetX = resAdjust(barOffsetX) barOffsetY = resAdjust(barOffsetY) barWidth = resAdjust(barWidth) barHeight = resAdjust(barHeight) end if x < 0 then x = screenWidth - width + x end if y < 0 then y = screenHeight - height + y end return setmetatable( { background = guiCreateStaticImage(x, y, width, height, bgName, false, nil), bar = guiCreateStaticImage(x + barOffsetX, y + barOffsetY, barWidth, barHeight, barName, false, nil), width = barWidth, height = barHeight, min = minval, max = maxval, range = maxval - minval, progress = maxval }, FancyProgress ) end function FancyProgress:setProgress(progress) if not progress then progress = 0 end if progress < self.min then progress = self.min elseif progress > self.max then progress = self.max end if progress ~= self.progress then guiSetSize(self.bar, math.floor((progress-self.min)*self.width/self.range), self.height, false) self.progress = progress end end function FancyProgress:show() guiSetVisible(self.background, true) guiSetVisible(self.bar, true) end function FancyProgress:hide() guiSetVisible(self.background, false) guiSetVisible(self.bar, false) end function FancyProgress:destroy() destroyElement(self.background) self.background = nil destroyElement(self.bar) self.bar = nil end p_HealthBar = FancyProgress.create( 0, 100, "hud.health.png", -1268.25, 736.35, 2, 60, "hud/p.png", 0.9, 8, 0.1, 15.4 ) function getTeamHealth(team) if team then HP = 0 for i, player in ipairs(getPlayersInTeam(team)) do HP = HP + getElementHealth(player) end return HP end end setTimer( getTeamHealth, 100, 0 ) setTimer( function( ) p_HealthBar:setProgress( getTeamHealth ) end, 100, 0 ) ERROR: line.39 @ attempt to compare function with a number Mind helping me out with this? Link to comment
Anderl Posted January 5, 2013 Share Posted January 5, 2013 You passed the function "getTeamHealth" as an argument in "setProgress" method, you should call the function to return the team's health instead. Link to comment
Anderl Posted January 5, 2013 Share Posted January 5, 2013 Just call the function instead? ( args ) getTeamHealth( teamElement ); Function call tutorial here Link to comment
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