Location of 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 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!

mezi

Member
Oct 19, 2024
2
0
1
Hi i have problem with locating block after mine it, function place blok work fine but when i mine skript cant locate it and locating to none. Thanks for any help

variables:
{respawn_time} = 10


function SkalaStworz():
send "&e[DEBUG] Ładowanie bloków z YAML..." to console
set {_nodes::*} to yaml nodes "Kopalnia.bloki" from file "plugins/Skript/lokacje.sk"
send "&e[DEBUG] Znaleziono %{_nodes::*}% bloków." to console

loop {_nodes::*}:
set {_loc} to location at {_x}, {_y}, {_z} in world {_world}
set {customblock::%loop-value%::location} to {_loc}
send "&e[DEBUG] Przypisano lokalizację %{_loc}% do {customblock::%loop-value%::location}." to console
send "&e[DEBUG] Przetwarzanie bloku nr %loop-value%..." to console
set {_block::location} to yaml value "Kopalnia.bloki.%loop-value%.location" from file "plugins/Skript/lokacje.sk"
set {_block::type} to yaml value "Kopalnia.bloki.%loop-value%.type" from file "plugins/Skript/lokacje.sk"
set {_block::hp} to yaml value "Kopalnia.bloki.%loop-value%.hp" from file "plugins/Skript/lokacje.sk"

send "&e[DEBUG] Lokalizacja: %{_block::location}%, Typ: %{_block::type}%, HP: %{_block::hp}%." to console


set {_loc_elements::*} to {_block::location} split at " "


set {_world} to {_loc_elements::1} parsed as world
set {_x} to {_loc_elements::2} parsed as number
set {_y} to {_loc_elements::3} parsed as number
set {_z} to {_loc_elements::4} parsed as number

set {_loc} to location at {_x}, {_y}, {_z} in world {_world}
send "&e[DEBUG] Przetwarzanie lokalizacji: Świat: %{_world}%, X: %{_x}%, Y: %{_y}%, Z: %{_z}%." to console


if {_block::type} is "iron_ore":
set block at {_loc} to iron ore
send "&e[DEBUG] Ustawiono blok Iron Ore w %{_loc}%." to console
else if {_block::type} is "gold_ore":
set block at {_loc} to gold ore
send "&e[DEBUG] Ustawiono blok Gold Ore w %{_loc}%." to console
else if {_block::type} is "diamond_ore":
set block at {_loc} to diamond ore
send "&e[DEBUG] Ustawiono blok Diamond Ore w %{_loc}%." to console


set {customblock::%loop-value%::location} to {_loc}
set {customblock::%loop-value%::type} to {_block::type}
set {customblock::%loop-value%::hp} to {_block::hp}

on load:
send "&e[DEBUG] Skript loaded fine." to console
SkalaStworz()
broadcast "Blocks loaded fine."

on block break:
loop {customblock::*}:
set {_loc} to {customblock::%loop-value%::location}
if {_loc} is set:
broadcast "&e[DEBUG] location of block nr %loop-value%: %{_loc}%."

if distance between location of event-block and {_loc} <= 1:
broadcast "Test"
cancel event
set {_hp} to {customblock::%loop-value%::hp}
send "&e[DEBUG] damage block. Remaining HP: %{_hp}%." to console
stop loop


And locating Skript

Kopalnia:
bloki:
1:
location: "world 583 97 -125 "
type: "iron_ore"
hp: 5
2:
location: "world 588.5 96 -110.5"
type: "gold_ore"
hp: 3
 
Ups line are gone under file for skript
 

Attachments

  • lokacje.sk
    335 bytes · Views: 127
  • skaki.sk
    3.5 KB · Views: 119