Solved Piston Block Move

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

    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.
code_language.skript:
on piston extend:
    broadcast "all blocks moved: %moved blocks%"
    broadcast "block directly next to piston: %first element of moved blocks%"
 
code_language.skript:
on piston extend:
    broadcast "all blocks moved: %moved blocks%"
    broadcast "block directly next to piston: %first element of moved blocks%"
How would I check the previous block at the location to the new block at the location? I have varables saved to blocks and want them moved over with the piston event
 
like this
code_language.skript:
on piston extend:
    loop moved blocks:
        set {_loc} to loop-value's location
        broadcast "[old location of %loop-value%] %{_loc}%"

        set {_loc} to {_loc} ~ normalize vector from event-block to loop-value
        broadcast "[new location of %loop-value%] %{_loc}%"
 
I got this working with the above code here is a finished example for those who want to properly check the before and after location on a block from piston extend and retract

code_language.skript:
piston extend:
  loop moved blocks:
    set {_loc} to loop-value's location
    broadcast "[old location of %loop-value%] %{_loc}%"
    set {_loc} to {_loc} ~ normalize vector from event-block to loop-value
    broadcast "[new location of %loop-value%] %{_loc}%"
    add {_loc} to {_blocks::*}
  wait 2 ticks
  loop {_blocks::*}:
    set block at loop-value to stone
piston retract:
  loop moved blocks:
    set {_loc} to loop-value's location
    broadcast "[old location of %loop-value%] %{_loc}%"
    set {_loc} to {_loc} ~ normalize vector from loop-value to event-block
    broadcast "[new location of %loop-value%] %{_loc}%"
    add {_loc} to {_blocks::*}
  wait 2 ticks
  loop {_blocks::*}:
    set block at loop-value to dirt

The retract sets it to dirt and the extend sets it to stone so you can see the results live
ezgif.com-video-to-gif.gif
 
Last edited:
Status
Not open for further replies.