/clone in skript

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

Bram van Es

New Member
Sep 21, 2020
8
0
1
22
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:
console command "/clone 561 4 -815 566 11 -812 946 28 -620"

error:
Code:
That position is not loaded

Is there a way to fix this? I have tried forceloading the chunks in skript itself too.
 
Code:
execute console command "/clone 561 4 -815 566 11 -812 946 28 -620"
Like this?
 
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.
 
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.
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
 
Oh really? How does one do this, could you give me an example?
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?
 
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.
 
Code:
# this function store build with some id
# pos1 - start location, pos2 - end location,
# inlucdeAir - save air or not?
function storeBuild(id: text,pos1: location, pos2: location, includeAir: boolean = true):
  set {_pos1} to location of block at {_pos1}
  set {_pos2} to location of block at {_pos2}
  set {_x} to min((x coord of {_pos1}),(x coord of {_pos2}))
  set {_y} to min((y coord of {_pos1}),(y coord of {_pos2}))
  set {_z} to min((z coord of {_pos1}),(z coord of {_pos2}))
  set {_vec} to vector({_x}-0.5,{_y}-0.5,{_z}-0.5)
  delete {savedbuilds::%{_id}%::offsets::*}
  delete {savedbuilds::%{_id}%::blocks::*}
  if {_includeAir} is true:
    loop blocks within {_pos1} and {_pos2}:
      add 1 to {_i}
      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})
      set {savedbuilds::%{_id}%::blocks::%{_i}%} to type of loop-block
  else:
    loop blocks within {_pos1} and {_pos2}:
      if type of loop-block is not air:
        add 1 to {_i}
        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})
        set {savedbuilds::%{_id}%::blocks::%{_i}%} to type of loop-block

# this function paste saved build by id start at 'pos'
# includeAir - paste air?
function pasteBuild(id: text,pos: location, includeAir: boolean = true):
  set {_pos} to location of block at {_pos}
  if {_includeAir} is true:
    loop {savedbuilds::%{_id}%::blocks::*}:
      set block at ({_pos} ~ {savedbuilds::%{_id}%::offsets::%loop-index%}) to loop-value
  else:
    loop {savedbuilds::%{_id}%::blocks::*}:
      if loop-value is not air:
        set block at ({_pos} ~ {savedbuilds::%{_id}%::offsets::%loop-index%}) to loop-value

# for example:
# rotateBuild("id",vector(0,1,0),-90) will rotate build around Y position
# x           x
# |  |_   ->  |  _|
# |_____z     |_____z

#
# rotateBuild("id",vector(0,0,1),-90) will rotate build around Z position
# y           y
# |  |_   ->  |  _|
# |_____x     |_____x

function rotateBuild(id:text, axis: vector, degrees: number):
  set {_mcos} to 1 - cos({_degrees})
  set {_sin} to sin({_degrees})

  set {_mcos} to vector({_mcos},{_mcos},{_mcos})
  set {_sin} to vector({_sin},{_sin},{_sin})

  loop {savedbuilds::%{_id}%::offsets::*}:
    set {_vec} to loop-value
    set {_vxp} to ({_axis} cross {_vec})
    set {_vxvxp} to ({_axis} cross {_vxp})
    set {savedbuilds::%{_id}%::offsets::%loop-index%} to ({_vec} ++ ({_sin} ** {_vxp}) ++ ({_mcos} ** {_vxvxp}))
 
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:
console command "/clone 561 4 -815 566 11 -812 946 28 -620"

error:
Code:
That position is not loaded

Is there a way to fix this? I have tried forceloading the chunks in skript itself too.

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
 
Status
Not open for further replies.