1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Gravity

Discussion in 'Requests' started by ShaneBee, May 12, 2018.

  1. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    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.
     
  2. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,336
    Likes Received:
    177
    Medals:
    Code (Skript):
    1. on break:
    2.     if block above event-block is dirt:
    3.         set block above event-block to air
    4.         spawn falling block of dirt at block above event-block
    5.     if block above event-block is grass:
    6.         set block above event-block to air
    7.         spawn falling block of grass at block above event-block
    8.     loop 255 - event-block's y-coord times:
    9.         set {_block} to block at location at event-block's x-coord, event-block's y-coord + loop-number, event-block's z-coord
    10.         if block below {_block} is air:
    11.             if {_block} is dirt:
    12.                 set block at {_block} to air
    13.                 spawn falling block of dirt at {_block}
    14.             if {_block} is grass:
    15.                 set block at {_block} to air
    16.                 spawn falling block of grass at {_block}
    17.  
    18. on place:
    19.     if block below event-block is air:
    20.         if event-block is dirt:
    21.             set block at event-block to air
    22.             spawn falling block of dirt at event-block
    23.         if event-block is grass:
    24.             set block at {_block} to air
    25.             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
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Thanks Donut, Ill give it a try.
    --- Double Post Merged, May 13, 2018, Original Post Date: May 13, 2018 ---
    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
     
  4. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,336
    Likes Received:
    177
    Medals:
    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
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    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.
     
  6. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,336
    Likes Received:
    177
    Medals:
    Code (Skript):
    1. function gravify(bottomBlock: block):
    2.     set block at {_bottomBlock} to air
    3.     spawn falling block of dirt at {_bottomBlock}
    4.     if block above {_bottomBlock} is dirt:
    5.         set block above {_bottomBlock} to air
    6.         spawn falling block of dirt at block above {_bottomBlock}
    7.     if block above {_bottomBlock} is grass:
    8.         set block above {_bottomBlock} to air
    9.         spawn falling block of grass at block above {_bottomBlock}
    10.     loop 255 - {_bottomBlock}'s y-coord times:
    11.         set {_block} to block at location({_bottomBlock}'s x-coord, {_bottomBlock}'s y-coord + loop-number, {_bottomBlock}'s z-coord, {_bottomBlock}'s world)
    12.         if block below {_block} is air:
    13.             if {_block} is dirt:
    14.                 set block at {_block} to air
    15.                 spawn falling block of dirt at {_block}
    16.             else if {_block} is grass:
    17.                 set block at {_block} to air
    18.                 spawn falling block of grass at {_block}
    19.             else:
    20.                 stop
    21.  
    22. on break:
    23.     loop blocks in radius 7 of event-block:
    24.         if block below loop-block is air:
    25.             if loop-block is dirt:
    26.                 gravify(loop-block)
    27.             else if loop-block is grass:
    28.                 gravify(loop-block)
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Thanks
    I just had to step out for a while but i’ll give it a try when I return home.
    --- Double Post Merged, May 13, 2018, Original Post Date: May 13, 2018 ---
    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:
     

Share This Page

Loading...