I need something to where someone would come up, press a button, and have one of the 16 colors to be displayed. I have played around with RedNet cable from MFR and the lamps from Project Red. I just need a way to randomize this.
Random rs.BundledOutput
Started by mrhat, Apr 28 2014 01:26 PM
3 replies to this topic
#1
Posted 28 April 2014 - 01:26 PM
#2
Posted 28 April 2014 - 02:36 PM
That should be pretty simple. Store all the color values in a numerically indexed table, then use math.random to pick a random index based on the size of the table.
local colors = {}
for k,v in pairs(color) do
if type(v) == "number" then
colors[#colors+1] = v
end
end
randomColor = colors[math.random(1,#colors)]
#3
Posted 28 April 2014 - 02:49 PM
colors is the name of the actual API and stores more than just the color values. The better solution relies on what the color values actually are to generate a single random color:
function randomColor() return 2 ^ math.random(0, 15) end
#4
Posted 28 April 2014 - 03:06 PM
Ah right my bad, i forgot wether it was color or colors
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











