Author Topic: Colorset Length [Solved]  (Read 1990 times)

Does anyone know how to get how many colors are in the current colorset?
« Last Edit: August 19, 2014, 07:56:05 PM by jes00 »


function getColorsetSize()
{
   for(%i = 0; %i < 64; %i++)
   {
      if(!getColorIDTable(%i))
         break;
   }
   return %i;
}

EDIT: Just tested, but it only works if none of the colors in your colorset start with "0.0000".
« Last Edit: August 19, 2014, 07:55:37 PM by Cruxeis »

Using this:
Code: [Select]
if($PaintCount < 1)
{
$PaintCount = 0;

while(isObject("color" @ %count @ "SprayCanImage"))
{
$PaintCount++;
}
}

Using this:
Code: [Select]
if($PaintCount < 1)
{
$PaintCount = 0;

while(isObject("color" @ %count @ "SprayCanImage"))
{
$PaintCount++;
}
}

Don't set a variable like that, it will break if someone closes and restarts his server with a larger colorset.

Unless this isn't for an add-on that you want to release.

Don't set a variable like that, it will break if someone closes and restarts his server with a larger colorset.

Unless this isn't for an add-on that you want to release.

Not counting how weird a way that is, the only thing wrong is that he's using %count to check objects. This'll actually always result in 0. What do you mean about closing and restarting?

Not counting how weird a way that is, the only thing wrong is that he's using %count to check objects. This'll actually always result in 0. What do you mean about closing and restarting?
Oh, I didn't notice that he wasn't setting %count. Let's assume he did.

You'd start a local server with a colorset with 42 colors. This will figure out: $PaintCount = 42.

Now you close this server and start another local server with a colorset of 43 colors. Since $PaintCount is still 42, it will not check again and never notice the new color.

Oh, you mean in the context of listen servers maintaining scope. Well yeah, that's true. You shouldn't really be saving the count at all as it can change while the server is running.

Not counting how weird a way that is, the only thing wrong is that he's using %count to check objects. This'll actually always result in 0. What do you mean about closing and restarting?
I fixed that in the actual code. Forgot to fix it in my post.
Don't set a variable like that, it will break if someone closes and restarts his server with a larger colorset.
Good point. I guess I should just use a local variable and calculate it each time the function is called then.