1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to set a block to a block name stored in a variable

Discussion in 'Skript' started by cottondell, Aug 18, 2019.

Thread Status:
Not open for further replies.
  1. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    Hi!
    I want to set a block to another block which is stored in a variable.
    This is the line of code ive tried:
    set block at location of block to {block}

    The location of block is the location of a block which was broken because what i want is a system where when a block is broken, its gets replaced with the same block, to do this i also tried:
    set block at location of block to block
    but that doesn't work either.

    No errors show up when i reload skript, it just doesnt work when i try it.


    Please Help, thank you!
     
  2. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Code (Skript):
    1. on break:
    2.     set event-block at event-location to {block}
    This?

    Set block at location of block
    doesn't make sense...
     
  3. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    That came up with this error:
    upload_2019-8-18_22-0-49.png
     

    Attached Files:

  4. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Try:
    Code (Skript):
    1. set event-block to redstone block
     
  5. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    That works but if i try,
    set event-block to {block}
    it doesn't work.

    Also, how do you asign text to be script on skunity?
     
  6. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Show me the definition of {block}

    2. Question:

    [​IMG]
     
  7. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    well it is coal ore by default but when you level up it changes to a different block and thx.
     
  8. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Yeah but show the code for it
     
  9. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    Code (Text):
    1. on place:
    2.     if name of player's tool is "&6&lRegenerating Block":
    3.         set {rb.player.%location of block%} to player
    4.         set {rb.pos.%location of block%} to true
    5.         set {rb.block.%location of block%} to "coal ore" -- this line is temp, i would have it so it is the blocks name that was placed
    6.         create a new hologram with line "&6&lGenerator" and store in {holograms.gb.%player%.%location of block%}
    7.        
    8.  
    9. on break:
    10.     if {rb.pos.%location of block%} is true:
    11.         if {rb.player.%location of block%} is player:
    12.             wait 0.1 seconds
    13.             set event-block to {rb.block.%location of block%}
    14.         else:
    15.             message "{@MsgPrefix} &4You can not use other peoples Generator blocks!"
    16.             cancel event
     
  10. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Code (Skript):
    1. set event-block to {rb.block.%location of block%}
    You're setting a BLOCK to a location...
     
  11. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    nope:
    Code (Text):
    1. set {rb.block.%location of block%} to "coal ore" - would be set to the block placed down
     
  12. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Code (Skript):
    1. set {rb.block.%location of block%} to "coal ore"
    You cannot do this (?)

    Try:
    Code (Skript):
    1. set {rb.block.%location of block%} to coal ore
    2.  
    3. # the method i would use:
    4.  
    5. set {rb.block.BLOCK} to coal ore
     
  13. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    that works but is there a way to have {rg.block.%location of block%} set to the block's name cause i have it in an "on place"?
     
  14. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Have you tried the first example I gave? If so, what results? Anyways I do not think you can set a location to a block type...
     
  15. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    If you mean "set event-block at event-location to {block}" then this happens:
    View attachment 3687
     
  16. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Code (Skript):
    1. set {rb.block.%location of block%} to coal ore
    This...
     
  17. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    that works but i need it so if the block placed down was a grass_block then {rb.block.BLOCK} is set to grass_block but if the block placed down is a block of stone then {rb.block.BLOCK} is set to stone.
    (they would need to be named correct but i already have a cmd to give you a block named correctly)
    --- Double Post Merged, Aug 19, 2019, Original Post Date: Aug 19, 2019 ---
    what i done is close too working but after the wait it sets the variable to air?!?!

    Code (Text):
    1. on break:
    2.     if {rb.pos.%location of block%} is true:
    3.         if {rb.player.%location of block%} is player:
    4.             message "%{rb.block.%location of block%}%"
    5.             wait 0.1 seconds <-------
    6.             message "%{rb.block.%location of block%}%"
    7.             set event-block to {rb.block.%location of block%}
    8.         else:
    9.             message "{@MsgPrefix} &4You can not use other peoples Generator blocks!"
    10.             cancel event
     
  18. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Code (Skript):
    1. message "%{rb.block.%location of block%}%"
    2.  
    3. # replace with
    4.  
    5. message "%{rb.block.%event-block%}%"
     
  19. cottondell

    cottondell Member

    Joined:
    Aug 16, 2019
    Messages:
    14
    Likes Received:
    0
    says the same thing, and if i had {rb.block.%event-block%}, if i had multiple of the same block would it be personalized to each block
     
  20. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    304
    Likes Received:
    20
    Sorry I'm lost there, what do you wanna do?
     
Thread Status:
Not open for further replies.
Loading...