Author Topic: Disable brick planting inside Modter  (Read 1760 times)

I want to do a salvage gamemode in my toystore map but I don't want people able to plant bricks inside modter bricks because that defeats the purpose of having a "map." Things end up getting messy and I'll even have spawn points inside modter walls.

Is there any way someone can enable a switch to prevent planting inside modter?

You would have to set the .isWaterBrick to false on every single modter datablock, which still comes with problems of it's own. Every modter brick is counted as a cuboid in terms of the brick grid. So even if you had a ramp brick, you couldn't build on the ramp part itself, you could however, build 'floating' bricks atop of the grid aspect of the brick.

Here's some quick stuffty code to do this:
Code: [Select]
function modterSetWater(%w)
{
$Pref::Server::modterSolidState = !%w;
if(isObject(brick32Cube5Data))
{
%y=brick32Cube5Data.getID()+133;
for(%x=brick32Cube5Data.getID();%x<%y;%x++)
%x.isWaterBrick=%w;
}
if(isObject(brick32Ramp5InvData))
{
%y=brick32Ramp5InvData.getID()+95;
for(%x=brick32Ramp5InvData.getID();%x<%y;%x++)
%x.isWaterBrick=%w;
}
}

function serverCmdModterSetWater(%c,%w)
{
if(%c.isSuperAdmin)
{
if(%w)
messageClient(%c,'',"Modter is now 'water'.");
else
messageClient(%c,'',"Modter is now 'solid'.");
modterSetWater(%w);
}
}

if($Pref::Server::modterSolidState)
schedule(0,0,modterSetWater,0);


Completely untested, terrible code.

/modterSetWater 0

That code is a terrible hack and you shouldn't be surprised if it stops working overnight

That code is a terrible hack and you shouldn't be surprised if it stops working overnight
To be fair, the only reason it would stop working, assuming it works in the first place, is that if the number of datablocks in modter changes.

Remember when terrain used "grounded" what about trying to do that with modter?

Is there a way to modify the ramp modter so it would assume the edges that don't exist are floating?

This was solved on Furdle's old GTA server by having drug bricks do a container raycast check of their own bounds for any other existing brick within those same bounds - so planting them within the bounds of any existing brick were negated, this included modTer ramps and other bricks that were visually possible to build in - but weren't due to the check.

Created this in like 5 minutes, unsure if it works.

/TogModTerWater

//Unsure if DatablockGroup should be good to use, but it should work anyways
function serverCmdTogModTerWater(%client)
{
   if(!%client.isSuperAdmin)
      return;

   announce("Converting ModTer bricks... (" @ %client.getPlayerName() @ ")"); //Tell who's doing it.

   %converted = 0;
   for(%i = 0; %i < DatablockGroup.getCount(); %i++)
   {
      %datablock = DatablockGroup.getObject(%i);
      if(%datablock.printAspectRatio $= "ModTer")
      {
         if(%isWaterBrick $= "")
            %isWaterBrick = %datablock.isWaterBrick;

         if(%isWaterBrick)
         {
            %datablock.isWaterBrick = !%datablock.isWaterBrick;
            %converted++;
         }
      }
   }

   announce("Converted " @ %converted @ " ModTer bricks to " @ (%isWaterBrick ? "regular bricks. You can no longer plant bricks inside ModTer." : " overlapping bricks. You can now plant bricks inside ModTer."));
}


Edit: If you want it to work instantly, here's one.
function TogModTerWater()
{
   announce("Converting ModTer bricks... ");
   %converted = 0;
   for(%i = 0; %i < DatablockGroup.getCount(); %i++)
   {
      %datablock = DatablockGroup.getObject(%i);
      if(%datablock.printAspectRatio $= "ModTer")
      {
         if(%isWaterBrick $= "")
            %isWaterBrick = %datablock.isWaterBrick;

         if(%isWaterBrick)
         {
            %datablock.isWaterBrick = !%datablock.isWaterBrick;
            %converted++;
         }
      }
   }
   announce("Converted " @ %converted @ " ModTer bricks to " @ (%isWaterBrick ? "regular bricks. You can no longer plant bricks inside ModTer." : " overlapping bricks. You can now plant bricks inside ModTer."));
}
schedule(0, 0, "TogModTerWater");


Editing datablocks are usually not recommended, but it would still work.
« Last Edit: November 12, 2015, 11:44:31 PM by Kyuande »



okay and its still completely subject to failure until you test it

One thing that worries me is if I disable water planing when I load bricks will all current bricks in the save that are inside a modter brick not load?

How will we do slope bricks?

okay and its still completely subject to failure until you test it
what difference does it make...
if it doesn't work, then it doesn't work. it's not going to be any more likely to work because one person tests it rather than someone else

isWaterBrick is a datablock variable and should not be messed around with after load like the above are suggesting, there is only one real right/simple way to do it and it is the way I explained above.