Solved Gravity

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

ShaneBee

Supporter +
Addon Developer
Sep 7, 2017
2,248
241
73
Vancouver, Canada
Suggested name: Gravity

What I want:
I want something written to be able to give gravity to grass/dirt just like sand/gravel. So when a player breaks a block under grass or dirt it will make them fall, just like sand/gravel
Ideas for commands:
none needed
Ideas for permissions:
none needed
When I'd like it by: no rush, but sometime soon would be nice.
 
code_language.skript:
on break:
    if block above event-block is dirt:
        set block above event-block to air
        spawn falling block of dirt at block above event-block
    if block above event-block is grass:
        set block above event-block to air
        spawn falling block of grass at block above event-block
    loop 255 - event-block's y-coord times:
        set {_block} to block at location at event-block's x-coord, event-block's y-coord + loop-number, event-block's z-coord
        if block below {_block} is air:
            if {_block} is dirt:
                set block at {_block} to air
                spawn falling block of dirt at {_block}
            if {_block} is grass:
                set block at {_block} to air
                spawn falling block of grass at {_block}

on place:
    if block below event-block is air:
        if event-block is dirt:
            set block at event-block to air
            spawn falling block of dirt at event-block
        if event-block is grass:
            set block at {_block} to air
            spawn falling block of grass at event-block
couldve been alot shorter but i had duplicate stuff for grass and dirt because i couldnt figure out how to make skquery's falling block syntax take the block as an itemtype
 
Thanks Donut, Ill give it a try.
[doublepost=1526167245,1526166931][/doublepost]Okay, I gave it a whirl. I actually wrote something that did just that, that was substantially shorter.. but here is the problem, it doesn't effect the blocks around it. Lets say there is a cave, and I break one dirt, it just makes the dirt above it fall and not beside.

I want to be able to do like a cave in. But when I wrote it to look blocks in a radius around the event block, it was making blocks fall that weren't touching the block i was breaking
 
followed u up til "it was making blocks fall that weren't touching the block i was breaking". that sounds like you want? if you want the whole cave to fall then it wouldnt be just the blocks touching the broken block
 
Man this is hard to explain. Ok, so here is my idea (well not my idea its from a plugin called extra hard mode)
Let me paint a picture, say you find the opening of a cave, and the roof of it is dirt. When you break the block, dirt above it will fall (as is already done) BUT... the dirt beside it, if air is under it, it would fall to (to lets say a distance of 7 - obviously too far would just cause a terrible chain reaction) .... if a dirt block within the distance of 7, did NOT have air under it, it would stop the chain reaction.

When I wrote it.... the chain reaction went past the blocks that had dirt under them. WOW this feels like its not making sense.... ok a visual

1 2 3 4 5 6 7 ... so you hit block 1, the blocks above it fall, now lets say there is air under 2 and 3, that would mean 2 and 3 would fall, but if there was stone under 4, then that would stop the reaction.
 
code_language.skript:
function gravify(bottomBlock: block):
    set block at {_bottomBlock} to air
    spawn falling block of dirt at {_bottomBlock}
    if block above {_bottomBlock} is dirt:
        set block above {_bottomBlock} to air
        spawn falling block of dirt at block above {_bottomBlock}
    if block above {_bottomBlock} is grass:
        set block above {_bottomBlock} to air
        spawn falling block of grass at block above {_bottomBlock}
    loop 255 - {_bottomBlock}'s y-coord times:
        set {_block} to block at location({_bottomBlock}'s x-coord, {_bottomBlock}'s y-coord + loop-number, {_bottomBlock}'s z-coord, {_bottomBlock}'s world)
        if block below {_block} is air:
            if {_block} is dirt:
                set block at {_block} to air
                spawn falling block of dirt at {_block}
            else if {_block} is grass:
                set block at {_block} to air
                spawn falling block of grass at {_block}
            else:
                stop
  
on break:
    loop blocks in radius 7 of event-block:
        if block below loop-block is air:
            if loop-block is dirt:
                gravify(loop-block)
            else if loop-block is grass:
                gravify(loop-block)
 
Thanks
I just had to step out for a while but i’ll give it a try when I return home.
[doublepost=1526246773,1526169645][/doublepost]Okay, so I tried out your latest one, and it didn't do what I was hoping. BUT... I racked my brain for a few hours and I think I have FINALLY made it work. Thank you for your help :emoji_slight_smile: