From 53aec581bb63cc34d1eb3a32bebe903ef41826b1 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 25 Nov 2020 01:50:32 -0400 Subject: [PATCH] simplify affected, not count set failures in draw --- .../assets/carpet/scripts/draw_beta.sc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/resources/assets/carpet/scripts/draw_beta.sc b/src/main/resources/assets/carpet/scripts/draw_beta.sc index 0927b318..ff819431 100644 --- a/src/main/resources/assets/carpet/scripts/draw_beta.sc +++ b/src/main/resources/assets/carpet/scripts/draw_beta.sc @@ -34,27 +34,27 @@ __config() -> { set_block(x, y, z, block, replacement)-> ( if(block != block(x, y, z), - without_updates(set([x, y, z],block)); - global_affected:0 += [x, y, z]; - global_affected:1 += 1; + without_updates( if (set([x, y, z],block), + global_affected += [x, y, z]; + )); ); ); -global_affected = [[],0]; +global_affected = []; affected(player) -> ( - print(player,format('gi Filled ' + global_affected:1 + ' blocks')); - affected = global_affected:1; + affected = length(global_affected); + print(player,format('gi Filled ' + affected + ' blocks')); if(system_info('world_carpet_rules'):'fillUpdates', - for(global_affected:0,update(_));//updating if fillUpdates is true + for(global_affected,update(_));//updating if fillUpdates is true ); - global_affected = [[],0]; + global_affected = []; affected ); -length_sq(vec) -> _vec_length(vec)^2; +length_sq(vec) -> reduce(vec, _a + _*_, 0); fill_flat(pos, offset, dr, rectangle, orientation, block, hollow, replacement)->( r = floor(dr); @@ -84,7 +84,7 @@ fill_flat(pos, offset, dr, rectangle, orientation, block, hollow, replacement)-> ) ), print(player(),format('r Error while running command: orientation can only be "x", "y" or "z", '+orientation+' is invalid.')); - global_affected = [[],0]; + global_affected = []; ); );