Author Topic: A Loading Problem  (Read 2895 times)

Code: [Select]
package plantLots
{
    function CityRPGXSmallLotBrickData::OnLoadPlant(%this,%brick,%a)
    {
new trigger()
{
     triggerData = %brick.getDatablock().CityRPGXLotTriggerData;
}
return parent::OnLoadPlant(%this, %brick, %a);
    }
    function CityRPGXHalfSmallLotBrickData::OnLoadPlant(%this,%brick,%a)
    {
new trigger()
{
     triggerData = %brick.getDatablock().CityRPGXLotTriggerData;
}
return parent::OnLoadPlant(%this, %brick, %a);
    }
};


I'm hoping datablock shouldn't stay datablock.

No, 'datablock' is a special namespace that needs to stay datablock
and you need a ; at the end of every object declaration.  A trigger counts as an object, as well as anything you need a new thingy(){}; to create.
and you still dont have an instance field for "CityRPGXLotTriggerData" so stop trying to use it.

And you need more instance fields than just the datablock.

I'd take lugnut's advice, all you need is two extra functions almost identical to the ones that already exist.

Thats a pretty big piece of code to copy.

It would need to be:

Code: [Select]
function fxDTSBrick::onLoadPlant(%brick)
{
Parent::onLoadPlant(%brick);

if(isObject(%brick))
{
if(%brick == $LastLoadedBrick)
{
switch(%brick.getDatablock().CityRPGXBrickType)
{
case 1:
%brick.schedule(1, "handleCityRPGXBrickCreation");
case 2:
%brick.schedule(1, "handleCityRPGXBrickCreation");
case 3:
$CityRPGX::temp::spawnPoints = ($CityRPGX::temp::spawnPoints $= "") ? %brick : $CityRPGX::temp::spawnPoints SPC %brick;
case 4:
%brick.resources = %brick.getDatablock().resources;
case 6:
%brick.schedule(1, "handleCityRPGXBrickCreation");
case 10:
%brick.schedule(1, "handleCityRPGXBrickCreation");
}
}
else
{
if(isObject(%client = %brick.getGroup().client))
{
if(mFloor(getWord(%brick.rotation, 3)) == 90)
{
%boxSize = getWord(%brick.getDatablock().brickSizeY, 1) / 2.5 SPC getWord(%brick.getDatablock().brickSizeX, 0) / 2.5 SPC getWord(%brick.getDatablock().brickSizeZ, 2) / 2.5;
}
else
{
%boxSize = getWord(%brick.getDatablock().brickSizeX, 1) / 2.5 SPC getWord(%brick.getDatablock().brickSizeY, 0) / 2.5 SPC getWord(%brick.getDatablock().brickSizeZ, 2) / 2.5;
}

initContainerBoxSearch(%brick.getWorldBoxCenter(), %boxSize, $typeMasks::triggerObjectType);

while(isObject(%trigger = containerSearchNext()))
{
if(%trigger.getDatablock() == CityRPGXLotTriggerData.getID())
{
%lotTrigger = %trigger;
}
}

if(%lotTrigger && %brick.getDatablock().CityRPGXBrickType != 1)
{
%lotTriggerMinX = getWord(%lotTrigger.getWorldBox(), 0);
%lotTriggerMinY = getWord(%lotTrigger.getWorldBox(), 1);
%lotTriggerMinZ = getWord(%lotTrigger.getWorldBox(), 2);

%lotTriggerMaxX = getWord(%lotTrigger.getWorldBox(), 3);
%lotTriggerMaxY = getWord(%lotTrigger.getWorldBox(), 4);
%lotTriggerMaxZ = getWord(%lotTrigger.getWorldBox(), 5);

%brickMinX = getWord(%brick.getWorldBox(), 0) + 0.0016;
%brickMinY = getWord(%brick.getWorldBox(), 1) + 0.0013;
%brickMinZ = getWord(%brick.getWorldBox(), 2) + 0.00126;

%brickMaxX = getWord(%brick.getWorldBox(), 3) - 0.0016;
%brickMaxY = getWord(%brick.getWorldBox(), 4) - 0.0013;
%brickMaxZ = getWord(%brick.getWorldBox(), 5) - 0.00126;


if(%brickMinX >= %lotTriggerMinX && %brickMinY >= %lotTriggerMinY && %brickMinZ >= %lotTriggerMinZ)
{
if(%brickMaxX <= %lotTriggerMaxX && %brickMaxY <= %lotTriggerMaxY && %brickMaxZ <= %lotTriggerMaxZ)
{
if(%brick.getDatablock().CityRPGXBrickAdmin &&!%client.isAdmin)
{
commandToClient(%client, 'centerPrint', "You must be an admin to plant this brick.", 3);
%brick.schedule(0, "delete");
}
else
{
switch(%brick.getDatablock().CityRPGXBrickType)
{
case 2:
%brick.schedule(0, "handleCityRPGXBrickCreation");
case 3:
$CityRPGX::temp::spawnPoints = ($CityRPGX::temp::spawnPoints $= "") ? %brick : $CityRPGX::temp::spawnPoints SPC %brick;
case 4:
if(%brick.getDatablock().resources)
%brick.resources = %brick.getDatablock().resources;
case 420:
if(%lotTrigger && %brick.getDataBlock().CityRPGXBrickType == 420 || !%lotTrigger && %brick.getDataBlock().CityRPGXBrickType == 420 && %client.isAdmin)
{
if(!%lotTrigger && !%client.isAdmin)
{
commandToClient(%client, 'centerPrint', "You cannot plant a brick outside of a lot.\n\c6Use a lot brick to start your build!", 3);
messageAll(%client,'',"\c6ERRORRRR");
%brick.schedule(0, "delete");
return;
}
else if(%lotTrigger && %client.isAdmin || %lotTrigger && !%client.isAdmin || !%lotTrigger && %client.isAdmin)
{
messageAll(%client,'',"\c6GOOO");
if(CityRPGXData.getData(%client.bl_id).valueMoney >= mFloor(%brick.getDatablock().price))
{
if(CityRPGXData.getData(%client.bl_id).valuedrugamount <= $CityRPGX::drug::maxdrugplants)
{
CityRPGXData.getData(%client.bl_id).valueMoney -= mFloor(%brick.getDatablock().price);
CityRPGXData.getData(%client.bl_id).valuedrugamount++;
%drug = %brick.getID();
%drug.canchange = true;
%drug.isGrowing = false;
%drug.grew = false;
%drug.watered = false;
%drug.isDrug = true;
%drug.currentColor = 45;
%drug.setColor(45);
%drug.owner = %client.bl_id;
%drug.hasemitter = true;
%drug.growtime = 0;
%drug.health = 0;
%drug.orighealth = %drug.health;
if(%brick.getDataBlock().drugType $= "marijuana")
{
%drug.random = getRandom($CityRPGX::drugs::marijuana::harvestMin,$CityRPGX::drugs::marijuana::harvestMax);
%drug.uiName = "Marijuana";
messageClient(%client, '', "\c6You have paid \c3$" @ mFloor(%brick.getDatablock().price) @ "\c6 to plant a \c3Marijuana\c6 brick.");
}
else if(%brick.getDataBlock().drugType $= "opium")
{
%drug.random = getRandom($CityRPGX::drugs::opium::harvestMin,$CityRPGX::drugs::opium::harvestMax);
%drug.uiName = "opium";
messageClient(%client, '', "\c6You have paid \c3$" @ mFloor(%brick.getDatablock().price) @ "\c6 to plant an \c3Opium\c6 brick.");
}
%drug.canbecolored = false;
%drug.setEmitter("None");
%drug.cansetemitter = false;
%drug.emitterr = "GrassEmitter";
%drug.canchange = false;
}
else
{
commandToClient(%client, 'centerPrint', "\c6You have met the limit of drugs you can plant.", 1);
%brick.schedule(0, "delete");
}
}
else
{
commandToClient(%client, 'centerPrint', "\c6You need at least \c3$" @ mFloor(%brick.getDatablock().price) SPC "\c6in order to plant this.", 1);
%brick.schedule(0, "delete");
}
}
else
{
if(CityRPGXData.getData(%client.bl_id).valueMoney >= mFloor(%brick.getDatablock().price))
{
if(CityRPGXData.getData(%client.bl_id).valuedrugamount < $CityRPGX::drug::maxdrugplants)
{
CityRPGXData.getData(%client.bl_id).valueMoney -= mFloor(%brick.getDatablock().price);
CityRPGXData.getData(%client.bl_id).valuedrugamount++;
%drug = %brick.getID();
%drug.canchange = true;
%drug.isGrowing = false;
%drug.grew = false;
%drug.watered = false;
%drug.isDrug = true;
%drug.currentColor = 45;
%drug.setColor(45);
%drug.owner = %client.bl_id;
%drug.hasemitter = true;
%drug.growtime = 0;
%drug.health = 0;
%drug.orighealth = %drug.health;
if(%brick.getDataBlock().drugType $= "marijuana")
{
%drug.random = getRandom($CityRPGX::drugs::marijuana::harvestMin,$CityRPGX::drugs::marijuana::harvestMax);
%drug.uiName = "Marijuana";
messageClient(%client, '', "\c6You have paid \c3$" @ mFloor(%brick.getDatablock().price) @ "\c6 to plant a \c3Marijuana\c6 brick.");
}
else if(%brick.getDataBlock().drugType $= "opium")
{
%drug.random = getRandom($CityRPGX::drugs::opium::harvestMin,$CityRPGX::drugs::opium::harvestMax);
%drug.uiName = "opium";
messageClient(%client, '', "\c6You have paid \c3$" @ mFloor(%brick.getDatablock().price) @ "\c6 to plant an \c3Opium\c6 brick.");
}
%drug.canbecolored = false;
%drug.setEmitter("None");
%drug.cansetemitter = false;
%drug.emitterr = "GrassEmitter";
%drug.canchange = false;
}
else
{
commandToClient(%client, 'centerPrint', "\c6You have met the limit of drugs you can plant.", 1);
%brick.schedule(0, "delete");
}
}
else
{
commandToClient(%client, 'centerPrint', "\c6You need at least \c3$" @ mFloor(%brick.getDatablock().price) SPC "\c6in order to plant this.", 1);
%brick.schedule(0, "delete");
}
}
}
default:
if(!%brick.brickGroup.client.isAdmin && %brick.getDatablock().getID() == brickVehicleSpawnData.getID())
{
if(CityRPGXData.getData(%client.bl_id).valueMoney >= mFloor($CityRPGX::prices::vehicleSpawn))
{
commandToClient(%client, 'centerPrint', "\c6You have paid \c3$" @ mFloor($CityRPGX::prices::vehicleSpawn) @ "\c6 to plant this vehicle spawn.", 3);
CityRPGXData.getData(%client.bl_id).valueMoney -= mFloor($CityRPGX::prices::vehicleSpawn);
%client.setInfo();
}
else
{
commandToClient(%client, 'centerPrint', "\c6You need at least \c3$" @ mFloor($CityRPGX::prices::vehicleSpawn) SPC "\c6in order to plant this vehicle spawn!", 3);
%brick.schedule(0, "delete");
}
}
}
}
}
else
%brick.schedule(0, "delete");
}
else
%brick.schedule(0, "delete");
}
else if(%lotTrigger && %brick.getDataBlock().CityRPGXBrickType == 420 || !%lotTrigger && %brick.getDataBlock().CityRPGXBrickType == 420 && %client.isAdmin)
{
if(!%lotTrigger && !%client.isAdmin)
{
commandToClient(%client, 'centerPrint', "You cannot plant a brick outside of a lot.\n\c6Use a lot brick to start your build!", 3);
%brick.schedule(0, "delete");
return;
}
else if(%lotTrigger && %client.isAdmin || %lotTrigger && !%client.isAdmin || !%lotTrigger && %client.isAdmin)
{
if(CityRPGXData.getData(%client.bl_id).valueMoney >= mFloor(%brick.getDatablock().price))
{
if(CityRPGXData.getData(%client.bl_id).valuedrugamount <= $CityRPGX::drug::maxdrugplants)
{
CityRPGXData.getData(%client.bl_id).valueMoney -= mFloor(%brick.getDatablock().price);
CityRPGXData.getData(%client.bl_id).valuedrugamount++;
%drug = %brick.getID();
%drug.canchange = true;
%drug.isGrowing = false;
%drug.grew = false;
%drug.watered = false;
%drug.isDrug = true;
%drug.currentColor = 45;
%drug.setColor(45);
%drug.owner = %client.bl_id;
%drug.hasemitter = true;
%drug.growtime = 0;
%drug.health = 0;
%drug.orighealth = %drug.health;
if(%brick.getDataBlock().drugType $= "marijuana")
{
%drug.random = getRandom($CityRPGX::drugs::marijuana::harvestMin,$CityRPGX::drugs::marijuana::harvestMax);
%drug.uiName = "Marijuana";
messageClient(%client, '', "\c6You have paid \c3$" @ mFloor(%brick.getDatablock().price) @ "\c6 to plant a \c3Marijuana\c6 brick.");
}
else if(%brick.getDataBlock().drugType $= "opium")
{
%drug.random = getRandom($CityRPGX::drugs::opium::harvestMin,$CityRPGX::drugs::opium::harvestMax);
%drug.uiName = "opium";
messageClient(%client, '', "\c6You have paid \c3$" @ mFloor(%brick.getDatablock().price) @ "\c6 to plant an \c3Opium\c6 brick.");
}
%drug.canbecolored = false;
%drug.setEmitter("None");
%drug.cansetemitter = false;
%drug.emitterr = "GrassEmitter";
%drug.canchange = false;
}
else
{
commandToClient(%client, 'centerPrint', "\c6You have met the limit of drugs you can plant.", 1);
%brick.schedule(0, "delete");
}
}
else
{
commandToClient(%client, 'centerPrint', "\c6You need at least \c3$" @ mFloor(%brick.getDatablock().price) SPC "\c6in order to plant this.", 1);
%brick.schedule(0, "delete");
}
}
}
else if(%lotTrigger && %brick.getDatablock().CityRPGXBrickType == 1)
{
commandToClient(%client, 'centerPrint', "Only Chuck Norris can put a lot on top of another lot.", 3);
%brick.schedule(0, "delete");
}
else if(!%lotTrigger && %brick.getDatablock().CityRPGXBrickType == 1)
{
if(CityRPGXData.getData(%client.bl_id).valueMoney >= mFloor(%brick.getDatablock().initialPrice))
{
if(%client.brickGroup.lotsOwned < $CityRPGX::pref::realestate::maxLots)
{
messageClient(%client, '', "\c6You have paid \c3$" @ mFloor(%brick.getDatablock().initialPrice) @ "\c6 to plant this lot.");
CityRPGXData.getData(%client.bl_id).valueMoney -= mFloor(%brick.getDatablock().initialPrice);
%brick.schedule(0, "handleCityRPGXBrickCreation");
}
else
{
commandToClient(%client, 'centerPrint', "You already own the maximum number of lots.", 3);
%brick.schedule(0, "delete");
}
}
else
{
commandToClient(%client, 'centerPrint', "\c6You need at least \c3$" @ mFloor(%brick.getDatablock().initialPrice) SPC "\c6in order to plant this lot!", 3);
%brick.schedule(0, "delete");
}
}
else if(!%lotTrigger)
{
if(!%client.isAdmin)
{
commandToClient(%client, 'centerPrint', "You cannot plant a brick outside of a lot.\n\c6Use a lot brick to start your build!", 3);
%brick.schedule(0, "delete");
}
else
{
if(%brick.getDatablock().CityRPGXBrickAdmin &&!%client.isAdmin)
{
commandToClient(%client, 'centerPrint', "You must be an admin to plant this brick.", 3);
%brick.schedule(0, "delete");
}
else
{
switch(%brick.getDatablock().CityRPGXBrickType)
{
case 2:
%brick.schedule(0, "handleCityRPGXBrickCreation");
case 3:
$CityRPGX::temp::spawnPoints = ($CityRPGX::temp::spawnPoints $= "") ? %brick : $CityRPGX::temp::spawnPoints SPC %brick;
case 4:
if(%brick.getDatablock().resources)
{
%brick.resources = %brick.getDatablock().resources;
}
default:
if(%brick.getDatablock().getID() == brickVehicleSpawnData.getID())
{
if(CityRPGXData.getData(%client.bl_id).valueMoney >= mFloor($CityRPGX::prices::vehicleSpawn))
{
commandToClient(%client, 'centerPrint', "\c6You have paid \c3$" @ mFloor($CityRPGX::prices::vehicleSpawn) @ "\c6 to plant this vehicle spawn.", 3);
CityRPGXData.getData(%client.bl_id).valueMoney -= mFloor($CityRPGX::prices::vehicleSpawn);
}
else
{
commandToClient(%client, 'centerPrint', "\c6You need at least \c3$" @ mFloor($CityRPGX::prices::vehicleSpawn) SPC "\c6in order to plant this vehicle spawn!", 3);
%brick.schedule(0, "delete");
}
}
}
}
}
}
else
messageAll('', "fxDTSBrick::onLoadPlant() - Brick fell through tests!");
}
else
{
switch(%brick.getDatablock().CityRPGXBrickType)
{
case 1:
%brick.schedule(0, "delete");
case 2:
%brick.schedule(0, "handleCityRPGXBrickCreation");
case 3:
$CityRPGX::temp::spawnPoints = ($CityRPGX::temp::spawnPoints $= "") ? %brick : $CityRPGX::temp::spawnPoints SPC %brick;
case 4:
%brick.resources = %brick.getDatablock().resources;
}
}
}
}
}

Of course, im not expecting anyone to brown townyze it.

looks good

If you want to make it shorter, you can probably make one function with all that code and then have your different packaged functions all point to it, but you don't need to.

This works. For now at least. I'll shorten it later when I rewrite drugs to be less stupid.

see guys
i told you i was a pr0!!!111