Location spawn

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

NiklasBroz

Member
Aug 31, 2018
4
0
0
24
How do i do so a location spawn cookies forever but if i type /stopcookiespawn it stop spawning them but if i type /togglecookiespawn it spawns again Pls help me ( sorry for bad english )
 
code_language.skript:
command /setcookiespawn:
    trigger:
        set {cookie.location} to player's location
        add 1 to y-coord of {cookie.location} #Prevents items from being glitched inside a block
        broadcast "Cookie location set at %{cookie.location}%"

command /togglecookiespawn:
    trigger:
        set {cookie.activated} to true if {cookie.activated} is false otherwise false
        broadcast "Cookie Activated: %{cookie.activated}%"
        
every 1 second:
    if {cookie.activated} is true:
        drop 1 cookie at {cookie.location} without velocity

This code will set a location for the cookie to spawn, and spawn cookies at that location every one second. It can be toggled.
 
code_language.skript:
command /setcookiespawn:
    trigger:
        set {cookie.location} to player's location
        add 1 to y-coord of {cookie.location} #Prevents items from being glitched inside a block
        broadcast "Cookie location set at %{cookie.location}%"

command /togglecookiespawn:
    trigger:
        set {cookie.activated} to true if {cookie.activated} is false otherwise false
        broadcast "Cookie Activated: %{cookie.activated}%"
      
every 1 second:
    if {cookie.activated} is true:
        drop 1 cookie at {cookie.location} without velocity

This code will set a location for the cookie to spawn, and spawn cookies at that location every one second. It can be toggled.
use list vars kthx bye

And use this code, way more efficient.
code_language.skript:
command /setcookie:
    trigger:
        set {_x} to location of player
        set y coordinate of {_x} to (y coordinate of {_x} + 1)
        set {cookie::spawn} to {_x}
        broadcast "Cookie spawn has been set at %{_x}%"
        while {cookie::spawn} is set:
            drop 1 cookie at {cookie::spawn}
            wait 1 second

command /delcookie:
    trigger:
        delete {cookie::spawn}
        broadcast "RIP cookie spawn"
Please refrain to using periodical loops, and use while loops instead since they are way better and only need 1 trigger (the command in this case)
 
Last edited:
Status
Not open for further replies.