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.

/clone in skript

Discussion in 'Skript' started by Bram van Es, Sep 12, 2022.

Thread Status:
Not open for further replies.
  1. Bram van Es

    Bram van Es New Member

    Joined:
    Sep 21, 2020
    Messages:
    8
    Likes Received:
    0
    I'm trying to use the /clone command to make open-gate animations using skript. I have forceloaded the chunks that I need to clone. When I do the command in-game, it works perfectly fine, however, when I try to put it in skript, it gives an error.

    skript:
    Code (Text):
    1. console command "/clone 561 4 -815 566 11 -812 946 28 -620"
    error:
    Code (Text):
    1. That position is not loaded
    Is there a way to fix this? I have tried forceloading the chunks in skript itself too.
     
  2. Sabified

    Sabified Member

    Joined:
    Jun 5, 2022
    Messages:
    46
    Likes Received:
    2
    Code (Text):
    1. execute console command "/clone 561 4 -815 566 11 -812 946 28 -620"
    Like this?
     
  3. Bram van Es

    Bram van Es New Member

    Joined:
    Sep 21, 2020
    Messages:
    8
    Likes Received:
    0
    it's does the same thing with the skript that I have stated above
     
  4. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    139
    Likes Received:
    22
    Why are you using command instead of placing blocks with skript?
     
  5. Bram van Es

    Bram van Es New Member

    Joined:
    Sep 21, 2020
    Messages:
    8
    Likes Received:
    0
    it's not just 1 or two blocks that need to be placed, it's quite a few. Therefor I was wondering if this could work/anyone has any idea how to fix this.
     
  6. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    139
    Likes Received:
    22
    You can simply implement function to place not one block, save block types with locations then calculate offset vector for place this on any location
     
  7. Bram van Es

    Bram van Es New Member

    Joined:
    Sep 21, 2020
    Messages:
    8
    Likes Received:
    0
    Oh really? How does one do this, could you give me an example?
     
  8. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    139
    Likes Received:
    22
    Can you explain what doing /clone command, its copy from location to location? Because store building then paste has greater performance then copy and paste natively, I can make code for any of this options.
    What would you prefer?
     
  9. Bram van Es

    Bram van Es New Member

    Joined:
    Sep 21, 2020
    Messages:
    8
    Likes Received:
    0
    I am trying to open and close a gate with it, if that's possible with the store building option, that would be very lovely.
     
  10. lotzy

    lotzy Active Member

    Joined:
    Mar 15, 2022
    Messages:
    139
    Likes Received:
    22
    Code (Text):
    1. # this function store build with some id
    2. # pos1 - start location, pos2 - end location,
    3. # inlucdeAir - save air or not?
    4. function storeBuild(id: text,pos1: location, pos2: location, includeAir: boolean = true):
    5.   set {_pos1} to location of block at {_pos1}
    6.   set {_pos2} to location of block at {_pos2}
    7.   set {_x} to min((x coord of {_pos1}),(x coord of {_pos2}))
    8.   set {_y} to min((y coord of {_pos1}),(y coord of {_pos2}))
    9.   set {_z} to min((z coord of {_pos1}),(z coord of {_pos2}))
    10.   set {_vec} to vector({_x}-0.5,{_y}-0.5,{_z}-0.5)
    11.   delete {savedbuilds::%{_id}%::offsets::*}
    12.   delete {savedbuilds::%{_id}%::blocks::*}
    13.   if {_includeAir} is true:
    14.     loop blocks within {_pos1} and {_pos2}:
    15.       add 1 to {_i}
    16.       set {savedbuilds::%{_id}%::offsets::%{_i}%} to vector((x coord of loop-block)-{_x},(y coord of loop-block)-{_y},(z coord of loop-block)-{_z})
    17.       set {savedbuilds::%{_id}%::blocks::%{_i}%} to type of loop-block
    18.   else:
    19.     loop blocks within {_pos1} and {_pos2}:
    20.       if type of loop-block is not air:
    21.         add 1 to {_i}
    22.         set {savedbuilds::%{_id}%::offsets::%{_i}%} to vector((x coord of loop-block)-{_x},(y coord of loop-block)-{_y},(z coord of loop-block)-{_z})
    23.         set {savedbuilds::%{_id}%::blocks::%{_i}%} to type of loop-block
    24.  
    25. # this function paste saved build by id start at 'pos'
    26. # includeAir - paste air?
    27. function pasteBuild(id: text,pos: location, includeAir: boolean = true):
    28.   set {_pos} to location of block at {_pos}
    29.   if {_includeAir} is true:
    30.     loop {savedbuilds::%{_id}%::blocks::*}:
    31.       set block at ({_pos} ~ {savedbuilds::%{_id}%::offsets::%loop-index%}) to loop-value
    32.   else:
    33.     loop {savedbuilds::%{_id}%::blocks::*}:
    34.       if loop-value is not air:
    35.         set block at ({_pos} ~ {savedbuilds::%{_id}%::offsets::%loop-index%}) to loop-value
    36.  
    37. # for example:
    38. # rotateBuild("id",vector(0,1,0),-90) will rotate build around Y position
    39. # x           x
    40. # |  |_   ->  |  _|
    41. # |_____z     |_____z
    42.  
    43. #
    44. # rotateBuild("id",vector(0,0,1),-90) will rotate build around Z position
    45. # y           y
    46. # |  |_   ->  |  _|
    47. # |_____x     |_____x
    48.  
    49. function rotateBuild(id:text, axis: vector, degrees: number):
    50.   set {_mcos} to 1 - cos({_degrees})
    51.   set {_sin} to sin({_degrees})
    52.  
    53.   set {_mcos} to vector({_mcos},{_mcos},{_mcos})
    54.   set {_sin} to vector({_sin},{_sin},{_sin})
    55.  
    56.   loop {savedbuilds::%{_id}%::offsets::*}:
    57.     set {_vec} to loop-value
    58.     set {_vxp} to ({_axis} cross {_vec})
    59.     set {_vxvxp} to ({_axis} cross {_vxp})
    60.     set {savedbuilds::%{_id}%::offsets::%loop-index%} to ({_vec} ++ ({_sin} ** {_vxp}) ++ ({_mcos} ** {_vxvxp}))
     
  11. Sabified

    Sabified Member

    Joined:
    Jun 5, 2022
    Messages:
    46
    Likes Received:
    2
    It works for me though
    Try updating skript
     
  12. Pierrelasse

    Pierrelasse Active Member

    Joined:
    Apr 20, 2022
    Messages:
    116
    Likes Received:
    4
    The error is cuz the chunks are not loaded. This is a minecraft error that is useless i think but ye it is what it is
     
Thread Status:
Not open for further replies.

Share This Page

Loading...