Solved Placing a chest with specified items in it

  • 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.
This should work
code_language.skript:
function chestSummon(player: player):
    #here you get a random block
    set {_block} to random element out of the blocks in radius 10 around {_player}
    set block at {_block} to chest
    #Here is where you add the items this is just an example
    set slot 3 of {_block}'s inventory to diamond sword
    #Here is where you check if the chest has items
    while {_block} is a chest:
        if items in {_block}'s inventory isn't set:
            set {_block} to air
        wait 1 tick
 
on rightclick:
    chestSummon(player)
[doublepost=1499825302,1499825265][/doublepost]
Yeah i forgot to change that part
it now semi works but due to the fact that im using a 1 time use item to summon the chest it doesnt go away when empty
 
it now semi works but due to the fact that im using a 1 time use item to summon the chest it doesnt go away when empty
This should work if it doesnt work is cause the item set is not working correctly
code_language.skript:
function chestSummon(player: player):
    #here you get a random block
    set {_block} to random element out of the blocks in radius 10 around {_player}
    broadcast "%{_block}%"
    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
    while block at {_block} is a chest:
        if items in {_block}'s inventory isn't set:
            set block at {_block} to air
        wait 1 tick

on rightclick:
    chestSummon(player)
 
This should work if it doesnt work is cause the item set is not working correctly
code_language.skript:
function chestSummon(player: player):
    #here you get a random block
    set {_block} to random element out of the blocks in radius 10 around {_player}
    broadcast "%{_block}%"
    set block at {_block} to chest
    #Here is where you add the items this is just an example
    set slot 3 of block at {_block}'s inventory to diamond sword
    #Here is where you check if the chest has items
    while block at {_block} is a chest:
        if items in {_block}'s inventory isn't set:
            set block at {_block} to air
        wait 1 tick
 
on rightclick:
    chestSummon(player)
could you also add a loop so if the chosen block is not air it will attempt to choose a different block?
[doublepost=1499825773,1499825704][/doublepost]
could you also add a loop so if the chosen block is not air it will attempt to choose a different block?[/QUO
This should work if it doesnt work is cause the item set is not working correctly
code_language.skript:
function chestSummon(player: player):
    #here you get a random block
    set {_block} to random element out of the blocks in radius 10 around {_player}
    broadcast "%{_block}%"
    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
    while block at {_block} is a chest:
        if items in {_block}'s inventory isn't set:
            set block at {_block} to air
        wait 1 tick

on rightclick:
    chestSummon(player)
and also on the same y-level as the player, sorry i understand nothing of functions XD
 
Status
Not open for further replies.