Jump to content

Block Regeneration


Znyx

Recommended Posts

Block Regeneration to a RPG-Server.

Hello, I'm not very experienced in coding with skript so I would need some help with this.

  • When the block first is mined the code should cancel the event and replace the block with bedrock. + It should give the user the block that was mined.
  • It should then wait a few seconds: stone 30, coal, 1 minute, iron 2 minutes.
  • When the timer is up the block should get regenerated.

 


Please note that this should be for over 10 different blocks.
Here is what I first made:

on break coal ore:    
    if gamemode of player is survival:      
        wait 3 ticks
        set event-block to bedrock
        wait 60 seconds
        set event-block to stone               

on break stone:    
    if gamemode of player is survival:      
        wait 3 ticks
        set event-block to bedrock
        wait 30 seconds
        set event-block to stone

However that gets really big when there's a lot of blocks, so I then thought something like this might work:

options:
    Blacklist: Stone and Iron ore

lst = [("stone", 30), ("Iron Ore", 60)]

on break:
    if {@Blacklist} contains event-block:
        wait 3 ticks
        set event-block to bedrock
        wait lst[1] seconds
        set event-block to lst[0]

The problem with this is that I don't know if you can assign arrays with tuples, and then do array[1] on it.

If anyone knows how to solve this, or if they know an even better solution I would really appreciate it!

 

Link to comment
Share on other sites

this isn't how you create lists (or as you know, arrays) in skript. Additionally, you can't create lists in the "options" section (at least to my knowledge).

Here is what you can do:

on load:
    set {blockList::*} to stone, coal ore and iron ore
    set {timeList::*} to 30 seconds, 60 seconds and 120 seconds

on break:
    if {blockList::*} contains event-block:
        cancel event
        set {_block} to event-block
        set {_loc} to location at event-block
        give player {_block}
        set event-block to bedrock
        set {_size} to size of {blockList::*}
        loop {_size} times:
            set {_i} to loop-number
            if {blockList::%{_i}%} contains {_block}:
                wait {timeList::%{_i}%}
                set block at {_loc} to {_block}
                stop

I'm not sure if this is the most efficient way of doing this, but this should work. I used the skUnity parser and it didn't return any errors, so I think this works. Let me know if there are any problems!

Also, if this post helped you out, please leave a reaction! It means a lot to me!

  • Thanks 1

If I have helped you out in your post or you liked what I posted, please upvote and react to my post! It helps me a lot!

Some Minehut Links:

Server Rules • Staff Applications • News & Updates • Reports • Appeals


Minehut: VIP (07/04/2021 --> Current)
Elestra/Versa Realms: Manager (12/04/2021 --> Current)

If you have any questions contact me!
My Discord: BanditEagle#2481
My Spigot Profile: https://www.spigotmc.org/members/banditeagle.935281/
My IGN: BanditEagle

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...