Jump to content

Dropping an item on a certain location


Logiq1

Recommended Posts

I'm trying to make a generator type thing where an ingot or diamond or something else drops on top of the "generator"'s location when a player is near a certain type of block. I currently have it working but am unsure of how to make the item drop at a certain coordinate or location, so instead the item drops randomly near the player.

 

on join:
    wait 1 tick
    while player is alive:
        loop all blocks in radius 5 around the player:
            if loop-block is a Block of Diamond:
                wait 3 seconds
                drop a diamond
        wait 1 second

This is what I have currently and it works perfectly fine apart from when I try to put in a location.

Thanks for any help!

Link to comment
Share on other sites

this should work:

on join:
    wait 1 tick
    while player is alive:
        loop all blocks in radius 5 around the player:
            if loop-block is a Block of Diamond:
                wait 3 seconds
                set {_loc} to location of loop-block
                add 0.5 to y-coordinate of {_loc}
                drop a diamond at {_loc}
        wait 1 second

but I recommend doing something like this:

function checkGen(plr: player):
    loop all blocks in radius 5 around {_plr}:
        if loop-block is a Block of Diamond:
            wait 3 seconds
            set {_loc} to location of loop-block
            add 0.5 to y-coordinate of {_loc}
            drop a diamond at {_loc}

every 1 second:
    loop all players:
    	checkGen(loop-player)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...