function fxDTSbrick::UpDuplicate(%this)
{
%xsize = %this.getDatablock().brickSizeX * 0.2;
%pos = vectorAdd(%this.getPosition(), %xsize SPC "0 0");
%brick = new FxDTSbrick()
{
datablock = %this.getDatablock();
position = %pos;
rotation = %this.rotation;
colorID = %this.colorID;
scale = "1 1 1";
angleID = %this.angleID;
colorFxID = %this.colorFxID;
shapeFxID = %this.shapeFxID;
isPlanted = 1;
client = %this.client;
};
%brick.plant();
%brick.setTrusted(1);
if(isObject(%this.getGroup()))
{
%this.getGroup().add(%brick);
}
$Server::BrickCount++;
return %brick;
}
function Plant::dead(%this)
{
%this.killBrick();
}
function Plant::onActivate(%this,%obj,%player)
{
if(%obj.finished)
{
%this.killBrick();
%player.client.FinishedPlants++;
messageClient(%client,'',"You have harvested your Grown Plant!");
}
}
function FarmingTick()
{
cancel($FarmingTick);
for(%i=0;%i<FarmBricks.getCount();%i++)
{
%brick = FarmBricks.getObject(%i);
if(%brick.stage == 10)
{
%brick.finished += 1;
}
else if(%brick.finished == 3)
%brick.dead();
else
{
%brick.UpDuplicate();
%brick.stage++;
}
}
$FarminTick = schedule(60000,0,FarmingTick);
}
In this mod, the brick actually grows up instead of just changing colors.
but heres the fixed version:
datablock fxDTSBrickData(FarmRPGBlueberryData)
{
brickFile = "Add-Ons/Script_FarmMod/brickShapes/1x1F.blb";
category = "Farm Mod";
subCategory = "Small Plants";
uiName = "Blueberry Plant";
iconName = "Add-Ons/Script_FarmMod/brickIcons/blueberry.png";
};
function FarmRPGBlueberryData::onPlant(%datablock, %client)
{
%datablock.setcolor(54);
}
function FarmRPGBlueberryData::onActivate(%datablock, %client)
{
if(!%datablock.isWatered)
{
messageClient(%client,'',"\c6You have watered your \c5blueberry\c6 plant.");
%datablock.isWatered = 1;
schedule(120000,0,eval,"%datablock.growth = 1;");
schedule(120000,0,eval,"%datablock.setcolor(55);");
schedule(120000*2,0,eval,"%datablock.growth = 2;");
schedule(120000*2,0,eval,"%datablock.setcolor(56);");
schedule(120000*3,0,eval,"%datablock.growth = 3;");
schedule(120000*3,0,eval,"%datablock.setcolor(57);");
schedule(120000*4,0,eval,"%datablock.growth = 4;");
schedule(120000*4,0,eval,"%datablock.setcolor(58);");
schedule(120000*5,0,eval,"%datablock.growth = 5;");
schedule(120000*5,0,eval,"%datablock.setcolor(59);");
}
else if(%datablock.isWatered)
{
messageClient(%client,'',"\c6You have already watered your \c5blueberry\c6 plant!");
}
else if(%datablock.growth == 1)
{
messageClient(%client,'',"\c6The \c5blueberry\c6 plant is \c320\c6% done!");
}
else if(%datablock.growth == 2)
{
messageClient(%client,'',"\c6The \c5blueberry\c6 plant is \c340\c6% done!");
}
else if(%datablock.growth == 3)
{
messageClient(%client,'',"\c6The \c5blueberry\c6 plant is \c360\c6% done!");
}
else if(%datablock.growth == 4)
{
messageClient(%client,'',"\c6The \c5blueberry\c6 plant is \c380\c6% done!");
}
else if(%datablock.growth == 5)
{
messageClient(%client,'',"\c6You harvested your \c5blueberry \c6plant!");
%datablock.growth = 0;
%datablock.setcolor(63);
%datablock.isWatered = 0;
%client.blueberry += 1;
}
return;
}