TreesFall

  • 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!

RaikaS

Active Member
Apr 6, 2018
53
1
0
20
Category:
Misc?
Suggested name: TreesFall

What I want:
When player breaks a log block, and above it is more wood, wood above falls (even brushwoods)
Ideas for commands:
No cmds.
Ideas for permissions:
No perm.
When I'd like it by: In few days
 
Like this?
code_language.skript:
on break:
    event-block is log
    loop blocks above event-block:
        location of loop-block is not location of event-block
        if loop-block is log:
            if gamemode of player is survival:
                drop loop-block at loop-block
            set block at loop-block to air
            wait 1 tick
        else:
            exit loop
 
Ah man TPGames beat me to it.... Anyways mines a bit different, mine won't drop the blocks, the logs themselves will FALL.
2 add-ons required, SkQuery (For the falling blocks) and Skript-Mirror(to make the falling blocks hurt the player if it lands on them)
SkQuery is a must, but if you dont want to use Skript-Mirror you can remove lines 4-7 and line 18
code_language.skript:
#This requires Skript-Mirror.... for some reason the falling blocks DO NOT hurt players, so this makes sure to hurt them.
#If you dont want to use Skript-mirror remove lines 4-7 and 18

effect make %entities% hurt entities:
  trigger:
    loop expressions 1:
      loop-value.setHurtEntities(true);

#Functions for Gravify and Chain reactions
function gravify(b: block):
    wait 1 tick
    set {_b2} to block 10 above {_b}
    loop blocks between {_b} and {_b2}:
        if loop-block is any log block:
            set {_block} to loop-block
            spawn falling block of {_block} at location 0.5 below loop-block
            set loop-block to air
            make the last spawned entity hurt entities
            wait 2 ticks
                  
function chain(b: block, n: number):
    wait 1 tick
    if {_n} is less than 20:
        add 1 to {_n}
        loop blocks in radius 2 around {_b}:
            if loop-block is any log block:
                if block below loop-block is air or any leaves:
                    set block below loop-block to air
                    chain(loop-block,{_n})
                    gravify(loop-block)
                    wait 1 tick
                  
#when a player breaks any log block block, it'll check for logs around it, and make them GRAVIFY
on break:
    if gamemode of player is survival:
        if event-block is any log block:
            chain(event-block, 0)
[doublepost=1533463224,1533463145][/doublepost]Warning, its not exactly perfect... sometimes the branches in big trees won't fall, but it kind of gives it a little more realism.
I wrote this before for myself, but I had to update it to work properly with big trees.
 
Oh for some reasons I didn't read the falling part. Or I thought you meant destroy or something. Well maybe you can add my dropping block part if you want it? (idk i'm just trying to actually do something for this script :emoji_grinning:)