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!

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

Break torches in rain

Discussion in 'Requests' started by ShaneBee, Sep 25, 2018.

  1. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Category: Environment?!?!

    Suggested name: No name required, part of another skript

    What I want:
    So working on my ExtraHardMode skript, one of the things I need done is when it rains, torches need to break when they are exposed to rain. Im trying to think of a more efficient way to do this.
    So far, what I have is when you place a torch it saves a variable, and when the rain starts, it loops these variables, loops the blocks above them, if they are air (exposed to rain) they break, if there is any other block above them they dont break. Now obviously with a LOT of players on the server, placing numerous amounts of torches, this will turn into a LLOTTTTT of loops, which makes this extremely inefficient. I'm open to ideas on ways to create a more efficient system, so lets here what you guys have to offer!


    Ideas for commands:
    None

    Ideas for permissions:
    None

    When I'd like it by: Not in a serious rush, but would be nice to get this in the next week or two
     
  2. DeahtstrokeSW

    DeahtstrokeSW New Member

    Joined:
    Mar 13, 2017
    Messages:
    7
    Likes Received:
    0
    This is just an idea (Not tested)

    Loop players and then search for torches in a chunk around the player.
    Then make your check loop for figuring out if it rains.

    Im not sure if it would reduce the amount of loops but you can give it a try
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    I considered that. The only problem is i want it to go a fair distance. If I were to do a distance of say 3 chunks that would be a crap ton of blocks to loop.
     
  4. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    OO i did not know about that expression... Thanks!

    Basically the way it works right now is as soon as the weather changes, it loops the list of torches. Each torch it loops the blocks above (will be changing that), if its all air, and its still raining, breaks the torch and moves onto the next, if the rain has stopped by the time it reaches this torch the effect stops (making sure it doesn't keep trying to loop thru the rest of the list if the weather is clear)
     
  6. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    so you are looping through the torches only once? i dont think that should be too much of a problem then. but btw if someone places a torch after the rain starts then it wont break because you only loop the torches when it starts raining
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    1) Correct... but also remember, lets pretend we have 20 players, and throughout the day they place an entire stack of torches (mining and such) that night it rains, none of those torches get broken, as well as their variables never gets deleted. The next day placing more and more torches. The variables add up, thats what scares me. I just dont want an obscene amount of torch variables.
    I considered having it, so if during the loop theres a solid block above it, it would delete the variable so that the next time it loops (next rain storm) it wouldn't loop thru that torch. Only problem there is what if someone catches on (unlikely) and figures out they can remove the block above the torch (still unlikely but you never know)

    2) I have a second mechanic set up so if someone places a torch DURING a rainstorm, after 2 seconds it'll break and therefor never sets a variable and never ends up in the loop.
     
  8. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    in regards to #2 what if they place it under a block? even if you check if they place it under a block then they could still place it under a block then remove the block above it
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    If they place during a rainstorm, FIRST it checks for blocks above
    if block above, it places fine and dandy, sets the variable
    if no block above, does not set the variable, wait 2 seconds break naturally

    IF they removed the block, and the loop has already started, maybe we will get lucky and the loop will catch that block. IF NOT then I guess it'll catch on the next rainstorm.
     
  10. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    you wont catch it in the started loop, for example run /test2 after /test
    Code (Skript):
    1. command /test:
    2.     trigger:
    3.         set {test::*} to 1, 2, and 3
    4.         loop {test::*}:
    5.             wait 3 seconds
    6.             broadcast "%loop-value%"
    7.  
    8. command /test2:
    9.     trigger:
    10.         add 4 to {test::*}
    so like you said it will stay until the next rain which is what i was pointing out if you care about that
     
  11. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    231
    Ahh... that I was not aware of, I thought it would loop just whatever happened to be in there. So that is good to know.
    And no, not terribly worried if it doesn't catch it during that rainstorm. 99% chance the player's will never actually catch on to the backbone of how the rain/torch system works. *Fingers crossed*
     

Share This Page

Loading...