Break torches in rain

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

ShaneBee

Supporter +
Addon Developer
Sep 7, 2017
2,247
241
73
Vancouver, Canada
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
 
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
 
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
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.
 
are you continuously looping until the rain ends or just once when it starts? you dont need to loop the blocks above the torch just use https://skriptlang.github.io/Skript/expressions.html#ExprHighestSolidBlock
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)
 
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
 
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
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.
 
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
 
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
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.
 
you wont catch it in the started loop, for example run /test2 after /test
code_language.skript:
command /test:
    trigger:
        set {test::*} to 1, 2, and 3
        loop {test::*}:
            wait 3 seconds
            broadcast "%loop-value%"

command /test2:
    trigger:
        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
 
you wont catch it in the started loop, for example run /test2 after /test
code_language.skript:
command /test:
    trigger:
        set {test::*} to 1, 2, and 3
        loop {test::*}:
            wait 3 seconds
            broadcast "%loop-value%"

command /test2:
    trigger:
        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
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*