Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
4

Getting a Table of BrickColors? [closed]

Asked by 9 years ago

I have a command line of code:

data = {}
for i = 1, 64 do
    table.insert(data, i, tostring(BrickColor.new(i)))
    print(BrickColor.new(pos + 1))
end 
print('local table = {"'..table.concat(data, '", "')..'"}')

It runs without error. But. What it gives me is really odd. >

local table= {"White", "Grey", "Light yellow", "Medium stone grey", "Brick yellow", "Light green (Mint)", "Medium stone grey", "Medium stone grey", "Light reddish violet", "Medium stone grey", "Pastel Blue", "Light orange brown", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Nougat", "Medium stone grey", "Medium stone grey", "Bright red", "Med. reddish violet", "Bright blue", "Bright yellow", "Earth orange", "Black", "Dark grey", "Dark green", "Medium green", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Lig. Yellowich orange", "Bright green", "Dark orange", "Light bluish violet", "Transparent", "Tr. Red", "Tr. Lg blue", "Tr. Blue", "Tr. Yellow", "Light blue", "Medium stone grey", "Tr. Flu. Reddish orange", "Tr. Green", "Tr. Flu. Green", "Phosph. White", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey", "Medium stone grey"}

I have no idea why it returns "Medium stone grey" so often. I have testing just changing the brickcolor to BrickColor.new(i) and it still repeats medium stone grey. There is also colors I don't remeber like "Transparent" (Bright white when I tested) and "Tr. Red" and such. Please help me understand why this is happening?

2
print(#data) > 64 YellowoTide 1992 — 9y

Locked by YellowoTide, EzraNehemiah_TF2, Lacryma, and Redbullusa

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
6
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

ROBLOX BrickColors are a bundle of hacks, and so they have odd behaviors.


The reason you're getting Medium stone grey so much is that it's the "default" color.

print(BrickColor.new(-1))
--> Medium stone grey

If you give BrickColor.new something that isn't a valid brick color code, it will give you "Medium stone grey".

There are "gaps" in the sequence of BrickColors (e.g., 8 isn't assign to any color), and all of those gaps will correspond to "Medium stone grey".


ROBLOX also has several deprecated colors, like "Transparent". I'm guessing this was going to make transparent bricks before the Transparency property was realized very early on, but they are pointless (to that end, anyway) now.


I think the full table goes up to 1032 now. If you want to avoid duplicates, you could do this:

local inserted = {};
local text = {};
for i = 1, 1032 do
    local s = tostring( BrickColor.new(i))
    if not inserted[s] then
        inserted[s] = true
        table.insert(text, "[" .. i .. "] = \"" .. s .. "\"")
    end
end

print("colors = {" .. table.concat(text, ",\n") .. "\n};")

-- output: http://hastebin.com/devejirubu.lua

EDIT: Apparently it goes up to 1032 (not 1024) (and there aren't any above that, at least until 10000).

2
So its not in order, odd xD. Thanks though it helped :) YellowoTide 1992 — 9y
Ad