ID:147894
 
I've got a paintball course in my game and I have thirteen different colors of paintballs that I want the object to pick randomly everytime a new paintball is created. The icon states in the file are all numbers, from "0" to "12". I tried a few different ways but the following is ultimately what I ended up with:

obj
bullet
icon='paintballs.dmi'
var/I = rand(0,12)
icon_state = I

But this does not seem to work.

Icon Ultima.dm:22:error:= :expected a constant expression
Icon Ultima.dm:23:error:I:invalid variable

Could anyone help me out?
Enigmaster2002 wrote:
obj
bullet
icon='paintballs.dmi'
var/I = rand(0,12)
icon_state = I

But this does not seem to work.

Icon Ultima.dm:22:error:= :expected a constant expression
Icon Ultima.dm:23:error:I:invalid variable

You cannot have actual statements execute outside of a proc/verb. Try putting it in the object's constructor like so:
obj/bullet
New()
..()
icon_state = "[rand(0,12)]"