Solved loop between 2 locations

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

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

FlamForEver

Member
Aug 10, 2023
24
0
1
hy, this skript doesn't work, because don't understand the loop. this is the skript and the error:


on right click on a sign:
if line 1 of event-block is "&8==========":
if line 2 of event-block is "&8[&6&lCancello Podio&8]":
if line 3 of event-block is "&f - &7&lChiudere &f-":
if player has permission "re.use" or "guardiare.use":
set {location.close} to player's location
send "&7Stai per chiudere il cancello, attendi &75&a secondi..." to player
wait 5 seconds
make console execute command "//set %{_pos1}% %{_pos2}% 35:4"
set {_loc1} to location at -1351, 173, and -267 in world "world"
set {_loc2} to location at 1342, 164, and -267 in world "world"
loop all blocks between {_loc1} and {_loc2}:
set loop-block to yellow wool

error:

Can't understand this loop: 'loop all blocks between {_loc1} and {_loc2}' (lucky.sk, line 950: loop all blocks between {_loc1} and {_loc2}:')
 
There is a fix to this. The one I will send might not be right, but regardless:

Code:
loop all blocks:
    if %loop-block% is in between {loc1} and {loc2}:
        set %loop-block% to yellow wool

Also btw, I don't think you know the difference between a local and global variable.

A local variable is only mean to be called in one function, and it would look like {_variable}.

A global variable can be recognized anywhere, and would look like {variable}.

One of your problems is that you are using a local variable instead of a global variable. Basically, the code would look like this:

Code:
on right click on a sign:
    if line 1 of event-block is "&8==========":
        if line 2 of event-block is "&8[&6&lCancello Podio&8]":
            if line 3 of event-block is "&f - &7&lChiudere &f-":
                if player has permission "re.use" or "guardiare.use":
                    set {location.close} to player's location
                    send "&7Stai per chiudere il cancello, attendi &75&a secondi..." to player
                    wait 5 seconds
                    make console execute command "//set %{_pos1}% %{_pos2}% 35:4"
                     set {loc1} to location at -1351, 173, and -267 in world "world"
                     set {loc2} to location at 1342, 164, and -267 in world "world"
                     loop all blocks:
                         if %loop-block% is in between {loc1} and {loc2}:
                             set %loop-block% to yellow wool
 
Actually, on second thought, you were probably fine. But either way, it's still a solution. If you still have errors or the code isn't working, send me the error message and I'll help you figure it out.
 
thx for all, but i have find a solution. Infact, i have use the command /fill for replace the block, because in the skript I no longer entered variables or anything else, am only coordinates since I only needed it to close a gate at a certain location on the map.
 
thx for all, but i have find a solution. Infact, i have use the command /fill for replace the block, because in the skript I no longer entered variables or anything else, am only coordinates since I only needed it to close a gate at a certain location on the map.
Oh. Well, in that case, no problem! Glad you managed to figure it out!