From 8fdb8a9ffa3c2135c5348da9f6bd5d59d4a0850f Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Tue, 20 Mar 2018 09:22:44 +0800 Subject: [PATCH] Add border support --- libworld.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/libworld.lua b/libworld.lua index 5fc1c76..a8ab052 100644 --- a/libworld.lua +++ b/libworld.lua @@ -4,6 +4,42 @@ local component=require("component") local computer=require("computer") +function GetBlockBorder(x,y,z) + local lx,lz,mx,mz + if(x<0) then + lx=math.ceil((-x)/16) + if((-x)%16>0) then + lx=lx+1 + end + lx=(-lx)*16 + mx=lx+15 + else + lx=math.ceil(x/16) + if(x%16>0) then + lx=lx+1 + end + lx=lx*16 + mx=lx+15 + end + + if(z<0) then + lz=math.ceil((-z)/16) + if((-z)%16>0) then + lz=lz+1 + end + lz=(-lz)*16 + mz=lz+15 + else + lz=math.ceil(z/16) + if(z%16>0) then + lz=lz+1 + end + lz=lz*16 + mz=lz+15 + end + return lx,lz,mx,mz +end + -- Copy an area. returns a table contains area info. -- Can be serialized and stored in files. function CopyArea(ax,ay,az,bx,by,bz)