#(Moepius) How to find blocks in a radius proportionally to a given density/intensity

1 messages · Page 1 of 1 (latest)

vapid magnet
#

Hello, I am working on a script that let's players set some plants in a GUI with intensity (or density) and radius and then bonemeals them in the given radius. So bonemeal basically, but with settings.
This is the script so far: https://paste.denizenscript.com/View/109858
No errors, but a question. Since the players can set the radius where to search for blocks to grow plants on, the number of blocks that are found will vary greatly. The players can also set an intensity (how dense the plants will be placed).
My script uses a foreach: foreach <valid block(grass,dirt,etc.) in set radius and random number set by intensity> or - foreach <[found_blocks].random[<[intensity].add[<[found_blocks].size>]>]> as:block: to find the blocks where plants should be growing.

The problem is that I would like to set the density in which the plants are placed in dependence with the intensity, so that the ratio remains about the same. That is, at a high intensity, both at a large and a small radius proportionally many plants would be placed with about the same density. Does anyone have any ideas on how to solve this?

jovial radishBOT
#

(Moepius) How to make

jovial radishBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

vapid magnet
#

(Moepius) How to find blocks in a radius proportionally to a given density/intensity

cedar dock
#

<[found_blocks].random[<[intensity].add[<[found_blocks].size>]>]> will always max out, regardless of the intensity
lets say found_blocks is a list with 10 entries, and intensity is at 0. then, all you're doing is getting <list[10 entries here].random[10]> because of the <[found_blocks].size>. if found_blocks was 200 entries, it'd be .random[200]

what you probably want to do, is instead multiply <[found_blocks].size> by the intensity, as a percentage. so 100 * 10% or something

#

if you do that then yeah it'll always be the same ratio depending on your intensity. intensity 10%, 10% of blocks

#

if i misunderstood any core concept of what this should do then lmk

vapid magnet
#

yeah, this should do I think ... is there some tag to get a percentage or do I have to math it manually?

#

Have to try it out though

cedar dock
#

multiply intensity by 0.01, so for example 100 turns into 1 and 10 turns into 0.1
that's your percentage, 100 * 10% is the same thing as 100 * 0.1

#

uh, if your percentage isnt base 10 you'll need to do cross multiplication (easiest method i know of), i have a proc for that if you want it

cedar dock
# vapid magnet That would be nice
cross_multiplication:
    type: procedure
    definitions: arg|arg2|arg3
    debug: false
    script:
    ############################
    ##                        ##
    ##     1            2     ##
    ##                        ##
    ##     3            x     ##
    ##                        ##
    ############################
    # <proc[cross_multiplication].context[1|2|3]>
    - define mul <[arg2].mul[<[arg3]>]>
    - determine <[mul].div[<[arg]>]>

uhh logic goes if 1 = 2 then 3 = x
applying that, if 2 = 4, then 5 = 10

terse cobalt
#

divide by 100 lol

#

15% = 0.15

cedar dock
#

thats 100 not 10, and i meant in case his intensity is like, from 5 to 31 or something, and not clean like from 1 to 10

gleaming nymph
cedar dock
#

thanks for condensing when i couldnt 😭

gleaming nymph
#

if you write it in real numbers you can think about the tags easier, that helps me a lot

vapid magnet
#

okay, I will rewrite that tag and see how it turns out

vapid magnet
#

This works better:
- foreach <[found_blocks].random[<[found_blocks].size.mul[0.<[intensity]>].round_down>]> as:block:

#

Des the "find_blocks" tag have any upper limit for the radius within it can search? I set my radius between 10 to 60 ... but when trying it with 70 and above it won't place any plants

cedar dock
#

the tag itself no it doesnt, your server though yes
searching above 100 starts to become really slow

#

70 and above it won't place any plants
debug

vapid magnet
# cedar dock > 70 and above it won't place any plants debug
#

smh the list of blocks to place on will be empty with radius 80

#

I want radius between 10 to 100 and intensity any scale from almost no plants to almost every block filled with plants .. right now intensity 1 = less plants but still many and 7 almost every block has a plant on it

gleaming nymph
#

the chunks must be loaded for that tag to work

vapid magnet
gleaming nymph
#

what's your simulation distance?

topaz oyster
#

Why not have the intensity be 0 -> 1? 0 being 0% and 1 being 100%. Then you can just use <util.random_chance[<percent>]> to determine whether a block should be placed there or not.

#

There's no need for the intensity to be tied to the size.

vapid magnet
vapid magnet
vapid magnet
vapid magnet
vapid magnet
#

I have another related question:
I also want to let the players decide how the selected plants are distributed. Worldedit has a feature with patterns where you can write something like this: //set 20%grass,40%tall_grass,10%brown_mushroom ... In my GUI players have 5 slots to set plants there. Each of these slots should get an own adjustable distribution, besides the general intensity. Example: in slot 1 there is grass, in slot 2 tall grass, in slot 3 fern, in the last two slots nothing. Grass has intensity 100, tall grass and fern intensity 50 ... when planting, this should mean that at intensity 100 the block is set normally, at a lower number the block is skipped with the corresponding probability and replaced by another one. So that, for example, grass is represented most often and fern and tall grass about half as often.

How can I proceed here?

#

The important part is that the skipped plants do not leave empty blocks without plants (which is already set with the general intensity), but there is a chance that they will be replaced by another plant depending on the respective intensities set.

#

Currently, one of the SLots is simply selected at random.
`- define plant <[player].flag[player.commands.duenger.items_selected].values.exclude[duenger_leer].random>

  • modifyblock <[block].above> <[plant]> no_physics`

The selection should still happen randomly but with the set intensity of the slot as an additional factor. Where 100 = unchanged and everything below 100 means a reduced chance or a chance to be replaced by a plant of another slot.

karmic pelicanBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@vapid magnet

#
Resolved

Thread closed as resolved.

karmic pelicanBOT
#
Thread Reopened

Thread was manually reopened by @shrewd aurora.