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.

Problem With Variables

Discussion in 'Skript' started by commandmaker, Jul 7, 2019.

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

    commandmaker New Member

    Joined:
    May 27, 2019
    Messages:
    7
    Likes Received:
    0
    i am trying to recreate parts of skyfactory like silkworms and i have tried to do it but i can't get it to work properly

    Code (Text):
    1. on right click:
    2.     if {Running} is equal to 1:
    3.         if targeted block is oak leaves:
    4.             if distance between targeted block and player is less than or equal to 5:
    5.                 set {SilkStage::%targeted block's position%} to 1
    6.  
    7. on script load:
    8.     while {Running} is equal to 1:
    9.         wait 1 tick
    10.         loop {SilkStage::*}:
    11.             if {SilkStage::%loop-value%} is greater or equal to 500:
    12.                 set block at loop-value to bedrock
    13.                 delete {SilkStage::%loop-value%}
    14.             else:
    15.                 add 1 to {SilkStage::%loop-value%}
    thanks for any help fixing it
     
  2. TPGamesNL

    Moderator Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    108
    Medals:
    You have to use `loop-index` for the index
     
  3. commandmaker

    commandmaker New Member

    Joined:
    May 27, 2019
    Messages:
    7
    Likes Received:
    0
    why do i need the index?
     
  4. TPGamesNL

    Moderator Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    108
    Medals:
    Because `{SilkStage::%loop-value%}` will most likely not exist, whereas `{SilkStage::%loop-index%}` will definitely exist.
     
  5. commandmaker

    commandmaker New Member

    Joined:
    May 27, 2019
    Messages:
    7
    Likes Received:
    0
    but it's fine if it doesn't exist because then it just won't do anything i thought
    also can you put changes in it?
     
  6. TPGamesNL

    Moderator Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    108
    Medals:
    No I won't fix your code. Use loop-index, not loop-value.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...