Please test this Plant Anywhere script I made

Author Topic: Please test this Plant Anywhere script I made  (Read 3041 times)

I made a script that allows me to plant bricks pretty much anywhere, including inside of each other.

It works because:
  • Badspot added the ability to change brick datablocks after they've been planted
  • I can make bricks that have no brick grid collision, so they can be placed inside of other bricks.
  • I can overwrite the servercmdplantbrick() function to allow for floating bricks.


For ease of use/coolness factor:
  • I made killBrick() delete the brick, to avoid chainkills
  • I made it give an overlap error if you plant the same exact brick in the same position, to avoid accidental doubleplanting :P


Here's a picture of a 16x cube, inside of a 32x cube, inside of a 64x cube, with some 4x cubes thrown in there as well.


And here's a download link:
v6 - Script_PlantAnywhere

Bad things/confirmed issues:   
The console is spammed with error messages on initial startup
No more cool animation when bricks are destroyed
Undo is broken      
No brickplant sound plays when planting
No brickkill sound plays when destroying a brick
Saving, then loading causes the bricks to load 1000 units higher than they should.
« Last Edit: September 11, 2017, 10:27:04 AM by Tendon »

since you increased the ground height, do loaded bricks spawn deep underground or did you also change the load offset?
and does saving and loading work with overlapping bricks?

Will try this out later but what happens when you use it then disable it and then load a save that used it?

since you increased the ground height, do loaded bricks spawn deep underground or did you also change the load offset?
and does saving and loading work with overlapping bricks?
The load offset changes temporarily while loading bricks.
Saving and- ... oh.  ok well loading works.
...  on to the bug list it goes.

Will try this out later but what happens when you use it then disable it and then load a save that used it?
The save will be 1000 units up, and any overlapping bricks will not load correctly.

Fixed everything except the startup console spam and the missing brickkill animation.
Saving and loading with the add-on enabled should work correctly.
« Last Edit: September 05, 2017, 05:51:11 PM by Tendon »

why not fakekill, then delete bricks when you killbrick(); something?

fxDtsBrick::KillBrick() is an engine function.

Aw, v3 breaks loading in general.  I don't want to pursue the offset anymore.  While loading the $loadoffset is "0 0 1000", but it doesn't affect where the bricks load for some reason, even when loading default builds.

The reason I added the offset was for coolness factor, and the fact that w/o it you can plant bricks only halfway into the ground.  Which is funky and not cool.

why not fakekill, then delete bricks when you killbrick(); something?
That's possible.  But as soon as .delete is called the brick is deleted, so it'd have to be on a delay.
So something like:
Code: [Select]
%brick.fakekillbrick(getRandom(1,2) SPC getrandom(1,2) SPC getRandom(1,2),1);
%brick.schedule(750,"delete");
Would work, but while it's being fakekilled, the brick would still technically exist.  So someone could hammer the brick multiple times while it's still there.  I could modify the hammer to bypass 'deleted' the brick, but I could not modify every other brick deletion tool.
If I could change the brick typemask and remove BrickAlwaysType form the brick while deleting it, it would work, but I don't think I can do that.

Another option would be to create a copy of the original brick, delete the original, and then run killbrick() on the unplanted copy.  Dunno if that plays the animation though.

I went with the brick copying route.
I also removed the offset stuff for v4.
« Last Edit: September 06, 2017, 09:00:06 PM by Tendon »

Just a quick FYI, there is a mod that Freek linked me back in December called Hackplant to plant floating bricks without them being removed with /clearfloatingbricks, but I see what you mean if you are trying to combine both not having to use modter and floating bricks for it.

i put the script in my addons folder but when i tried to put a modter in a modter, with different sizes, it didnt work

I think it is because they are "water" bricks

Just a quick FYI, there is a mod that Freek linked me back in December called Hackplant to plant floating bricks without them being removed with /clearfloatingbricks, but I see what you mean if you are trying to combine both not having to use modter and floating bricks for it.
Interesting.  It uses .isBaseplate to preserve the support system.
Maybe I could use that instead of overwriting killbrick();

i put the script in my addons folder but when i tried to put a modter in a modter, with different sizes, it didnt work
The version you have might not be working at all(syntax error :c).
I fixed the errors, and reuploaded v5.

found out why it didnt work for me, i didnt even turn it on