print current object color

I have set color of object using hex converter how do i retrieve current color being used on the object.

function randomcolor() local colors = { "#e67e22","#e74c3c" ,"#f1c40f","#1abc9c","#8e44ad" } local finalcolor = colors[math.random(1, 5)] return finalcolor end local ragdogLib = require "ragdogLib";

local function addnewobject()        local bombstartnew = display.newRect( startingpoint, -340, 50, 50) bombstartnew:setFillColor(ragdogLib.convertHexToRGB(randomcolor())); end

Hey cm2001m,

why not save the created color in a variable before using it?

local color1, color2, color3 = ragdogLib.convertHexToRGB(randomcolor()) bombstartnew:setFillColor(color1, color2, color3); print(color1, color2, color3)

Like this you are able to access the randomly choosen colors.

Or do you want to retrieve the color values outside of the creation functions?

If that’s the case, you should store the values as a property of the object you used them for.

local color1, color2, color3 = ragdogLib.convertHexToRGB(randomcolor()) bombstartnew:setFillColor(color1, color2, color3); bombstartnew.fillColor = {color1, color2, color3} print(unpack(bombstartnew.fillColor))

Hope that helps :slight_smile:

Hey cm2001m,

why not save the created color in a variable before using it?

local color1, color2, color3 = ragdogLib.convertHexToRGB(randomcolor()) bombstartnew:setFillColor(color1, color2, color3); print(color1, color2, color3)

Like this you are able to access the randomly choosen colors.

Or do you want to retrieve the color values outside of the creation functions?

If that’s the case, you should store the values as a property of the object you used them for.

local color1, color2, color3 = ragdogLib.convertHexToRGB(randomcolor()) bombstartnew:setFillColor(color1, color2, color3); bombstartnew.fillColor = {color1, color2, color3} print(unpack(bombstartnew.fillColor))

Hope that helps :slight_smile: