block break event with custom 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.

FallingCatus

Member
Jun 29, 2017
38
0
6
33
can someone tell me what i am doing wrong here? its not cancelling the event and is dropping the default block. I feel i am missing something simple here.

thanks
Code:
options:
    block: light gray glazed terracotta
    name: "&b&lGravity Generator"
    lore: "&7This item restores earth like gravity."

on block place of {@block}:
    if the 1st line of the tool's lore is {@lore}:
        send "&dCosmic &8» &b&lGravity Generator &7has been placed." to player
        stop

on block break of {@block}:
    if the 1st line of the tool's lore is {@lore}:
        cancel event
        set event-block to air
        wait 3 tick
        give player 1 {@block} named {@name} with lore {@lore}
        send "&dCosmic &8» &b&lGravity Generator &7has been removed." to player
        stop
    if the 1st line of the tool's lore is not {@lore}:
        stop


I am guessing its soemthing to do with storing block info, maybe like NBT but looking around a cant seem to find any real docs on it.
any help will be awesome!
 
I replied to your discord message just going to paste it here:

Seems to be working fine for me, except I just replaced the block you are using to dirt as I'm running 1.8 skript. In this case it might be the block you are using I'd recommend changing the block and seeing if it still does the same.
 
I replied to your discord message just going to paste it here:

Seems to be working fine for me, except I just replaced the block you are using to dirt as I'm running 1.8 skript. In this case it might be the block you are using I'd recommend changing the block and seeing if it still does the same.
intresting, will check now
[doublepost=1553384888,1553384721][/doublepost]
I replied to your discord message just going to paste it here:

Seems to be working fine for me, except I just replaced the block you are using to dirt as I'm running 1.8 skript. In this case it might be the block you are using I'd recommend changing the block and seeing if it still does the same.

Just tried with dirt block and same issue, drops and dirt block with default name and lore and did not run the "give player 1 {@block} named {@name} with lore {@lore}"
 
Oh, yeah I made a mistake didn't realise you was asking why it wasn't cancelling the event if the name and lore wasn't correct. It's late and totally my fault.

Explanation on why it doesn't work:
You missed the "cancel event" bit from line 19 on. You only included a "stop" meaning it just stops the code if you want it to stop the event always add "cancel event", then after that put "stop" after stopping the code.

Fixed code:
Code:
options:
    block: light gray glazed terracotta
    name: "&b&lGravity Generator"
    lore: "&7This item restores earth like gravity."
 
on block place of {@block}:
    if the 1st line of the tool's lore is {@lore}:
        send "&dCosmic &8» &b&lGravity Generator &7has been placed." to player
        stop
 
on block break of {@block}:
    if the 1st line of the tool's lore is {@lore}:
        cancel event
        set event-block to air
        wait 3 tick
        give player 1 {@block} named {@name} with lore {@lore}
        send "&dCosmic &8» &b&lGravity Generator &7has been removed." to player
        stop
    if the 1st line of the tool's lore is not {@lore}:
        cancel event
        stop
 
Status
Not open for further replies.