Author Topic: Help with colorshifting a model  (Read 1495 times)


So I finally figured out how to make the color change on my Stomrtrooper model but the problem is I can't change the color unless I edit the script. I have been trying to figure out what the hell I have to do to get the blue parts of this model to change based on the color on the player's chest.

Here's the portion of the code that changes color:

Colorshift is a datablock field. Datablocks are like templates for building objects. You can make a duplicate datablock with a different colorshift, but you shouldn't dynamically create new datablocks.

concept: loop through as many distinctively different colors as possible and create a different colored datablock for each, then assign the player to the closest color you have in your table of differently color-shifted datablocks

Why are they images? Should this not be a player type?

It's generally not a good idea to make a separate data-block for each colored armor. Instead let's try something like this:

Code: [Select]
//CHANGE COLOR
function YourArmorImage::onMount(%this, %obj, %slot)
{
%this.doColorshift = true; //Just to be sure
%this.colorShiftColor = getColorIDTable(%obj.client.currentColor);
}

This will change the color of the armor to the color of your paint can

It's generally not a good idea to make a separate data-block for each colored armor. Instead let's try something like this:

Code: [Select]
//CHANGE COLOR
function YourArmorImage::onMount(%this, %obj, %slot)
{
%this.doColorshift = true; //Just to be sure
%this.colorShiftColor = getColorIDTable(%obj.client.currentColor);
}

This will change the color of the armor to the color of your paint can
It doesn't, color shift is a datablocks variable.

I still have no idea why these are images instead of a playertype, then you can just call setNodeColor or name your nodes properly so the default code handles applying the avatar.

Dynamically creating a bunch of datablocks is generally a bad practice.

It doesn't, color shift is a datablocks variable.
It works...it's the same code I used for the Pilgrim Hat and Native Headband

It works...it's the same code I used for the Pilgrim Hat and Native Headband
It only works for the host and it'll only work for them if it's not a dedicated server.

It only works for the host and it'll only work for them if it's not a dedicated server.
Well that's nice to find out....it certainly doesn't work on a dedicated server, and works oddly on a non-dedicated. It seems it only works with the host's current color o.O very odd.

I guess the only way to do this is to stick with using a player-type, or do something like this
Code: [Select]
datablock ShapeBaseImageData(HatRedImage)
{
shapeFile = "./YourHat.dts";
emap = true;
mountPoint = $HeadSlot;
offset = "0 0 0.2";
rotation = eulerToMatrix("0 0 0");
eyeOffset = "0 0 0.24";
eyeRotation = eulerToMatrix("0 0 0");
correctMuzzleVector = false;
className = "WeaponImage";
item = HatRedItem;
melee = false;
armReady = false;
doColorShift = true;
colorShiftColor = "1 0 0 1";
//Custom Hat Property
isHat = true;
//Idle State
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.2;
stateTransitionOnTimeout[0]      = "Ready";

stateName[1]                     = "Ready";
stateScript[1]                  = "onReady";
stateTransitionOnTimeout[1] = "Activate";
stateTimeoutValue[1]             = 0.8;
stateAllowImageChange[1]         = true;
};
datablock ShapeBaseImageData(HatOrangeImage : HatRedImage)
{
doColorShift = true;
colorShiftColor = "0.8 0.4 0 1";
};
datablock ShapeBaseImageData(HatYellowImage : HatRedImage)
{
doColorShift = true;
colorShiftColor = "0.7 0.7 0 1";
};
datablock ShapeBaseImageData(HatGreenImage : HatRedImage)
{
doColorShift = true;
colorShiftColor = "0 1 0 1";
};
Then you could make a command that lets players change their helm/armor color
--
This all seems a bit unnecessary just to change an image color, I wonder if there is a better method for re-coloring images?

This all seems a bit unnecessary just to change an image color, I wonder if there is a better method for re-coloring images?
Nope. Only playertypes, static shapes, and bricks are easily recolorable during gameplay.

It's probably a good idea to post the mod in it's current state here and see what can be done about it.
http://www.mediafire.com/download/j3607j8o97twduo/Player_FOStormtrooper.zip

The solution is to make it a proper player model and not two images.

Which means lots of animating?

Which means lots of animating?

Import the default m.dts in blender, replace torso and head with the custom models, replace all nodes you don't want (like hats) with empty meshes, export again. Animations are in .dsq files so they'll work automatically as long as the node names aren't changed.