i have been trying to get this skript code working as intented for a while now
it is meant to replace a random block in a radius of 10 of the player with a chest but only on the same y-level of the player, so if it fails to choose an air block on the same y-level as the player it should try again, but i cannot get this to work
the 1st part works as intended the chest spawns with the test item in it, but the second part will only spawn the chest at the players feet and will also not detect if it is air so if your standing on a slab it replaces the slab, could i get some help fixing this please
it is meant to replace a random block in a radius of 10 of the player with a chest but only on the same y-level of the player, so if it fails to choose an air block on the same y-level as the player it should try again, but i cannot get this to work
code_language.skript:
function chestSummon(block: location):
set block at {_block} to chest
#Here is where you add the items this is just an example
add 1 diamond sword to block at {_block}'s inventory
#Here is where you check if the chest has items
wait 1 tick
while block at {_block} is a chest:
if items in block at {_block}'s inventory isn't set:
set block at {_block} to air
wait 1 tick
function addBlocks(player: player, radius: integer):
#here you get a random block
loop blocks in radius {_radius} around {_player}:
loop-block is air
set {_1} to "%loop-block's y-coordinate%"
set {_loc1::*} to {_1} split at "."
set {_2} to "%{_player}'s y-coordinate%"
set {_loc2::*} to {_2} split at "."
{_loc1::1} = {_loc2::1}
add loop-block to {_blocks::*}
if {_blocks::*} is set:
set {_block} to a random block out of {_blocks::*}
chestSummon({_block}'s location)
else:
wait 1 tick
addBlocks({_player}, {_radius})
the 1st part works as intended the chest spawns with the test item in it, but the second part will only spawn the chest at the players feet and will also not detect if it is air so if your standing on a slab it replaces the slab, could i get some help fixing this please