Set a command block's command.

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

1NTORT

Member
May 27, 2024
3
0
1
I've been trying to make a skript that would be good for gen servers (repeatedly places a block in the same place so you can mine it forever), however there seem to be almost no resources on how to change a command block's command. I'm also completely new to skript, and just trying to figure things out. Here's how far I've got:

code_language.skript:
command /genstick:
    permission: op
    permission message: &r&fUnkown command. Type "/help" for help.
    trigger:
        set {_genstick} to unbreakable blaze rod named "&6Gen Stick"
        give player {_genstick}

on rightclick with blaze rod:
    if name of player's tool is "&6Gen Stick":
        if player is an operator:
            set {_clicked} to event-block
            set {_x} to x-coord of {_clicked}
            set {_y} to y-coord of {_clicked}
            set {_z} to z-coord of {_clicked}
            set block 2 below {_clicked} to repeating command block
            make console execute command data merge "blockdata %{_x}% %{_y}% %{_z}% {auto:1b,Command:\"setblock ~ ~10 ~ %type of {_clicked}%\"}"

If there is a better way of doing this, (i.e without command blocks) that would be good to know aswell.
 
wait so you want it to make a block of the block that was clicked? also I believe that command blocks may work better because they will still run after a server reset, I am not sure if a list will be saved permanently.

Code:
command /genstick:
    permission: op
    permission message: &r&fUnknown command. Type "/help" for help."
    trigger:
        set {_genstick} to unbreakable blaze rod named "&6Gen Stick"
        give player {_genstick}

on rightclick with blaze rod:
    if name of player's tool is "&6Gen Stick":
        if player is an operator:
            set {_clicked} to event-block
            set {_loc} to location of {_clicked}
            set {savedblocks::%{_loc}%} to type of {_clicked}
            send "&aBlock at %{_loc}% saved."

every 1 tick in "world":
    if world time of "world" is 11:30:
        loop {savedblocks::*}:
            set block at Idk what to do here-----(loop-index parsed as location)------- in world "world" to {savedblocks::%loop-index%}
        send "&6All saved blocks have been reset!" to all players
 
Last edited: