From 180b2285f9b0ba2bbc732da7aae9608f60fd87bb Mon Sep 17 00:00:00 2001 From: Ghoulboy78 Date: Wed, 24 Feb 2021 09:44:43 +0100 Subject: [PATCH] moved drawing commands to separate library app now gotta import, and fix issues --- .../assets/carpet/scripts/draw_beta.sc | 132 ------------------ .../assets/carpet/scripts/shapes.scl | 132 ++++++++++++++++++ 2 files changed, 132 insertions(+), 132 deletions(-) create mode 100644 src/main/resources/assets/carpet/scripts/shapes.scl diff --git a/src/main/resources/assets/carpet/scripts/draw_beta.sc b/src/main/resources/assets/carpet/scripts/draw_beta.sc index 954fed07..32da53c5 100644 --- a/src/main/resources/assets/carpet/scripts/draw_beta.sc +++ b/src/main/resources/assets/carpet/scripts/draw_beta.sc @@ -66,36 +66,6 @@ affected(player) -> ( length_sq(vec) -> reduce(vec, _a + _*_, 0); -fill_flat(pos, offset, dr, rectangle, orientation, block, hollow, replacement)->( - r = floor(dr); - drsq = dr^2; - if(orientation=='x', - scan(pos,0,-r,-r, - if((!hollow && (rectangle || _y^2 + _z^2 <= drsq))||//if not hollow, vry simple - (hollow && ((rectangle && (abs(_y) == r || abs(_z) ==r)) || //If hollow and it's a rectangle - (!rectangle && (_y^2 + _z^2 <= drsq && (abs(_y)+1)^ 2 + (abs(_z)+1)^2 >= drsq)))),//If hollow and not rectangle - set_block(_x+offset,_y,_z,block, replacement) - ) - ), - orientation == 'y', - scan(pos,-r,0,-r, - if((!hollow && (rectangle || _x^2 + _z^2 <= drsq))||//if not hollow, vry simple - (hollow && ((rectangle && (abs(_x) == r || abs(_z) ==r)) || //If hollow and it's a rectangle - (!rectangle && (_x^2 + _z^2 <= drsq && (abs(_x)+1)^ 2 + (abs(_z)+1)^2 >= drsq)))),//If hollow and not rectangle - set_block(_x,_y+offset,_z,block, replacement) - ) - ), - orientation == 'z', - scan(pos,-r,-r,0, - if((!hollow && (rectangle || _y^2 + _x^2 <= drsq))||//if not hollow, vry simple - (hollow && ((rectangle && (abs(_y) == r || abs(_x) ==r)) || //If hollow and it's a rectangle - (!rectangle && (_y^2 + _x^2 <= drsq && (abs(_y)+1)^ 2 + (abs(_x)+1)^2 >= drsq)))),//If hollow and not rectangle - set_block(_x,_y,_z+offset,block, replacement) - ) - ) - ) -); - //Drawing commands draw(what, args)->(//custom setter cos it's easier @@ -111,105 +81,3 @@ draw(what, args)->(//custom setter cos it's easier affected(player()); ); - -draw_sphere(args)->( - if(global_debug, start_time=unix_time()); - - [centre, radius, block, replacement, hollow] = args; - - [cx,cy,cz]=centre; - for(range(-90, 90, 45/radius), - cpitch = cos(_); - spitch = sin(_); - for(range(0, 180, 45/radius), - cyaw = cos(_)*cpitch*radius; - syaw = sin(_)*cpitch*radius; - if(hollow, - set_block(cx+cyaw,cy+spitch*radius,cz+syaw,block,replacement); - set_block(cx+cos(_+180)*cpitch*radius,cy+spitch*radius,cz+sin(_+180)*cpitch*radius,block,replacement), - for(range(-syaw,syaw+1), - set_block(cx+cyaw*cpitch,cy+spitch*radius,cz+_,block,replacement) - ) - ) - ) - ); - - if(global_debug, - print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) - ); - return(global_positions) -); - -draw_diamond(args)->( - if(global_debug, start_time=unix_time()); - - [pos, radius, block, replacement] = args; - - c_for(r=0, r( - if(global_debug, start_time=unix_time()); - - [pos, radius, block, replacement] = args; - - for(diamond(pos,radius,radius), - set_block(_x,_y,_z,block,replacement) - ); - - if(global_debug, - print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) - ); - return(global_positions) -); - -draw_pyramid(args)->( - if(global_debug, start_time=unix_time()); - - [pos, radius, height, pointing, orientation, block, fill_type, replacement, is_square] = args; - - hollow = fill_type=='hollow'; - pointup = pointing=='up'; - for(range(height), - r = if(pointup, radius * ( 1- _ / height) -1, radius * _ / height); - fill_flat(pos, _, r, is_square, orientation, block, if((pointup&&_==0)||(!pointup && _==height-1),false,hollow),replacement)//Always close bottom off - ); - - if(global_debug, - print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) - ); - return(global_positions) -); - -draw_prism(args)->( - if(global_debug, start_time=unix_time()); - - [pos, rad, height, orientation, block, fill_type, replacement, is_square]=args; - - hollow = fill_type =='hollow'; - radius = rad+0.5; - - for(range(height), - fill_flat(pos, _, radius, is_square, orientation, block, if(_==0 || _==height-1,false,hollow), replacement)//Always close ends off - ); - - if(global_debug, - print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) - ); - return(global_positions) -); \ No newline at end of file diff --git a/src/main/resources/assets/carpet/scripts/shapes.scl b/src/main/resources/assets/carpet/scripts/shapes.scl new file mode 100644 index 00000000..c33ea53e --- /dev/null +++ b/src/main/resources/assets/carpet/scripts/shapes.scl @@ -0,0 +1,132 @@ + +draw_sphere(args)->( + if(global_debug, start_time=unix_time()); + + [centre, radius, block, replacement, hollow] = args; + + [cx,cy,cz]=centre; + for(range(-90, 90, 45/radius), + cpitch = cos(_); + spitch = sin(_); + for(range(0, 180, 45/radius), + cyaw = cos(_)*cpitch*radius; + syaw = sin(_)*cpitch*radius; + if(hollow, + set_block(cx+cyaw,cy+spitch*radius,cz+syaw,block,replacement); + set_block(cx+cos(_+180)*cpitch*radius,cy+spitch*radius,cz+sin(_+180)*cpitch*radius,block,replacement), + for(range(-syaw,syaw+1), + set_block(cx+cyaw*cpitch,cy+spitch*radius,cz+_,block,replacement) + ) + ) + ) + ); + + if(global_debug, + print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) + ); + return(global_positions) +); + +draw_diamond(args)->( + if(global_debug, start_time=unix_time()); + + [pos, radius, block, replacement] = args; + + c_for(r=0, r( + if(global_debug, start_time=unix_time()); + + [pos, radius, block, replacement] = args; + + for(diamond(pos,radius,radius), + set_block(_x,_y,_z,block,replacement) + ); + + if(global_debug, + print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) + ); + return(global_positions) +); + +draw_pyramid(args)->( + if(global_debug, start_time=unix_time()); + + [pos, radius, height, pointing, orientation, block, fill_type, replacement, is_square] = args; + + hollow = fill_type=='hollow'; + pointup = pointing=='up'; + for(range(height), + r = if(pointup, radius * ( 1- _ / height) -1, radius * _ / height); + fill_flat(pos, _, r, is_square, orientation, block, if((pointup&&_==0)||(!pointup && _==height-1),false,hollow),replacement)//Always close bottom off + ); + + if(global_debug, + print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) + ); + return(global_positions) +); + +draw_prism(args)->( + if(global_debug, start_time=unix_time()); + + [pos, rad, height, orientation, block, fill_type, replacement, is_square]=args; + + hollow = fill_type =='hollow'; + radius = rad+0.5; + + for(range(height), + fill_flat(pos, _, radius, is_square, orientation, block, if(_==0 || _==height-1,false,hollow), replacement)//Always close ends off + ); + + if(global_debug, + print(player(),format('gi Time taken: '+(unix_time()-start_time)+'ms')) + ); + return(global_positions) +); + +fill_flat(pos, offset, dr, rectangle, orientation, block, hollow, replacement)->( + r = floor(dr); + drsq = dr^2; + if(orientation=='x', + scan(pos,0,-r,-r, + if((!hollow && (rectangle || _y^2 + _z^2 <= drsq))||//if not hollow, vry simple + (hollow && ((rectangle && (abs(_y) == r || abs(_z) ==r)) || //If hollow and it's a rectangle + (!rectangle && (_y^2 + _z^2 <= drsq && (abs(_y)+1)^ 2 + (abs(_z)+1)^2 >= drsq)))),//If hollow and not rectangle + set_block(_x+offset,_y,_z,block, replacement) + ) + ), + orientation == 'y', + scan(pos,-r,0,-r, + if((!hollow && (rectangle || _x^2 + _z^2 <= drsq))||//if not hollow, vry simple + (hollow && ((rectangle && (abs(_x) == r || abs(_z) ==r)) || //If hollow and it's a rectangle + (!rectangle && (_x^2 + _z^2 <= drsq && (abs(_x)+1)^ 2 + (abs(_z)+1)^2 >= drsq)))),//If hollow and not rectangle + set_block(_x,_y+offset,_z,block, replacement) + ) + ), + orientation == 'z', + scan(pos,-r,-r,0, + if((!hollow && (rectangle || _y^2 + _x^2 <= drsq))||//if not hollow, vry simple + (hollow && ((rectangle && (abs(_y) == r || abs(_x) ==r)) || //If hollow and it's a rectangle + (!rectangle && (_y^2 + _x^2 <= drsq && (abs(_y)+1)^ 2 + (abs(_x)+1)^2 >= drsq)))),//If hollow and not rectangle + set_block(_x,_y,_z+offset,block, replacement) + ) + ) + ) +);