Author Topic: [resource] setSkinName example  (Read 1756 times)

CheesyPeesy is working on some lightsabers and wanted to be able to change the textures via code.  I gave him this example showing the LCD colon from the kitchen and bedroom maps and how it changes colors using the same model.

https://leopard.hosting/download.php?f=neibj
Use /setlcdcolor [base or blue or green] to change the color.

This is just a quick example, and might not work right if you restart your server without closing your client.
(it doesn't put the LCD object into missioncleanup :p)

I'm pretty sure the problem with changing the color of weapons is that all the useful methods on a static shape are unavailable for images mounted to a player.

Looking closer, yeah this isn't helpful for weapons at all.

for a melee weapon i'd use an aiplayer and mount that to the hand. it's recolorable through setNodeColor and since melee weapons mostly fire from eye node you can just fire a raycast from the eye node. states could be replaced with schedules and playthreads

Didn't v0002/RTB 1.x have skinName functionality for weaponImages? Or was that removed in the retail release of Blockland?

After some digging around I found out how to use ColorShiftColor you need to have a blank material set to the mesh you want colored. Now I don't have to create like 5 different weapons just for different varieties of colors.

colorshifting requires transmitdatablocks and/or server restart in order to work

Didn't v0002/RTB 1.x have skinName functionality for weaponImages? Or was that removed in the retail release of Blockland?
It was part of the .mountImage command.
.mountImage(image,slot[,skin])

Might still be there, might not be.

colorshifting requires transmitdatablocks and/or server restart in order to work
Quote
datablock ShapeBaseImageData(GreenImage)
{
   shapeFile = "./blade.dts";
   emap = true;

   mountPoint = 0;
   offset = "0 0 -0.43751";
   eyeOffset = "0 0 0";

   doColorShift = true;
   colorShiftColor = "0 1 0 1";


    hasLight = true;
   lightType = "ConstantLight";
   lightRadius = 50;
   lightColor  = "0 1 0 1";

   correctMuzzleVector = false;
};

datablock ShapeBaseImageData(BlueImage)
{
   shapeFile = "./blade.dts";
   emap = true;

   mountPoint = 0;
   offset = "0 0 -0.43751";
   eyeOffset = "0 0 0";

   doColorShift = true;
   colorShiftColor = "0 0 1 1";

   hasLight = true;
   lightType = "ConstantLight";
   lightRadius = 50;
   lightColor  = "0 0 1 1";
   correctMuzzleVector = false;
};

datablock ShapeBaseImageData(RedImage)
{
   shapeFile = "./blade.dts";
   emap = true;
   mountPoint = 0;
   offset = "0 0 -0.43751";
   eyeOffset = "0 0 0";

   doColorShift = true;
   colorShiftColor = "1 0 0 1";

    hasLight = true;
   lightType = "ConstantLight";
   lightRadius = 50;
   lightColor  = "1 0 0 1.00";

function normaljedistyle1Image::onMount(%this, %obj, %slot)
{
    parent::onMount(%this, %obj, %slot);
   if (%obj.meleeStance)
      %obj.playthread(2, "2hswing" @ (%obj.swingPhase + 1) % 2 + 1);
   else
      %obj.playthread(2, tswing @ (%obj.swingPhase + 1) % 2 + 1);
   %obj.schedule(32, stopThread, 2);
   %obj.setImageAmmo(%slot, !%obj.meleeStance);
      %obj.playAudio(2, lightSaberHumSound);
      %client = %obj.client;
      if(%user.Idle)
   {
      return;
   }
   if(%client.player.Idle == 1)
   {
      serverPlay3D(EquipVest, %obj.position);
      %client.player.unmountimage(2);
      %client.player.Idle = 0;
      if(%user.color)
   {
      return;
   }

if(%client.player.color == 1)
      %client.player.mountimage(Greenimage, 3);
if(%client.player.color == 2)
      %client.player.mountimage(Blueimage, 3);
if(%client.player.color == 3)
      %client.player.mountimage(Redimage, 3);
   }
}
//1 is green
//2 is blue
//3 is red

function serverCmdcolorgreen(%client)
{
    %client.player.color = 1;
   commandtoclient(%client, 'centerprint', "<font:impact:20>\c3Reqeuip for effects to take place", 5);
}
function serverCmdcolorblue(%client)
{
    %client.player.color = 2;
    commandtoclient(%client, 'centerprint', "<font:impact:20>\c3Reqeuip for effects to take place", 5);

}

function serverCmdcolorred(%client)
{
    %client.player.color = 3;
      commandtoclient(%client, 'centerprint', "<font:impact:20>\c3Reqeuip for effects to take place", 5);
}

Some snippets of what I did. Im beginner at code so might look very inefficient but worked

Some snippets of what I did. Im beginner at code so might look very inefficient but worked
we all know how colorshifting works. it still requires restarting the server if you try to colorshift anything outside what is already executed

we all know how colorshifting works. it still requires restarting the server if you try to colorshift anything outside what is already executed

He's not shifting colors. He's just mounting an another image/item to the player. I guess that the code then could be more like this:

Code: [Select]
function serverCmdTurnOnLightSaber(%client)
{
%player = %client.player;
%player.updateArm(RedImage);
%player.mountImage(RedImage, 0);
}
function serverCmdTurnOffLightSaber(%client)
{
%player = %client.player;
%player.updateArm(EmptyImage);
%player.mountImage(EmptyImage, 0);
}

Of course, this could be set to a toggle and more appropriate names.