#Apparently I do not understand Loops

1 messages · Page 1 of 1 (latest)

calm timber
#

can someone help me with loops

basically it runs more than i want it to ultimately leading to it canceling either way

on place of yellow concrete:
    loop all blocks in radius 1 around event-block:
        if loop-block contains dead brain coral block:
            broadcast "a"
            stop
        if loop-block does not contain dead brain coral block:
            cancel event
            broadcast "b"
tawny sable
#

can you explain what you're trying to do

calm timber
#

make it check for one block instead of 3

#

it loops 3 times

#

ultimatly going to the second line even if its placed next to the brain coral

tawny sable
#

you want to check if the block is beside a specific block?

calm timber
#

pretty much, but how I am doing it right now always goes to the second one where it cancels

tawny sable
#
    loop all blocks in radius 1 around event-block:
        if loop-block is dead brain coral block:
            broadcast "a"
            stop
         else:
            cancel event
            broadcast "b"```
#

when you wrote "loop-block contains" i dont think you need to add "contains" you just specify what the loop-block is

calm timber
#

hm okay one sec

#

nope

#

even after i place it says in chat 3 x

tawny sable
#

what does it say A or B

calm timber
#

too fast of ss

#

one sec

#

both

tawny sable
#

oh i see what the problem is

#
    set {_blocks::*} to all blocks in radius 1 around event-block
    if {_blocks::*} contains dead brain coral block:
        broadcast "a"
        stop
     else:
        cancel event
        broadcast "b"```
#

when you loop the blocks in radius of event-block its not guaranteed that the first loop-block would be dead brain coral block

calm timber
#

oh

#

i get it

#

that stinks tho

tawny sable
#

?

calm timber
#

it being random stinks lol

tawny sable
#

yea

#

also i think you can simplify it

#

do you have SkQuery?

calm timber
#

nah

#

its fine lol