Setting object colour via a tuple string property via python

Like the title says, I want my object (which is a simple animated flower texture mapped to a plane) to burn or freeze. Ive done most of it, but when it comes to setting the colour via property in Python, it says I have too many arguments, should be 4. I want to set the colour so it updates with a string property that uses this [2,1,1,1] tuple as an example.

In this case, only the numbers should count. But it treats it as a whole, and therefore you get the too many arguments, should be 4 error.

probably due to it sees it as a string command and not as a list, you can simply do the following and see if that works.(if it doesnt just store the collors in the property so 2111)

color_to_use = list(own['property_name']) 

if that doesn’t work you need to convert it manually

the_colors = own['property_name']
obj.color = [the_colors[0], the_colors[1], the_colors[2], the_colors[3]]

The eval keyword would be the simplest, quickest and easiest method in this case.

Eval is evil.

Use ast.literal_eval

1 Like

*Eval is evil " :joy:lol

its a very serious security concern**

https://stackoverflow.com/questions/1832940/why-is-using-eval-a-bad-practice

1 Like

Ohhh. So you are serious. I thought it was a joke.

1 Like

You should never use eval() in Python code. It is essentially the same as letting people submit JavaScript in HTML forms- also very bad, fortunately all HTML forms have script filtering now. Anything that lets arbitrary code be executed is a very bad thing