1. NOTE: These forums are no longer used. Please use Discord instead.

[Request/Help] Replace blocks only next to other specified block(s)

Discussion in 'CraftScripts' started by RootPC, Aug 3, 2016.

  1. RootPC

    RootPC New Member

    Hello. I need a script that will change a specific block if it is next to another specified block (eg. on a mountain, if dirt is next to air, replace all those dirt blocks to specified block). That's basically all that needs to happen. Thanks for reading, and hope this isn't hard at all.
  2. wizjany

    wizjany Administrator Developer

    why do you need a script? you can just use a mask for this.
  3. RootPC

    RootPC New Member

    Based on looking at the mask command, it only supports "Above" and "Below", not next to (same layer on the X axis) the block, which is what I'm trying to do.

    At least, according to http://wiki.sk89q.com/wiki/WorldEdit/Masks not sure if it has changed since that page was last modified

    Also, brushes go in 2 blocks, I only want it to affect blocks that are out "in the open" so to speak
    Last edited: Aug 3, 2016
  4. wizjany

    wizjany Administrator Developer

    Expression masks work, so you can use the queryRel function:
    //gmask =queryRel(1,0,0,1,0)
    will match any block with stone next to it in the +x direction. you can chain these with logical operators as per http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax to get more complicated things.

    Not sure what you mean by "brushes go in 2 blocks" though. Size is configurable.
  5. RootPC

    RootPC New Member

    I tried doing what you suggested, but it wouldn't work for me... I made a video to better explain what needs to happen... Hope you can point me in the right direction.

  6. wizjany

    wizjany Administrator Developer

    ...what are all those blocks surrounding the grass/dirt?

    edit: oh that's actually grass in your texture pack.

    yes, a radius one sphere looks like that. if you only want to set a single block, you need to specify a radius < .5, e.g. //br sphere grass .4
  7. RootPC

    RootPC New Member

    Not to be annoying, but essentially what "//br s grass .4" would do is what "//repl grass" does but at a distance... We kinda want it to be done in bulk with a region selected :S sorry if I'm being difficult haha
  8. wizjany

    wizjany Administrator Developer

    i don't see what the problem is then. just use the mask with a larger brush.
  9. RootPC

    RootPC New Member

    We tried your gmask example, but even that fails, tells us "0 blocks affected". We've tried tweaking your example to see if we can get it to work for the past 3 hours or so, and we haven't been able to get it to work.


    Got it to work. We were still in 6.1.1SNAPSHOT - 6.1.3 (on my test server). Updated to 6.1.4SNAPSHOT (3582) and it worked. http://builds.enginehub.org/job/worldedit/9243
    Last edited: Aug 4, 2016
  10. WizardCM

    WizardCM New Member

    For anyone reading this later, our issue was caused by a bug fixed in the above linked WorldEdit version.

    Resulting commands are:

    Code (Text):

    //gmask =queryRel(1,0,0,0,0)||queryRel(0,0,1,0,0)||queryRel(0,0,-1,0,0)||queryRel(-1,0,0,0,0)

    //replace dirt grass
  11. wizjany

    wizjany Administrator Developer

    oh yea sorry, totally forgot that i fixed that bug since the last release.
    WizardCM and RootPC like this.