This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
AndreWalia's profile picture

Color360 [API] [BRAND NEW]

Started by AndreWalia, 30 December 2012 - 10:10 PM
AndreWalia #1
Posted 30 December 2012 - 11:10 PM
So I was wondering, it would be cool if there Owas a colors.random. So i added one. And i plan to add more functions. i present to you COLOR360!!!!!it only has one function for now ._. the functions it adds are
Spoilerrandom color
term.setTextColor(math360.random())
and thats it for now.
pastebin get iMs6yAwL color360

color360 = {}
function color360.random()
  toReturn = 1
  for i = 1,math.random(1,15) do
	toReturn = toReturn * 2
  end
  return toReturn
end
Xtansia #2
Posted 31 December 2012 - 12:12 AM
Just wanted to point something out, with your random colour function you will never get white (1) only orange (2) and up.
Also instead of using a for loop you could do 2 ^ randomNumber.

function randomColour()
   return 2 ^ math.random(0, 15) -- Shortens the for loop to a single line, and allows for the full range of white (1, 2 ^ 0) and up
end
There's nothing wrong with yours just thought I'd give you some (hopefully) helpful tips.
ScruffyRules #3
Posted 31 December 2012 - 12:25 AM
couldn't you do
term.setTextColor(math.random(0,15))
AndreWalia #4
Posted 31 December 2012 - 12:32 AM
couldn't you do
term.setTextColor(math.random(0,15))
no because the color codes go to above 6000 and last time i checked 15 wasn't ANYWHERE near 6000
ScruffyRules #5
Posted 31 December 2012 - 02:43 AM
couldn't you do
term.setTextColor(math.random(0,9999))
Problem solved
no because the color codes go to above 6000 and last time i checked 15 wasn't ANYWHERE near 6000
could you please be less bossy and angry next time, i was just trying to help.
AndreWalia #6
Posted 31 December 2012 - 11:45 AM
couldn't you do
term.setTextColor(math.random(0,9999))
Problem solved
no because the color codes go to above 6000 and last time i checked 15 wasn't ANYWHERE near 6000
could you please be less bossy and angry next time, i was just trying to help.
how was i being bossy? or angry? i just put anywhere in caps because it was a big difference
theoriginalbit #7
Posted 31 December 2012 - 08:46 PM
couldn't you do
term.setTextColor(math.random(0,15))

you could actually do
term.setTextColor( 2 ^ math.random( 0, 15 ) )
since all the colors are actually on a binary scale
Lyqyd #8
Posted 07 March 2013 - 07:20 PM
Locked by request.