Problem with ender chest spawns

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

hasanas

Member
Feb 7, 2017
12
0
0
34
Hey there! I've been making a script but I've run into a problem, here is the code:

Code:
variables:
    {rewards::1} = stick
    {rewards::2} = diamond
    {rewards::3} = apple

command /chestspawn <integer>:
    usage: /chestspawn <1-5>
    trigger:
        arg-1 is between 1 and 5:
            set {location.%arg-1%.chestspawn} to player's location
            send "Chestspawn %arg-1% created."
           
every 1 minute:
    set {_random} to a random integer between 1 and 5
    set block at {location.%{_random}%.chestspawn} to ender chest named "&cLootCrate"
    broadcast "Chest spawned at %{location.%{_random}%.chestspawn}%"
   
on rightclick:
    if clicked block is ender chest named "&cLootCrate"
    cancel event
    if {LootCrate.open} is true:
        message "&cSomeone else opened this crate already" to player
        stop
    else:
        set {LootCrate.open} to true
        wait 0.5 seconds
        give player a random item out of {rewards::*}
        launch burst firework colored blue at clicked block timed 0.1
        wait 0.5 seconds
        set {LootCrate.open} to false

I need it so only the spawned ender chests give loot and not placed ones, as you see I tried making it a NAMED ender chest but that doesn't work either since it gives me this error:

Code:
Can't compare 'if clicked block' with an item type (Zeta.sk, line 19: if clicked block is ender chest named "&cLootCrate"')

Kind regards
hasanas
 
You can't check the name of a placed chest like that, it's essentially the same as if asking if a block is a named stick or something. You have to check the name of the clicked block separately, either using SkStuff to check its NBT directly, or by checking the name of the clicked block's inventory using Bensku's fork (which only works from version dev20 onwards).
 
You can't check the name of a placed chest like that, it's essentially the same as if asking if a block is a named stick or something. You have to check the name of the clicked block separately, either using SkStuff to check its NBT directly, or by checking the name of the clicked block's inventory using Bensku's fork (which only works from version dev20 onwards).

do you know of any other way to make it so only the SPAWNED enderchests can give loot? the normal enderchests should just be enderchests
 
You could just check if the location of the block is one of the locations where your loot crates can spawn. It looks like you have 5 chestspawn variables where they can spawn, so you can just do

code_language.skript:
loop integers between 1 and 5:
    clicked block's location is {location.%loop-number%.chestspawn}
    <INSERT CRATE CODE HERE>
 
You could just check if the location of the block is one of the locations where your loot crates can spawn. It looks like you have 5 chestspawn variables where they can spawn, so you can just do

code_language.skript:
loop integers between 1 and 5:
    clicked block's location is {location.%loop-number%.chestspawn}
    <INSERT CRATE CODE HERE>

thanks!
 
Status
Not open for further replies.