Author Topic: Recolor question 2  (Read 1110 times)

Yes, me again.
And yes, again a recloring problem.

Now that i know how to get the value, i am still doing SOMETHING wrong, but i have absolutely no idea what it could be! D:
I tried many, many things, but i just can't seem to fix it.
Please tell me, what is wrong here:
Code: [Select]
function Zombie::onAdd(%this,%obj)
{
parent::onAdd(%this,%obj);
ZombieDefault::onAdd(%this,%obj);
//%obj.mountimage(rocketlauncherimage,0);
if(%obj.getClassName() $= "AIPlayer" && isObject(%brick = %obj.spawnBrick))
{
if(%obj.spawnbrick.ReColorVehicle == 1)
{
%obj.schedule(100,setnodeColor,"ALL",%obj.getDataBlock().skinColor);
}
}
}
« Last Edit: August 02, 2010, 05:17:52 PM by lordician »


what are you trying to do here?


what are you trying to do here?
I try to check if the newly made ZombieDatablock (player or AI) is a bot, then i try to find if it has a spawnbrick, then i try to look if it has recolorvehicle on and if not, recolor the bot to the setted color in the datablock.

Tom

You will need to get the bricks colorID (%brick.colorID) then use getColorIdTable(%colorID); to determine the RGB color of it. Then you will need to set the zombies color to that.
« Last Edit: August 03, 2010, 06:48:31 PM by Tom »

You will need to get the bricks colorID (%brick.colorID) then use getColorIdTable(%colorID); to determine the RGB color of it. Then you will need to set the zombies color to that.
Usefull for something else i am working on, but not for this.
But thanks anyway.

Tom

Oh sorry, I was confused about what you wanted.

I don't really see anything wrong with the script, maybe you could stick a few echos in their to see where the problem is happening.

Code: [Select]
function Zombie::onAdd(%this,%obj)
{
        echo("Zombie::onAdd was called!");
parent::onAdd(%this,%obj);
ZombieDefault::onAdd(%this,%obj);
//%obj.mountimage(rocketlauncherimage,0);
if(%obj.getClassName() $= "AIPlayer" && isObject(%brick = %obj.spawnBrick))
{
        echo("The zombie is an AI player!");
if(%obj.spawnbrick.ReColorVehicle == 1)
{
                         echo("The spawnbrick has reColorVehicle set.");
%obj.schedule(100,setnodeColor,"ALL",%obj.getDataBlock().skinColor);
}
}
}
If everything shows up in the console, then you problem have a problem with the setNodeColor schedule.


Oh sorry, I was confused about what you wanted.

I don't really see anything wrong with the script, maybe you could stick a few echos in their to see where the problem is happening.

Code: [Select]
function Zombie::onAdd(%this,%obj)
{
        echo("Zombie::onAdd was called!");
parent::onAdd(%this,%obj);
ZombieDefault::onAdd(%this,%obj);
//%obj.mountimage(rocketlauncherimage,0);
if(%obj.getClassName() $= "AIPlayer" && isObject(%brick = %obj.spawnBrick))
{
        echo("The zombie is an AI player!");
if(%obj.spawnbrick.ReColorVehicle == 1)
{
                         echo("The spawnbrick has reColorVehicle set.");
%obj.schedule(100,setnodeColor,"ALL",%obj.getDataBlock().skinColor);
}
}
}
If everything shows up in the console, then you problem have a problem with the setNodeColor schedule.


I thought it was fine too, but i'll try that to check it. Thanks a lot.

It only echo'd the first echo. :S
So, something's wrong with checking if the spawnbrick is an object.

Because i am sure, the AIplayer check works right.

Tom

Try making it just:
if(%obj.getClassName() $= "AIPlayer" && isObject(%obj.spawnBrick))

And if you haven't already, make sure AI players actually have a spawnBrick field.

Try making it just:
if(%obj.getClassName() $= "AIPlayer" && isObject(%obj.spawnBrick))

And if you haven't already, make sure AI players actually have a spawnBrick field.
Bots spawned from a vehicle spawn should have that field. :C
Also, have tried that allready since i don't really need %brick anyhow. :C

But perhaps i have an idea...

I have found the solution! :D
*partyemoticonhere*

It seems that when you spawn a vehicle or bot in this case, the spawnbrick field doesn't exist yet. :O
So basically, when it is added, it doesn't have anything else then it's datablock, but when you check after it is added (schedule a function) it has. :D

So, yeah, ask me about it, i guess i didn't explain very well now, i am in a WIN rush.
After all this time, i found the solution! :DD