Posted 19 December 2013 - 09:28 PM
                Currently I'm working on a program to change the colors of a Glowstone Illuminator to (almost) every color with a nice transition but my program keeps throwing out "glow:30:java.lang.IllegalArgumentExceptions.
When c.setColor is changed to print it outputs a perfect 0x1210ed and continues on perfectly.
                
            When c.setColor is changed to print it outputs a perfect 0x1210ed and continues on perfectly.
r = 16
g = 16
b = 239
c = peripheral.wrap("top")
function num2hex(num)  --Code I found online to convert dec to hex
    local hexstr = '0123456789abcdef'
    local s = ''
    while num > 0 do
        local mod = math.fmod(num, 16)
        s = string.sub(hexstr, mod+1, mod+1) .. s
        num = math.floor(num / 16)
    end
    if s == '' then s = '0'  
elseif s == 0 then s = '00' 
end
    return s
end
repeat
r = r + 1
b = b - 1
rh = num2hex(r)
gh = num2hex(g)
bh = num2hex(B)/>
print("red = "..rh)
print("green = "..gh)
print("blue = "..bh)
conv = string.format("%s%s%s%s", "0x",rh,gh,bh) -- converts all the hex into a single string
c.setColor(conv)
sleep(1)
until r == 239 and b == 16