Check for block below player

  • Thread starter Deleted member 5824
  • Start date
  • 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!

Status
Not open for further replies.
D

Deleted member 5824

Hi, I am trying to make a /wild command, and I don't want the player to spawn in mid air, or in lava/water. So I thought about making a while-loop to check for the block below the player. And if that block is air, check for the block underneath, until it's solid ground. Here is what I have so far: (And I know that I should randomize a new location if the block is lava or water, but I haven't gotten that far yet)
code_language.skript:
options:
    min.x: -15000
    max.x: 15000
    min.z: -15000
    max.z: 15000
    Cooldown: 5 minutes
    ForbiddenBlocks: "Lava" or "Water" or "Air"


command /wild:
    trigger:
        set {_waited} to difference between {wild.%player%.lastused} and now
        if {_waited} is less than {@Cooldown}:
            send "&cYou must wait %difference between {@Cooldown} and {_waited}%"
            stop

        set {_x} to a random number between {@min.x} and {@max.x}
        set {_z} to a random number between {@min.z} and {@max.z}
        set {_y} to 100

        set {_loc} to location at {_x}, {_y}, {_z} in world "wild"

        while block below the location of {_loc} is {@ForbiddenBlocks}:
            set {_loc} to location at {_x}, {_y}-1, {_z} in world "wild"

        teleport player to {_loc}
 
You have to remove the " from the option Forbiddenblocks
 
Status
Not open for further replies.