Solved Get block

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

glowgrew

Active Member
Jan 26, 2017
99
7
0
Perm, Russia
Hello, I have a code:
code_language.skript:
# There's errors on lines 3 and 10.
on break of any ore:
    set {_oretype::*} to block split at "_"
    position of block is {mine::%{_oretype::1}%}:
        cancel event
        set {_loc} to location of block
        set {_loc} to "%{_loc}%"
        replace all "x: ", "y: ", "z: " and "," with "" in {_loc}
        console command "/setblock %{_loc}% minecraft:cobblestone replace" # I'm using console command, cuz its breaks block naturally.
        give player 1 {_oretype::1} parsed as item type ore
        wait 5 seconds
        console command "/setblock %{_loc}% minecraft:%{_oretype::1}%_ore replace"
[doublepost=1500628545,1500628380][/doublepost]I forgot to say, that I creating an auto-regen mine.
 
Hello, I have a code:
code_language.skript:
# There's errors on lines 3 and 10.
on break of any ore:
    set {_oretype::*} to block split at "_"
    position of block is {mine::%{_oretype::1}%}:
        cancel event
        set {_loc} to location of block
        set {_loc} to "%{_loc}%"
        replace all "x: ", "y: ", "z: " and "," with "" in {_loc}
        console command "/setblock %{_loc}% minecraft:cobblestone replace" # I'm using console command, cuz its breaks block naturally.
        give player 1 {_oretype::1} parsed as item type ore
        wait 5 seconds
        console command "/setblock %{_loc}% minecraft:%{_oretype::1}%_ore replace"
[doublepost=1500628545,1500628380][/doublepost]I forgot to say, that I creating an auto-regen mine.

Okay, so first of all, you're using the split expression on the type block type, when it's normally used on text. Looking at your code, I'm assuming you want to get words like "iron, redstone, diamond" out of "iron_ore, redstone_ore, diamond_ore". We can do this by parsing the type as a text:

code_language.skript:
set {_oretype::*} to split "%block%" at "_"

Secondly, you're comparing the positing of the event-block with a variable. Now, I'm not entirely sure what you're trying to achieve as a whole, but by doing that- with the indexies as the ore type- you would only be able to have a handful of variables, since the indexes are already in use. But whatever, let's assume {mine::%{_oretype::1}%} ({mine::iron}, {mine::diamond}, {mine::redstone}, etc) is set to a position in the world.

I'm kinda confused about why you're using '/setblock' though, since 'replace' doesn't break blocks naturally. Anyways, we're going to try to not use console commands!

We can use Skellett's break block naturally expression to do the job.

code_language.skript:
skellett break event-block naturally

Now, since we're breaking blocks naturally, it will spawn a drop anyways, so we don't need to give the player an item.

code_language.skript:
on break of any ore:
    set {_oreType::*} to split "%event-block%" at "_"
    position of block is {mine::%{_oretype::1}%}:
        # we can't set it to plain event-block, since by the time we use this, the event-block will be air
        set {_block} to "%event-block%" parsed as item
        cancel event
        skellett break event-block naturally
        wait 5 seconds
        set block at event-location to {_block}
 
Status
Not open for further replies.