Author Topic: Rain Blocking Script  (Read 5340 times)

this thing is really bad on framerate dude. i'd recommend you only block on large bricks, things that would make up a roof.

there's no need to be checking every plate on the map

You could just use fxDTSBrick's 'getUpBrick(<index>)' method to detect if there is a brick above that brick, and if there isn't, then add a physical zone to the brick. However, if there is a brick above it, it would just keep going up the chain until it finds an end point.

And use fxDTSBrick's 'onPlant()' and 'onRemove()' methods to recalculate physical zones near the planted brick (so you don't have to re-calculate every brick on the server; only the ones near the affected brick).

The method above does cause several problems to arise, including breaking a brick chain by putting a hole in a wall of 1x1s (consequently making the chain stop at the hole and allowing rain to go through the top of the original chain), and the amount of calculation if you have a bunch of bricks in the server.

Sorry if I'm not making a whole lot of sense; I came up with this method on the spot, and I haven't had enough time to think it out entirely. Just wanted to put it out there to let someone build off of it. Hope it still somewhat helps you with optimizing this add-on, though.
« Last Edit: November 23, 2016, 11:41:05 PM by RTBARCHIVE »

You could just use fxDTSBrick's 'getUpBrick(<index>)' method to detect if there is a brick above that brick, and if there isn't, then add a physical zone to the brick. However, if there is a brick above it, it would just keep going up the chain until it finds an end point.
If it's finding only the top bricks, wouldn't a normal roof only have rain blocking on the very apex of the roof?

If it's finding only the top bricks, wouldn't a normal roof only have rain blocking on the very apex of the roof?
This add-on spawns a physical zone for every brick (including ones that are not exposed), including non-roof surfaces (like a stack of 1x1 bricks or something like that).  So, this will just help compensate with the bad FPS with a big build. Like I said, this is not a bulletproof method of doing this.
Or, I could be misunderstanding you.
« Last Edit: November 23, 2016, 11:58:35 PM by RTBARCHIVE »

This add-on spawns a physical zone for every brick (including ones that are not exposed), including non-roof surfaces (like a stack of 1x1 bricks or something like that).  So, this will just help compensate with the bad FPS with a big build. Like I said, this is not a bulletproof method of doing this.
Or, I could be misunderstanding you.
I'm just saying that I don't think what you suggested would work

I'm just saying that I don't think what you suggested would work

He clearly explained that repeatedly doing getUpBrick() would end up on a topmost brick which is the only one that needs to block rain and then nothing else.

So, I'd say it would work. Maybe not for snow if it doesn't go straight down though.

Pretty sure what Darryl means is if it keeps checking for bricks above other bricks, it'd eventually stop at the highest point of a roof and completely disregard the rest of the roof. What RTB posted would work for a flat roof but not for anyone with a slant or multiple elevations.

Okay, so big problem.

If you break a brick with a hammer or a wand, the rain blocking script still blocks the rain, even if the brick is gone. This is only fixed if you do a /clearallbricks

I found a bit of an issue, if the bricks are high enough, than the rain just falls through the bricks anyway.
In Blockland rain only falls from a certain height above you.
In the case of the default rainy sky:
numDrops: 1800
boxWidth: 80
boxHeight: 50
doCollision: 1

In addition, if a zone is not rendered, rain will fall straight through it.  So if you aren't looking at it, rain will still fall straight through. (An exception to this is bricks that are really close to you.)

If you break a brick with a hammer or a wand, the rain blocking script still blocks the rain, even if the brick is gone. This is only fixed if you do a /clearallbricks
This may happen for a few seconds until the brick has finished it's breaking animation.  If it still isn't working, I suggest doing a trace while breaking a brick and posting the results here.  The trace must have "onRemove" in it to be of any use.

Pretty sure what Darryl means is if it keeps checking for bricks above other bricks, it'd eventually stop at the highest point of a roof and completely disregard the rest of the roof. What RTB posted would work for a flat roof but not for anyone with a slant or multiple elevations.
Correct.  getUpBrick() is for brick support.  If you had a set of stairs, it would put a physical zone on the top stair, ignoring the rest.

Attached is a version which lets you set a minimum size for blocking rain.

Usage: /setbrickumbrellasminsize
  • [y] [z]

x y and z are measured in 1x1 plates.
Anything smaller than the minimum in all three measurements will not block rain.

Though really, I'm not interested in making this mod super efficient.  If anyone else wants to try it- go right ahead.