Checking if break-block is previous block

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

BrownMee

Active Member
Apr 16, 2018
126
6
18
23
Code:
on break:
    if event-block is oak wood log:
        set {_block} to event-block's location
        if {_block} is equal to event-block's location:
            send "s"

I want to check if the block i break is the same event block i previously break.
[doublepost=1586946499,1586904272][/doublepost]pls help !
[doublepost=1587019320][/doublepost]Anyone can give me a conclusion whether this is possible or not?
 
Code:
on break:
    if event-block is oak wood log:
        set {_block} to event-block's location
        if {_block} is equal to event-block's location:
            send "s"

I want to check if the block i break is the same event block i previously break.
[doublepost=1586946499,1586904272][/doublepost]pls help !
[doublepost=1587019320][/doublepost]Anyone can give me a conclusion whether this is possible or not?

yeah but depends: Is it about location or block specific? blocks can change location like with pistons or endermen moving them.

Also does it need to know the previous or all previous block?

It also would require some way of storage. Here a example if only location matters:


Code:
#Delete Data on reload of this script. Replace with 'on skript reload:' if u only want it to wipe data on server restart/reload.
on script load:
    delete {LastBrokenBlock::*}

on break:
    #First check if the location is equal.
    if {LastBrokenBlock::%uuid of player%} is location of event-block:
        send "&cU breaking multiple times on the same location :O."
    #Set a global variable for the player to current location so next time it compares with this value.
    set {LastBrokenBlock::%uuid of player%} to location of event-block
 
yeah but depends: Is it about location or block specific? blocks can change location like with pistons or endermen moving them.

Also does it need to know the previous or all previous block?

It also would require some way of storage. Here a example if only location matters:


Code:
#Delete Data on reload of this script. Replace with 'on skript reload:' if u only want it to wipe data on server restart/reload.
on script load:
    delete {LastBrokenBlock::*}

on break:
    #First check if the location is equal.
    if {LastBrokenBlock::%uuid of player%} is location of event-block:
        send "&cU breaking multiple times on the same location :O."
    #Set a global variable for the player to current location so next time it compares with this value.
    set {LastBrokenBlock::%uuid of player%} to location of event-block
It doesnt work. No errors.
I believe it set every new block player break to the variables.
[doublepost=1587091053,1587091021][/doublepost]
yeah but depends: Is it about location or block specific? blocks can change location like with pistons or endermen moving them.

Also does it need to know the previous or all previous block?

It also would require some way of storage. Here a example if only location matters:


Code:
#Delete Data on reload of this script. Replace with 'on skript reload:' if u only want it to wipe data on server restart/reload.
on script load:
    delete {LastBrokenBlock::*}

on break:
    #First check if the location is equal.
    if {LastBrokenBlock::%uuid of player%} is location of event-block:
        send "&cU breaking multiple times on the same location :O."
    #Set a global variable for the player to current location so next time it compares with this value.
    set {LastBrokenBlock::%uuid of player%} to location of event-block
Code:
on break:   
    if gamemode of player is survival:
        if event-block is oak wood bark or oak wood log:
            if name of player's tool contains "&a⛏ &7&lDiamond Axe &8150/150":
                cancel event
                set {daxe_} to 149
                set display name of held item to "&a⛏ &7&lDiamond Axe &8%{daxe_}%/150"
            if name of player's tool contains "&a⛏ &7&lDiamond Axe &8%{daxe_}%/150":
                cancel event
                set {wood.%player%} to location of event-block
                subtract 1 from {daxe_}
                set display name of held item to "&a⛏ &7&lDiamond Axe &8%{daxe_}%/150"
                if {wood.%player%} is location of event-block:
                    add 1 to {diamondaxe.%player%}
                {diamondaxe.%player%} is 1:
                    send player title "" with subtitle "&a&l⚒ Left: 1/4" for 5 seconds
                {diamondaxe.%player%} is 2:
                    send player title "" with subtitle "&a&l⚒ Left: 2/4" for 5 seconds
                {diamondaxe.%player%} is 3:
                    send player title "" with subtitle "&a&l⚒ Left: 3/4" for 5 seconds
                {diamondaxe.%player%} is 4:
                    if player has enough space for 1 diamond sword:
                        execute console command "mm items give %player% oakwood"
                    set {diamondaxe.%player%} to 0
                    play sound "PLAYER_LEVEL_UP" with volume 100 and pitch 1 at player for player
                    set event-block to air
 
Status
Not open for further replies.