Author Topic: What function is called when switching paint can to another color?  (Read 1049 times)

I need to set the paint can's color manually, but trace(); isn't helping much with this one...

serverCmdUseSprayCan is what you should look into. Not sure if this is exactly what you are going for, but for getting a person's current paint color, it's %client.currentColor.

EDIT:
This might help as something to look at.

for(%i=0;%i<PaintRowGroup.getCount();%i++) {
      %obj=PaintRowGroup.getObject(%i);
      if(%obj.getName()$="PaintRow")
         %row+=%obj.numSwatches;
   }
   %row-=9;
   for(%i=0;%i<%row;%i++) {
      %temp=getColorIDTable(%i);
      %a=(255-getWord(%temp,0))+(255-getWord(%temp,1))+(255-getWord(%temp,1))-(0-getWord(%temp,3));
      if(%trans$=""||%a<%transT) {
         %trans=%i;
         %transT=%a;
      }
   }
   for(%i=5;%i<HUD_PaintBox.getCount()-10;%i++) {
      %obj=HUD_PaintBox.getObject(%i);
      if(%obj.getPosition()$=getWords(vectorAdd(HUD_PaintActive.getPosition(),"1 1"),0,1)) {
         %solid=%i-5;
         break;
      }
   }
   for(%i=%len;%i>0;%i--) {
      for(%j=%y;%j>0;%j--) {
         if(%col[%len-%i+1,%j])
            %new=%solid;
         else
            %new=%trans;
         $BuildChar::Tick[$BuildChar::Count++]=schedule(%time+=(!$IamAdmin)*150,0,commandToServer,'useSprayCan',%new);
         $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'plantBrick');
         $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'superShiftBrick',0,0,1);
      }
      $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'superShiftBrick',0,-1,-%y);
   }
   $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'superShiftBrick',0,-1,0);
   $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'useSprayCan',%solid);
« Last Edit: July 25, 2014, 08:55:00 PM by Cruxeis »

serverCmdUseSprayCan is what you should look into. Not sure if this is exactly what you are going for, but for getting a person's current paint color, it's %client.currentColor.

EDIT:
This might help as something to look at.

for(%i=0;%i<PaintRowGroup.getCount();%i++) {
      %obj=PaintRowGroup.getObject(%i);
      if(%obj.getName()$="PaintRow")
         %row+=%obj.numSwatches;
   }
   %row-=9;
   for(%i=0;%i<%row;%i++) {
      %temp=getColorIDTable(%i);
      %a=(255-getWord(%temp,0))+(255-getWord(%temp,1))+(255-getWord(%temp,1))-(0-getWord(%temp,3));
      if(%trans$=""||%a<%transT) {
         %trans=%i;
         %transT=%a;
      }
   }
   for(%i=5;%i<HUD_PaintBox.getCount()-10;%i++) {
      %obj=HUD_PaintBox.getObject(%i);
      if(%obj.getPosition()$=getWords(vectorAdd(HUD_PaintActive.getPosition(),"1 1"),0,1)) {
         %solid=%i-5;
         break;
      }
   }
   for(%i=%len;%i>0;%i--) {
      for(%j=%y;%j>0;%j--) {
         if(%col[%len-%i+1,%j])
            %new=%solid;
         else
            %new=%trans;
         $BuildChar::Tick[$BuildChar::Count++]=schedule(%time+=(!$IamAdmin)*150,0,commandToServer,'useSprayCan',%new);
         $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'plantBrick');
         $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'superShiftBrick',0,0,1);
      }
      $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'superShiftBrick',0,-1,-%y);
   }
   $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'superShiftBrick',0,-1,0);
   $BuildChar::Tick[$BuildChar::Count++]=schedule(%time,0,commandToServer,'useSprayCan',%solid);
Any chance you could tell me what this chunk of code accomplishes? I'm not very good at looking at other's code any figuring out it's functionality.

You can use:
shiftPaintColumn(%dir) where %dir is the number of columns to shift by, can be positive or negative
scrollPaint(%dir) where %dir is the number of vertical colors to shift by, can be positive or negative
You can get the current paint color with $currSprayCanIndex

Actually, it depends on if you want this to be client sided or server sided. I believe that ZSNO's way is for client, try using what I told you for server.

I'm assuming that serverCmduseSprayCan's one argument is an RGBa value?

I'm assuming that serverCmduseSprayCan's one argument is an RGBa value?
No. It's the paint can color in the color set, starting at 0.

You peeps really need to say if you want client or server side code...

No. It's the paint can color in the color set, starting at 0.
Huh. When I use useSprayCan(#); manually in the console, regardless of the number I put in, it always simply shifted the the selection to the right.

Huh. When I use useSprayCan(#); manually in the console, regardless of the number I put in, it always simply shifted the the selection to the right.
That's because they're two different functions...

That's because they're two different functions...
Omg I feel like an idiot now... I even knew that they weren't the same. :/ Ok, now that that's taken care of, I should have what I need, thanks.