Solved Getting previous state of a 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.

Tilomi

New Member
Mar 7, 2017
7
1
3
23
Hi!
While making this skript, I've run in to an annoying problem. My skript loops blocks in radius 1 when right clicked with a diamond hoe. Then sets the loop-block to diamond block. After one second it should set the loop-block back into the original loop-block (including the facing, location etc.)

This skript doesn't work because the loop-block added to {_loopblocks::*} is linked to the actual loop-block and as it changes, so changes the loop-block stored in the variable. I've tried lot of approaches to this, but so far nothing has worked.

So... Is there a good way of doing this?

code_language.skript:
on right click holding diamond hoe:
    loop blocks in radius 1 of clicked block:
        add loop-block to {_loopblocks::*}
        set loop-block to diamond block
      
    wait 1 seconds
    loop {_loopblocks::*}:
        set block at loop-value to loop-value

Thanks.
 
Try:
code_language.skript:
on right click holding diamond hoe:
    loop blocks in radius 1 of clicked block:
        add loop-block's location to {_locations::*}
        add loop-block's type to {_types::*}
        set loop-block to diamond block

    wait 1 second
    loop {_locations::*}:
        set block at loc loop-value to {_types::%loop-index%}

I haven't tested this, you might have to tweak it, but it will work!
 
Try:
code_language.skript:
on right click holding diamond hoe:
    loop blocks in radius 1 of clicked block:
        add loop-block's location to {_locations::*}
        add loop-block's type to {_types::*}
        set loop-block to diamond block

    wait 1 second
    loop {_locations::*}:
        set block at loc loop-value to {_types::%loop-index%}

I haven't tested this, you might have to tweak it, but it will work!

Your skript works great! You just need to remove the "loc" from the last line. Many thanks!
 
  • Like
Reactions: jaylawl
I'm glad it works!
You should take precautions about which blocks get converted though. Because with this script, tile-entities will not be saved correctly. For example, if a placed player head is changed with your diamond hoe, it will lose all it's NBT data when it's placed back - so make sure it's not converted to a diamond block
 
  • Like
Reactions: Tilomi
I'm glad it works!
You should take precautions about which blocks get converted though. Because with this script, tile-entities will not be saved correctly. For example, if a placed player head is changed with your diamond hoe, it will lose all it's NBT data when it's placed back - so make sure it's not converted to a diamond block

Yeah, I noticed that but for me that doesn't matter since I'll be changing just specific kind of blocks :emoji_slight_smile:
 
Status
Not open for further replies.