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 our 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.

Loop Skript

Discussion in 'Skript' started by jackass, Jul 10, 2019.

  1. j

    jackass Member

    Joined:
    Nov 8, 2017
    Messages:
    16
    Likes Received:
    0
    Hello. I have been attempting to create a Sugar Cane Gen, in which on place of a dirt block, the skript will create layers of sugar cane and dirt on top of each other. The difficulty I am having, is that the purpose of the lines.

    if block loop-number above event-block is air:
    if block loop-number + 1 above event-block is air:
    if block loop-number + 2 above event-block is air:
    if block loop-number + 3 above event-block is air:

    are to make the skript stop when the gen hits any block other than air. The problem is that this skript is just going through the block and generating more layers above the block.

    What it does - https://gyazo.com/d2d848d14bbacca43c17750ecbaa2ddd
    What it should do - https://gyazo.com/85af677bfd423407441f7857838b5aaf


    Code (Text):
    1.  
    2. on place:
    3.     if name of held item is "&e&l*&f&l* &e&lCANE &F&LGEN &e&l*&f&l*":
    4.         wait 1 second
    5.         if event-block is dirt:
    6.             loop 20 times:
    7.                 if block loop-number above event-block's y-coordinate is more than 254:
    8.                     stop loop          
    9.                 else:
    10.                     if event-block is dirt:
    11.                         if block loop-number above event-block is air:
    12.                             if block loop-number + 1 above event-block is air:      
    13.                                 if block loop-number + 2 above event-block is air:
    14.                                     if block loop-number + 3 above event-block is air:                  
    15.                                         set block loop-number above event-block to sugar cane
    16.                                         set block loop-number + 1 above event-block to air
    17.                                         set block loop-number + 2 above event-block to air
    18.                                         set block loop-number + 3 above event-block to dirt
    19.                                         wait 1 second
    20.                                     else:
    21.                                         send "1" to player                                      
    22.                                         stop loop                                      
    23.                                 else:
    24.                                     send "2" to player                                  
    25.                                     stop loop                                  
    26.                             else:
    27.                                 send "3" to player                              
    28.                                 stop loop                  
    29.                         else:
    30.                             send "4" to player                      
    31.                             stop loop                  
    32.                     else:
    33.                         send "&8&l[&7&lF&c&lR&8&l] &aCane Gen &7Stopped!" to player                      
    34.                         stop loop
    35.         else:
    36.             send "&8&l[&7&lF&c&lR&8&l] &cCactus Gens &7Only Work In &cYour &7Faction's Land!" to player
    37.  
     
    #1 jackass, Jul 10, 2019
    Last edited: Jul 12, 2019
  2. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,202
    Likes Received:
    69
    Medals:
    Format your code
     
  3. j

    jackass Member

    Joined:
    Nov 8, 2017
    Messages:
    16
    Likes Received:
    0
  4. PatoFrango

    PatoFrango Well-Known Member

    Joined:
    Jul 12, 2017
    Messages:
    115
    Likes Received:
    10
    Could you send us a screenshot of how the "column" is supposed to look like please?
     
  5. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,202
    Likes Received:
    69
    Medals:
    Your code only stops the loop when the event-block is dirt, not when any of the other checks (`if block loop-num + ...)` return false. You will need to add a `continue` after waiting 1 second, and remove the `else:` (and fix indentation afterwards ofc) from the event-block = dirt check
     
  6. j

    jackass Member

    Joined:
    Nov 8, 2017
    Messages:
    16
    Likes Received:
    0
    What it does - https://gyazo.com/d2d848d14bbacca43c17750ecbaa2ddd
    What it should do - https://gyazo.com/85af677bfd423407441f7857838b5aaf

    --- Double Post Merged, Jul 12, 2019, Original Post Date: Jul 12, 2019 ---
    I have updated the code within the thread, now it seems to loop once successfully then sends 2 to the player (I number coordinated each step of the loop to see which part caused issues). I am not sure why this part of the loop would cause issues.
    --- Double Post Merged, Jul 13, 2019 ---
    Fixed the loop, started from scratch on the idea and it seemed to have fixed the problem, whatever it was.
     
Loading...