Solved loop-block not working 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!

Status
Not open for further replies.

drabspirit

New Member
Jan 25, 2020
6
0
0
23
Hi! I've been trying to get into Skript and have started with custom items, right now I'm working on an item to search a radius around the player for ore blocks, and then send a message. Everything works besides being able to sense the ores.

Code:
on rightclick:
    "%lore of player's held item%" contains "&eOre Enchament"
    loop blocks in radius 10 around player:
        if loop-block is iron ore, or coal ore, or gold ore, or diamond ore, or lapis ore, or redstone ore:
            send "&eThere are ores nearby!" to the player
            exit
        else:
            send "&e There's nothing nearby!" to the player
            exit
"

It's also doing the same with a 3x3 pickaxe. The loop-block isnt checking for the blocks.
Code:
on mine:
    "%lore of player's held item%" contains "&eGiant Pickaxe":
        set {_1} to location of event-block
        set {_2} to location of event-block
        if player's pitch is between -50 and 50:
            add 1 to y-coord of {_1}
            subtract 1 from y-coord of {_2}
            if player's horizontal facing is west or east:
                add 1 to z-coord of {_1}
                subtract 1 from z-coord of {_2}
                loop blocks within {_1} to {_2}:
                    if loop-block is not bedrock, or water, or lava:
                        if loop-block is stone, or andesite, or granite, or diorite, or obsidian, or cobblestone, or sandstone, or stone bricks, or chiseled stone bricks:
                            break loop-block using player's tool
            else if player's horizontal facing is north or south:
                add 1 to x-coord of {_1}
                subtract 1 from x-coord of {_2}
                loop blocks within {_1} to {_2}:
                    if loop-block is not bedrock, or water, or lava:
                        if loop-block is stone, or andesite, or granite, or diorite, or obsidian, or cobblestone, or sandstone, or stone bricks, or chiseled stone bricks:
                            break loop-block using player's tool
        else:
            add 1 to x-coord of {_1}
            add 1 to z-coord of {_1}
            subtract 1 from x-coord of {_2}
            subtract 1 from z-coord of {_2}
            loop blocks within {_1} to {_2}:
                if loop-block is not bedrock, or water, or lava:
                    if loop-block is stone, or andesite, or granite, or diorite, or obsidian, or cobblestone, or sandstone, or stone bricks, or chiseled stone bricks:
                        break loop-block using player's tool
 
Code:
on rightclick:
    "%lore of player's held item%" contains "&eOre Enchament"
    loop all blocks in radius 10 around the player:
        if loop-block is an ore:
            add 1 to {_ss}
    if {_ss} is set:
        send "&eThere are ores nearby!" to the player
        stop
    else:
        send "&e There's nothing nearby!" to the player
        stop
Hope it works for you ^-^
[doublepost=1579976152,1579960139][/doublepost]Does it work ? let me know
 
  • Like
Reactions: drabspirit
Hey thanks for the reply! That actually works perfectly, I have been kinda avoiding the the variables because I don't quite understand them ngl. While I was writing this I completely understood this, it's a 0 and a 1 right? Basically a true false statement with the if and else.

Sorry for my noobance, I've only done a bit of python so far, but tysm!
 
Hey thanks for the reply! That actually works perfectly, I have been kinda avoiding the the variables because I don't quite understand them ngl. While I was writing this I completely understood this, it's a 0 and a 1 right? Basically a true false statement with the if and else.

Sorry for my noobance, I've only done a bit of python so far, but tysm!
No problem, im not the best skript 'coder' but i try my best :emoji_grinning:
[doublepost=1580027925,1580027680][/doublepost]BTW set thread as solve please
 
  • Like
Reactions: drabspirit
Just did, also out of curiosity, did you know exactly why mine originally didnt work? My 3x3 pickaxe is running off the same format more or less, but I just dont understand why it doesnt work correctly to detect the blocks.
 
Status
Not open for further replies.