1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Loop blocks not working

Discussion in 'Skript' started by Aidanete, Aug 15, 2018.

Thread Status:
Not open for further replies.
  1. Aidanete

    Aidanete Well-Known Member

    Joined:
    Apr 11, 2017
    Messages:
    139
    Likes Received:
    9
    I'm trying to save blocks as an arena, but it doesn't works
    Code (Skript):
    1. command /save [<text>]:
    2.     trigger:
    3.         loop blocks from {hpos1::%player%} to {hpos2::%player%}:
    4.             wait 1 tick
    5.             set {arenastorage::%arg 1%::%loop-block%} to location of loop-block
    6.             add 1 to {_savedblocks}
    7.         message "{@Prefix} <gray>Arena saved with a total of %{_savedblocks}% blocks saved"
    The command will show the message below as it don't saved any block.
    The Hpos are setted here:
    Code (Skript):
    1. on rightclick:
    2.     player's tool is a golden axe:
    3.         set {hpos2::%player%} to location of targeted block
    4. on leftclick:
    5.     player's tool is a golden axe:
    6.         cancel event
    7.         set {hpos1::%player%} to location of targeted block
    HELP!

     
  2. Best Answer:
    Post #8 by ShaneBee, Aug 15, 2018
  3. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    180
    SkQuery has a CUBOID SYNTAX. you could try:
    Code (Skript):
    1. loop blocks within {hpos1::%player%} to {hpos2::%player%}:
     
  4. Aidanete

    Aidanete Well-Known Member

    Joined:
    Apr 11, 2017
    Messages:
    139
    Likes Received:
    9
    Okay, but how I load it?
    Code (Skript):
    1. command /load [<text>]:
    2.     trigger:
    3.         loop {arenastorage::%arg 1%::*}:
    4.             wait 1 tick
    5.             set the block at loop-value to loop-index parsed as a block
    6.         message "{@Prefix} <gray>Arena reloaded [Debug]"
     
  5. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    180
    I guess you could try that. Ive never done it this way, i have only every used world guard/world edit
     
  6. Aidanete

    Aidanete Well-Known Member

    Joined:
    Apr 11, 2017
    Messages:
    139
    Likes Received:
    9
    @ShaneBee No, that code shows up an error:
    Code (Skript):
    1. A block can't be set to loop-index because the latter is not an item type
    How do I fix that?

    The parsed as a block don't work, and without it the error log is the above one
     
  7. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    180
    try parsing it as an item type
     
  8. Aidanete

    Aidanete Well-Known Member

    Joined:
    Apr 11, 2017
    Messages:
    139
    Likes Received:
    9
    Don't log any error, but seems not working, it don't load the blocks
     
  9. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    180
    I actually have no idea. I have never used the cuboids, but IM going to fire up a test server and see if i can figure it out!
    --- Double Post Merged, Aug 15, 2018, Original Post Date: Aug 15, 2018 ---
    Okay, I did a little re-write and made this work:
    Code (Skript):
    1. command /save [<text>]:
    2.     trigger:
    3.         loop blocks within {hpos1::%player%} to {hpos2::%player%}:
    4.             set {arenastorage::block::%arg 1%::%loop-block%} to type of loop-block
    5.             set {arenastorage::loc::%arg 1%::%loop-block%} to location of loop-block
    6.             add 1 to {_savedblocks}
    7.         message "{@prefix} <gray>Arena saved with a total of %{_savedblocks}% blocks saved"
    8.  
    9. command /load [<text>]:
    10.     trigger:
    11.         loop {arenastorage::loc::%arg 1%::*}:
    12.             if block at {arenastorage::loc::%arg 1%::%loop-index%} is not {arenastorage::block::%arg 1%::%loop-index%}:
    13.                 set block at {arenastorage::loc::%arg 1%::%loop-index%} to {arenastorage::block::%arg 1%::%loop-index%}
    14.                 wait 1 tick
    15.         message "{@prefix} <gray>Arena reloaded [Debug]"
     
    • Winner Winner x 1
Thread Status:
Not open for further replies.
Loading...