Solved how to loop block correctly?

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

  • LOOKING FOR A VERSION OF SKRIPT?

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

gloatymadn

Member
Feb 9, 2024
13
0
1
21
I've been trying to loop blocks around the enchantment table.
The problem is that the loop-region is too big and the bookshelves that will be in the floor also count.
No matter how much I searched, I can't find a guide on how to correctly specify the region/zone for loop blocks.
i need loop blocks scan only 3x2x3 zone/region (enchanted table in the center of the region)

Code:
on rightclick on a enchanting table:
  if player isn't sneaking:
    cancel event
    set {_bs} to 0
    loop all blocks in radius 2.5 around the event-block:
      if loop-block is book shelf:
        add 1 to {_bs}
    if {_bs} >= 22:
      send "all ok" to player
 
you could use world edit / guard regions ... or add a check to see if the block is below the event block in y direction and disregard it
 
you could use world edit / guard regions ... or add a check to see if the block is below the event block in y direction and disregard it
wg / we regions - not. beacuse this script replace action when player try to use enchanting table. When I said "region" i mean a loop-region, not a wg region.
or add a check to see if the block is below the event block in y direction and disregard it

how? I can't figure out how to select zone in the center of which the event-block would be located.

Or how do I check which block is placed on the right 2 blocks from the event-block

I can't figure out how to write it correctly, because I haven't found a great guide to loop-blocks.
 
wg / we regions - not. beacuse this script replace action when player try to use enchanting table. When I said "region" i mean a loop-region, not a wg region.
or add a check to see if the block is below the event block in y direction and disregard it

how? I can't figure out how to select zone in the center of which the event-block would be located.

Or how do I check which block is placed on the right 2 blocks from the event-block

I can't figure out how to write it correctly, because I haven't found a great guide to loop-blocks.
you could manually set each based on direction
set {_west1} to block west of event-block
set {_west2} to block west of {_west1}
set {_east1} to block east of event-block
set {_east2} to block east of {_east1}
set {_above1} to block above of event-block
set {_above2} to block above of {_above1}

or like i said just exclude block below
 
you could manually set each based on direction
set {_west1} to block west of event-block
set {_west2} to block west of {_west1}
set {_east1} to block east of event-block
set {_east2} to block east of {_east1}
set {_above1} to block above of event-block
set {_above2} to block above of {_above1}

or like i said just exclude block below
solving problems with kludgy...
1708880660251.gif


Anyway, thanks for the help, this is at least a working solution at the moment, but in the long run, such solutions cause a RAM & tps leak.
 
what do you mean?
expressions like "loop blocks within" , "loop blocks in radius" "loop blocks from the loop-block to the block 10 north of the loop-block" and e.t.c.

english it's not my main language, and I don't speak it well, so I do not know how to write something like "select all blocks in the 3x3 around event block" so that the script understands me.
 
you can loop anything thats a list

the loop section itself:

examples of expressions you can loop:

to loop blocks in a 3x3 you need to:
1. get the center location, usually not a problem
2. offset it to 1 of the corners
3. offset the center to the opposite corner
4. loop blocks within both corners