Blockland Forums > Modification Help
Brick Changing
(1/1)
Bauklotz:

--- Code: ---      %gt = vectorAdd(%this.getPosition(), %obj.vehicleOffset);
      if(%obj.getPosition() $= %gt)
         return;
      %obj.setName("tempCopy_fxDTSBrick");
      %new = new fxDTSBrick(tempCopy2_fxDTSBrick : tempCopy_fxDTSBrick) {
         position = %gt;
         isPlanted = false;
      };
      %new.setName(%obj.getName());
      %new.setItem((isObject(%item = %obj.item.dataBlock) ? %item : -1));
      if(isObject(%obj.getGroup()))
         %obj.getGroup().add(%new);
      %new.setTrusted(1);
      %new.isPlanted = true;
      %new.plant();
      %obj.delete();

--- End code ---
What is wrong with the above code?
Destiny/Zack0Wack0:
Set isPlanted to 1 inside the creation of %new.
Bauklotz:
This is what I currently have.

--- Code: ---function wheeledVehicle::moveBricks(%this) {
   cancel(%this.moveBricks);
   if(!isObject(%brk = %this.spawnBrick))
      return:
   %cnt = %brk.bricks+1;
   for(%i=0;%i<%cnt;%i++) {
      %obj = %brk.bricks[%i];
      if(!isObject(%obj) || %obj $= %brk || %obj.getDataBlock().getName() $= brickJeepBaseplateData)
         continue;
      %gt = vectorAdd(%this.getPosition(), %obj.vehicleOffset);
      if(%this.getPosition() $= %gt)
         continue;
      %n = %obj.getName();
      %obj.setName("tempCopy_fxDTSBrick");
      %new = new fxDTSBrick(tempCopy2_fxDTSBrick : tempCopy_fxDTSBrick) {
         position = %gt;
         rotation = %this.rotation;
         isPlanted = true;
      };
      %new.setName(%n);
      %new.setColliding(false);
      %new.setItem((isObject(%item = %obj.item.dataBlock) ? %item : -1));
      if(isObject(%obj.getGroup()))
         %obj.getGroup().add(%new);
      %new.setTrusted(1);
      %obj.delete();
      %new.plant();
   }
   %this.moveBricks = %this.schedule(1, moveBricks);
}

--- End code ---

But the problem is, it keeps deleting %brk (.spawnBrick), and then complaining about that %this doesn't exist when doing %this.schedule.
Destiny/Zack0Wack0:
I can't see the error, but I'm going to be the first to point out that this is going to be horribly implemented.
Bauklotz:
You're not first. I was first.  :cookieMonster:
Navigation
Message Index

Go to full version