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

Solved Place block, save name... NBT??

Discussion in 'Skript' started by ShaneBee, Mar 23, 2018.

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

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Hey all

    So i have tried this numerous times and I am lost. I want to be able to set a block with a name, and then when I place the block on the ground it saves the name, so when I break it its the same name, vs reverting back to the blocks original name.
    I read somewhere you do this with NBT data? But I have no clue how to do that. How would one go about doing this?
    Thanks
     
  2. HackerOTVW

    HackerOTVW Active Member

    Joined:
    Sep 10, 2017
    Messages:
    91
    Likes Received:
    2
    Maybe something like this?
    Code (Skript):
    1. on place:
    2.     add "{YourTag:""%name of player's tool%""}" to nbt of event-block
    3.  
    4. on break:
    5.     if nbt of event-block contains "YourTag":
    6.         set {_YourTag} to tag "YourTag" of nbt of event-block
    7.         clear drops
    8.         drop 1 of event-block named "%{_YourTag}%"
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Hey
    Thanks for that, i threw it in, and this is what I get back from my console
    [19:25:28 ERROR]: can't understand this condition: 'nbt of event-block contains "YourTag"' (tool.sk, line 46: if nbt of event-block contains "YourTag":')
     
  4. HackerOTVW

    HackerOTVW Active Member

    Joined:
    Sep 10, 2017
    Messages:
    91
    Likes Received:
    2
    Ohh ... i think this will work:
    Code (Skript):
    1. if "%nbt of event-block%" contains "YourTag":
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Hey, thanks Hacker, The code works (no errors)
    but the action doesn't work.
    I did some more reading and apparently standard blocks that don't require anything to happen in them don't actually save NBT on placement.
    So sadly, this doesn't work.

    But I found another fix around it, so thanks again or your help :emoji_slight_smile:
     
  6. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    9
    Hey this intrigues me, would you mind posting the solution for me to examine and for any others wondering as well?
     
Thread Status:
Not open for further replies.

Share This Page

Loading...