Jump to content

.


DarkByte

Recommended Posts

Posted (edited)

Why just don't you use the cases.

if var <= 25 then 
 color = {0, 125, 0} 
elseif var <= 50 and var > 25 then  
 color = {0, 150, 0}  
elseif var <= 75 and var > 50 then 
 color = {0, 175, 0} 
end 

Edited by Guest
Posted

I want to make over 5 different values negative and positive colors, i have to write a lot of these...I know there is a simple way but i can't figure it out.

Posted

Ok so whats wrong with your code?

When the points are 0, the color is white &when the points are 75 the color is fully green.

You just need to change tocolor(0,calc,0,255)

Right? Or what?

Posted

This is what you're looking for:

local maxPoints = 75 
  
function onCmd(cmd, myPoints) 
    local color = (255 / maxPoints) * myPoints 
    local r,g,b = 255-color, 255, 255-color 
     
    outputChatBox("You have "..myPoints.." points.", r, g, b) 
end 
addCommandHandler("setPoints", onCmd, false) 
  

It goes from white to green. You can easily modify it and take the math to use it in your code.

I suppose it'll get a little more difficult if you want to go from say, purple to orange, but this is all I can do for you.

Why just don't you use the cases.

Because math.

Posted
Ok so whats wrong with your code?

When the points are 0, the color is white &when the points are 75 the color is fully green.

You just need to change tocolor(0,calc,0,255)

Right? Or what?

Nope it's not what i want when it's 0 it's green and when it's 75 it's white.

Posted
Ok so whats wrong with your code?

When the points are 0, the color is white &when the points are 75 the color is fully green.

You just need to change tocolor(0,calc,0,255)

Right? Or what?

Nope it's not what i want when it's 0 it's green and when it's 75 it's white.

@Tails - Thanks it's working now. :D

Posted

You're welcome. But like I said, it gets a bit more difficult with other colors than red, green and blue. It may involve different kind of maths if you want to keep everything short and simple. I can't really help you with it, because I know very little about maths. Hopefully you'll figure it out or someone is able to help you. Good luck. :)

Posted

Admin - Purple - R,G,B - 183,0,255

Admin - White - R,G,B - 255,255,255

So at start, G should be 255 as well as R; to be white.

MaxPoints are 375;

The G should be 0 by the end and the R should be 183.

colorG = (255/maxPoints) * reputation

colorR = ((255 - 183) / maxPoints ) * reputation

tocolor(255 - colorR, 255 - colorG,255)

That would probably work.

It will start with white and end up with purple.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...