Advertisement
pyroan

Computronics Color Converter

Apr 26th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. -- Converts a _good_ rgb format into
  2. -- 15-bit color for computronics lamps.
  3. -- specifically takes values 0.0-1.0 for red, green, blue
  4. -- this isn't specific to the minecraft mod it's written for
  5. -- but it's what annoyed me into doing this
  6. function rgb2x (r, g, b)
  7.   local rx = math.floor(31*r)
  8.   local gx = math.floor(31*g)
  9.   local bx = math.floor(31*b)
  10.   return bit32.lshift(rx,10) + bit32.lshift(gx,5) + bx
  11. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement