diff --git a/init.lua b/init.lua index 6edd190..d98df90 100644 --- a/init.lua +++ b/init.lua @@ -6,6 +6,8 @@ -- by David G (kestral246@gmail.com) -- and by Mikola +-- Version 2.0-beta-17 - 2019-03-04 +-- Move tunneling privs checks earlier. -- Version 2.0-beta-16 - 2019-03-03 -- Add support to specify lighting param2 in minetest.conf. -- This allows using lights such as moreblocks:slab_meselamp_1,20 @@ -804,110 +806,108 @@ end -- [2] = -1 (default base, down floor,) -- [1] = -2 (down base) local dig_tunnel = function(cdir, user, pointed_thing) - if minetest.check_player_privs(user, "tunneling") then - local dig_patterns = { - -- Orthogonal (north reference). - [1] = { {{-3, 3},{0,0, 4, 4,4,4,4, 40,0}}, {{-2, 3},{0,0,4, 4,4,4, 4, 4,0}}, {{-1, 3},{0, 0,4, 4,4,4,4, 4,0}}, {{ 0, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 1, 3},{0, 0,4, 4,4,4,4, 4,0}}, {{ 2, 3},{0,0,4, 4,4,4, 4, 4,0}}, {{ 3, 3},{0,0, 4, 4,4,4,4, 40,0}}, - {{-3, 2},{0,0,37, 3,3,3,3, 30,0}}, {{-2, 2},{0,0,7, 1,1,1,21, 32,0}}, {{-1, 2},{0,86,6, 1,1,1,1, 2,0}}, {{ 0, 2},{0,86,5, 1,1,1, 1, 2,0}}, {{ 1, 2},{0,86,6, 1,1,1,1, 2,0}}, {{ 2, 2},{0,0,7, 1,1,1,21, 32,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, - {{-3, 1},{0,0,37, 3,3,3,3, 30,0}}, {{-2, 1},{0,0,7, 1,1,1,21, 32,0}}, {{-1, 1},{0,86,6, 1,1,1,1, 2,0}}, {{ 0, 1},{0,86,6, 1,1,1,77, 2,0}}, {{ 1, 1},{0,86,6, 1,1,1,1, 2,0}}, {{ 2, 1},{0,0,7, 1,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, - {{-3, 0},{0,0,37, 3,3,3,3, 30,0}}, {{-2, 0},{0,0,7, 1,1,1,21, 32,0}}, {{-1, 0},{0,86,6, 1,1,1,1, 2,0}}, {{ 0, 0},{0,86,5, 1,1,1, 1, 2,0}}, {{ 1, 0},{0,86,6, 1,1,1,1, 2,0}}, {{ 2, 0},{0,0,7, 1,1,1,21, 32,0}}, {{ 3, 0},{0,0,37, 3,3,3,3, 30,0}}, - {{-3,-1},{0,0, 4, 4,4,4,4, 40,0}}, {{-2,-1},{0,0,4, 4,4,4, 4, 4,0}}, {{-1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 0,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 2,-1},{0,0,4, 4,4,4, 4, 4,0}}, {{ 3,-1},{0,0, 4, 4,4,4,4, 40,0}}, - }, + local dig_patterns = { + -- Orthogonal (north reference). + [1] = { {{-3, 3},{0,0, 4, 4,4,4,4, 40,0}}, {{-2, 3},{0,0,4, 4,4,4, 4, 4,0}}, {{-1, 3},{0, 0,4, 4,4,4,4, 4,0}}, {{ 0, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 1, 3},{0, 0,4, 4,4,4,4, 4,0}}, {{ 2, 3},{0,0,4, 4,4,4, 4, 4,0}}, {{ 3, 3},{0,0, 4, 4,4,4,4, 40,0}}, + {{-3, 2},{0,0,37, 3,3,3,3, 30,0}}, {{-2, 2},{0,0,7, 1,1,1,21, 32,0}}, {{-1, 2},{0,86,6, 1,1,1,1, 2,0}}, {{ 0, 2},{0,86,5, 1,1,1, 1, 2,0}}, {{ 1, 2},{0,86,6, 1,1,1,1, 2,0}}, {{ 2, 2},{0,0,7, 1,1,1,21, 32,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, + {{-3, 1},{0,0,37, 3,3,3,3, 30,0}}, {{-2, 1},{0,0,7, 1,1,1,21, 32,0}}, {{-1, 1},{0,86,6, 1,1,1,1, 2,0}}, {{ 0, 1},{0,86,6, 1,1,1,77, 2,0}}, {{ 1, 1},{0,86,6, 1,1,1,1, 2,0}}, {{ 2, 1},{0,0,7, 1,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, + {{-3, 0},{0,0,37, 3,3,3,3, 30,0}}, {{-2, 0},{0,0,7, 1,1,1,21, 32,0}}, {{-1, 0},{0,86,6, 1,1,1,1, 2,0}}, {{ 0, 0},{0,86,5, 1,1,1, 1, 2,0}}, {{ 1, 0},{0,86,6, 1,1,1,1, 2,0}}, {{ 2, 0},{0,0,7, 1,1,1,21, 32,0}}, {{ 3, 0},{0,0,37, 3,3,3,3, 30,0}}, + {{-3,-1},{0,0, 4, 4,4,4,4, 40,0}}, {{-2,-1},{0,0,4, 4,4,4, 4, 4,0}}, {{-1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 0,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 2,-1},{0,0,4, 4,4,4, 4, 4,0}}, {{ 3,-1},{0,0, 4, 4,4,4,4, 40,0}}, + }, - -- Knight move (north-northwest reference). - [2] = { {{-4, 3},{0,0, 4, 4,4,4,4, 40,0}}, {{-3, 3},{0,0, 4, 4,4,4, 4, 4,0}}, {{-2, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{-1, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 0, 3},{0, 0,4, 4,4,4,4, 4,0}}, {{ 1, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 2, 3},{0,0,37, 3,3,3, 3, 30,0}}, - {{-4, 2},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 2},{0,0, 7, 1,1,1,21, 32,0}}, {{-2, 2},{0,86,6, 1,1,1, 1, 2,0}}, {{-1, 2},{0,86,5, 1,1,1,77, 2,0}}, {{ 0, 2},{0,86,6, 1,1,1,1, 2,0}}, {{ 1, 2},{0, 0,7, 1,1,1,21, 32,0}}, {{ 2, 2},{0,0,37, 3,3,3, 3, 3,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, - {{-4, 1},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 1},{0,0, 7, 1,1,1,21, 32,0}}, {{-2, 1},{0,86,6, 1,1,1, 1, 2,0}}, {{-1, 1},{0,86,6, 1,1,1, 1, 2,0}}, {{ 0, 1},{0,86,6, 1,1,1,1, 2,0}}, {{ 1, 1},{0,86,6, 1,1,1, 1, 2,0}}, {{ 2, 1},{0,0, 7, 1,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, - {{-4, 0},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 0},{0,0,37, 3,3,3, 3, 3,0}}, {{-2, 0},{0, 0,7, 1,1,1,21, 32,0}}, {{-1, 0},{0,86,6, 1,1,1, 1, 2,0}}, {{ 0, 0},{0,86,5, 1,1,1,1, 2,0}}, {{ 1, 0},{0,86,6, 1,1,1, 1, 2,0}}, {{ 2, 0},{0,0, 7, 19,1,1,21, 32,0}}, {{ 3, 0},{0,0,37, 3,3,3,3, 30,0}}, - {{-3,-1},{0,0,37, 3,3,3, 3, 30,0}}, {{-2,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{-1,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 0,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 1,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 2,-1},{0,0, 4, 4,4,4, 4, 4,0}}, {{ 3,-1},{0,0, 4, 4,4,4,4, 40,0}}, - }, + -- Knight move (north-northwest reference). + [2] = { {{-4, 3},{0,0, 4, 4,4,4,4, 40,0}}, {{-3, 3},{0,0, 4, 4,4,4, 4, 4,0}}, {{-2, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{-1, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 0, 3},{0, 0,4, 4,4,4,4, 4,0}}, {{ 1, 3},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 2, 3},{0,0,37, 3,3,3, 3, 30,0}}, + {{-4, 2},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 2},{0,0, 7, 1,1,1,21, 32,0}}, {{-2, 2},{0,86,6, 1,1,1, 1, 2,0}}, {{-1, 2},{0,86,5, 1,1,1,77, 2,0}}, {{ 0, 2},{0,86,6, 1,1,1,1, 2,0}}, {{ 1, 2},{0, 0,7, 1,1,1,21, 32,0}}, {{ 2, 2},{0,0,37, 3,3,3, 3, 3,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, + {{-4, 1},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 1},{0,0, 7, 1,1,1,21, 32,0}}, {{-2, 1},{0,86,6, 1,1,1, 1, 2,0}}, {{-1, 1},{0,86,6, 1,1,1, 1, 2,0}}, {{ 0, 1},{0,86,6, 1,1,1,1, 2,0}}, {{ 1, 1},{0,86,6, 1,1,1, 1, 2,0}}, {{ 2, 1},{0,0, 7, 1,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, + {{-4, 0},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 0},{0,0,37, 3,3,3, 3, 3,0}}, {{-2, 0},{0, 0,7, 1,1,1,21, 32,0}}, {{-1, 0},{0,86,6, 1,1,1, 1, 2,0}}, {{ 0, 0},{0,86,5, 1,1,1,1, 2,0}}, {{ 1, 0},{0,86,6, 1,1,1, 1, 2,0}}, {{ 2, 0},{0,0, 7, 19,1,1,21, 32,0}}, {{ 3, 0},{0,0,37, 3,3,3,3, 30,0}}, + {{-3,-1},{0,0,37, 3,3,3, 3, 30,0}}, {{-2,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{-1,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 0,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 1,-1},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 2,-1},{0,0, 4, 4,4,4, 4, 4,0}}, {{ 3,-1},{0,0, 4, 4,4,4,4, 40,0}}, + }, - -- Diagonal (northwest reference). - [3] = { {{-1, 4},{0, 0, 4, 4,4,4, 4, 40,0}}, {{ 0, 4},{0, 0,37, 3,3,3, 3, 30,0}}, {{ 1, 4},{0, 0,37, 3,3,3, 3, 30,0}}, - {{-2, 3},{0, 0, 4, 4,4,4, 4, 4,0}}, {{-1, 3},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 0, 3},{0, 0, 7, 1,1,1,21, 32,0}}, {{ 1, 3},{0, 0,37, 3,3,3, 3, 2,0}}, {{ 2, 3},{0,0,37, 3,3,3,3, 30,0}}, - {{-3, 2},{0,0, 4, 4,4,4, 4, 4,0}}, {{-2, 2},{0, 0, 4, 4,4,4, 4, 4,0}}, {{-1, 2},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 0, 2},{0,86, 6, 1,1,1, 1, 2,0}}, {{ 1, 2},{0, 0, 7, 1,1,1,21, 32,0}}, {{ 2, 2},{0,0,37, 3,3,3,3, 2,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, - {{-4, 1},{0,0, 4, 4,4,4,4, 40,0}}, {{-3, 1},{0,0, 4, 4,4,4, 4, 4,0}}, {{-2, 1},{0, 0, 4, 4,4,4, 4, 4,0}}, {{-1, 1},{0,86, 5, 1,1,1, 1, 2,0}}, {{ 0, 1},{0,86, 6, 1,1,1, 1, 2,0}}, {{ 1, 1},{0,86, 6, 10,1,1, 1, 2,0}}, {{ 2, 1},{0,0, 7, 19,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, - {{-4, 0},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 0},{0,0, 7, 1,1,1,21, 32,0}}, {{-2, 0},{0,86, 6, 1,1,1, 1, 2,0}}, {{-1, 0},{0,86, 6, 1,1,1, 1, 2,0}}, {{ 0, 0},{0,86, 5, 10,1,1,77, 2,0}}, {{ 1, 0},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 2, 0},{0,0, 4, 4,4,4,4, 4,0}}, {{ 3, 0},{0,0, 4, 4,4,4,4, 40,0}}, - {{-4,-1},{0,0,37, 3,3,3,3, 30,0}}, {{-3,-1},{0,0,37, 3,3,3, 3, 2,0}}, {{-2,-1},{0, 0, 7, 1,1,1,21, 32,0}}, {{-1,-1},{0,86, 6, 10,1,1, 1, 2,0}}, {{ 0,-1},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 1,-1},{0, 0, 4, 4,4,4, 4, 4,0}}, - {{-3,-2},{0,0,37, 3,3,3, 3, 30,0}}, {{-2,-2},{0, 0,37, 3,3,3, 3, 2,0}}, {{-1,-2},{0, 0, 7, 19,1,1,21, 32,0}}, {{ 0,-2},{0, 0, 4, 4,4,4, 4, 4,0}}, - {{-2,-3},{0, 0,37, 3,3,3, 3, 30,0}}, {{-1,-3},{0, 0,37, 3,3,3, 3, 30,0}}, {{ 0,-3},{0, 0, 4, 4,4,4, 4, 40,0}}, - }, + -- Diagonal (northwest reference). + [3] = { {{-1, 4},{0, 0, 4, 4,4,4, 4, 40,0}}, {{ 0, 4},{0, 0,37, 3,3,3, 3, 30,0}}, {{ 1, 4},{0, 0,37, 3,3,3, 3, 30,0}}, + {{-2, 3},{0, 0, 4, 4,4,4, 4, 4,0}}, {{-1, 3},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 0, 3},{0, 0, 7, 1,1,1,21, 32,0}}, {{ 1, 3},{0, 0,37, 3,3,3, 3, 2,0}}, {{ 2, 3},{0,0,37, 3,3,3,3, 30,0}}, + {{-3, 2},{0,0, 4, 4,4,4, 4, 4,0}}, {{-2, 2},{0, 0, 4, 4,4,4, 4, 4,0}}, {{-1, 2},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 0, 2},{0,86, 6, 1,1,1, 1, 2,0}}, {{ 1, 2},{0, 0, 7, 1,1,1,21, 32,0}}, {{ 2, 2},{0,0,37, 3,3,3,3, 2,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, + {{-4, 1},{0,0, 4, 4,4,4,4, 40,0}}, {{-3, 1},{0,0, 4, 4,4,4, 4, 4,0}}, {{-2, 1},{0, 0, 4, 4,4,4, 4, 4,0}}, {{-1, 1},{0,86, 5, 1,1,1, 1, 2,0}}, {{ 0, 1},{0,86, 6, 1,1,1, 1, 2,0}}, {{ 1, 1},{0,86, 6, 10,1,1, 1, 2,0}}, {{ 2, 1},{0,0, 7, 19,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, + {{-4, 0},{0,0,37, 3,3,3,3, 30,0}}, {{-3, 0},{0,0, 7, 1,1,1,21, 32,0}}, {{-2, 0},{0,86, 6, 1,1,1, 1, 2,0}}, {{-1, 0},{0,86, 6, 1,1,1, 1, 2,0}}, {{ 0, 0},{0,86, 5, 10,1,1,77, 2,0}}, {{ 1, 0},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 2, 0},{0,0, 4, 4,4,4,4, 4,0}}, {{ 3, 0},{0,0, 4, 4,4,4,4, 40,0}}, + {{-4,-1},{0,0,37, 3,3,3,3, 30,0}}, {{-3,-1},{0,0,37, 3,3,3, 3, 2,0}}, {{-2,-1},{0, 0, 7, 1,1,1,21, 32,0}}, {{-1,-1},{0,86, 6, 10,1,1, 1, 2,0}}, {{ 0,-1},{0, 0, 4, 4,4,4, 4, 4,0}}, {{ 1,-1},{0, 0, 4, 4,4,4, 4, 4,0}}, + {{-3,-2},{0,0,37, 3,3,3, 3, 30,0}}, {{-2,-2},{0, 0,37, 3,3,3, 3, 2,0}}, {{-1,-2},{0, 0, 7, 19,1,1,21, 32,0}}, {{ 0,-2},{0, 0, 4, 4,4,4, 4, 4,0}}, + {{-2,-3},{0, 0,37, 3,3,3, 3, 30,0}}, {{-1,-3},{0, 0,37, 3,3,3, 3, 30,0}}, {{ 0,-3},{0, 0, 4, 4,4,4, 4, 40,0}}, + }, - -- Orthogonal slope down (north reference). - -- Review water tunnel (-3,0), (-2,0), (2,0), (3,0) all 1 below ref level (0 and 87) -- not solid seal, but water's not going to go up. - [10] = {{{-3, 3},{0, 4, 4, 4,4,4,40, 0,0}}, {{-2, 3},{0, 4, 4, 4,4, 4, 4, 0,0}}, {{-1, 3},{ 0,4, 4, 4,4,4,4, 0,0}}, {{ 0, 3},{ 0,4, 4, 4,4,4, 4, 0,0}}, {{ 1, 3},{ 0,4, 4, 4,4,4,4, 0,0}}, {{ 2, 3},{0, 4, 4, 4,4, 4, 4, 0,0}}, {{ 3, 3},{0, 4, 4, 4,4,4,40, 0,0}}, - {{-3, 2},{0,37, 3, 3,3,3, 3, 30,0}}, {{-2, 2},{0, 7, 1, 1,1,21,32, 32,0}}, {{-1, 2},{86,6, 1, 1,1,1,2, 2,0}}, {{ 0, 2},{86,5, 1, 1,1,1, 2, 2,0}}, {{ 1, 2},{86,6, 1, 1,1,1,2, 2,0}}, {{ 2, 2},{0, 7, 1, 1,1,21,32, 32,0}}, {{ 3, 2},{0,37, 3, 3,3,3, 3, 30,0}}, - {{-3, 1},{0,37, 3, 3,3,3, 3, 30,0}}, {{-2, 1},{0, 7,13, 1,1, 1,21, 32,0}}, {{-1, 1},{86,6,12, 1,1,1,1, 2,0}}, {{ 0, 1},{86,6,12, 1,1,1,77, 2,0}}, {{ 1, 1},{86,6,12, 1,1,1,1, 2,0}}, {{ 2, 1},{0, 7,13, 1,1, 1,21, 32,0}}, {{ 3, 1},{0,37, 3, 3,3,3, 3, 30,0}}, - {{-3, 0},{0, 0,37, 3,3,3, 3, 30,0}}, {{-2, 0},{0,87, 7, 1,1, 1,21, 32,0}}, {{-1, 0},{86,8, 6, 1,1,1,1, 2,0}}, {{ 0, 0},{86,8, 5, 1,1,1, 1, 2,0}}, {{ 1, 0},{86,8, 6, 1,1,1,1, 2,0}}, {{ 2, 0},{0,87, 7, 1,1, 1,21, 32,0}}, {{ 3, 0},{0, 0,37, 3,3,3, 3, 30,0}}, - {{-3,-1},{0, 0, 4, 4,4,4, 4, 40,0}}, {{-2,-1},{0, 0, 4, 4,4, 4, 4, 4,0}}, {{-1,-1},{ 0,0, 4, 4,4,4,4, 4,0}}, {{ 0,-1},{ 0,0, 4, 4,4,4, 4, 4,0}}, {{ 1,-1},{ 0,0, 4, 4,4,4,4, 4,0}}, {{ 2,-1},{0, 0, 4, 4,4, 4, 4, 4,0}}, {{ 3,-1},{0, 0, 4, 4,4,4, 4, 40,0}}, - }, + -- Orthogonal slope down (north reference). + -- Review water tunnel (-3,0), (-2,0), (2,0), (3,0) all 1 below ref level (0 and 87) -- not solid seal, but water's not going to go up. + [10] = {{{-3, 3},{0, 4, 4, 4,4,4,40, 0,0}}, {{-2, 3},{0, 4, 4, 4,4, 4, 4, 0,0}}, {{-1, 3},{ 0,4, 4, 4,4,4,4, 0,0}}, {{ 0, 3},{ 0,4, 4, 4,4,4, 4, 0,0}}, {{ 1, 3},{ 0,4, 4, 4,4,4,4, 0,0}}, {{ 2, 3},{0, 4, 4, 4,4, 4, 4, 0,0}}, {{ 3, 3},{0, 4, 4, 4,4,4,40, 0,0}}, + {{-3, 2},{0,37, 3, 3,3,3, 3, 30,0}}, {{-2, 2},{0, 7, 1, 1,1,21,32, 32,0}}, {{-1, 2},{86,6, 1, 1,1,1,2, 2,0}}, {{ 0, 2},{86,5, 1, 1,1,1, 2, 2,0}}, {{ 1, 2},{86,6, 1, 1,1,1,2, 2,0}}, {{ 2, 2},{0, 7, 1, 1,1,21,32, 32,0}}, {{ 3, 2},{0,37, 3, 3,3,3, 3, 30,0}}, + {{-3, 1},{0,37, 3, 3,3,3, 3, 30,0}}, {{-2, 1},{0, 7,13, 1,1, 1,21, 32,0}}, {{-1, 1},{86,6,12, 1,1,1,1, 2,0}}, {{ 0, 1},{86,6,12, 1,1,1,77, 2,0}}, {{ 1, 1},{86,6,12, 1,1,1,1, 2,0}}, {{ 2, 1},{0, 7,13, 1,1, 1,21, 32,0}}, {{ 3, 1},{0,37, 3, 3,3,3, 3, 30,0}}, + {{-3, 0},{0, 0,37, 3,3,3, 3, 30,0}}, {{-2, 0},{0,87, 7, 1,1, 1,21, 32,0}}, {{-1, 0},{86,8, 6, 1,1,1,1, 2,0}}, {{ 0, 0},{86,8, 5, 1,1,1, 1, 2,0}}, {{ 1, 0},{86,8, 6, 1,1,1,1, 2,0}}, {{ 2, 0},{0,87, 7, 1,1, 1,21, 32,0}}, {{ 3, 0},{0, 0,37, 3,3,3, 3, 30,0}}, + {{-3,-1},{0, 0, 4, 4,4,4, 4, 40,0}}, {{-2,-1},{0, 0, 4, 4,4, 4, 4, 4,0}}, {{-1,-1},{ 0,0, 4, 4,4,4,4, 4,0}}, {{ 0,-1},{ 0,0, 4, 4,4,4, 4, 4,0}}, {{ 1,-1},{ 0,0, 4, 4,4,4,4, 4,0}}, {{ 2,-1},{0, 0, 4, 4,4, 4, 4, 4,0}}, {{ 3,-1},{0, 0, 4, 4,4,4, 4, 40,0}}, + }, - -- Orthogonal slope up (north reference). - -- Review water tunnel (-3,2), (-2,2), (2,2), 3,2) all at ref level (0 and 87) -- not solid seal, but water's not going to go up. - [11] = {{{-3, 3},{0,0, 0, 4,4,4,4, 4,40}}, {{-2, 3},{0,0, 0, 4,4,4, 4, 4, 4}}, {{-1, 3},{0, 0,0, 4,4,4,4, 4,4}}, {{ 0, 3},{0, 0,0, 4,4,4,4, 4,4}}, {{ 1, 3},{0, 0,0, 4,4,4,4, 4,4}}, {{ 2, 3},{0,0, 0, 4,4,4, 4, 4, 4}}, {{ 3, 3},{0,0, 0, 4,4,4,4, 4,40}}, - {{-3, 2},{0,0, 0, 37,3,3,3, 3,30}}, {{-2, 2},{0,0,87, 7,1,1, 1, 21,32}}, {{-1, 2},{0,86,8, 6,1,1,1, 1,2}}, {{ 0, 2},{0,86,8, 5,1,1,1, 1,2}}, {{ 1, 2},{0,86,8, 6,1,1,1, 1,2}}, {{ 2, 2},{0,0,87, 7,1,1, 1, 21,32}}, {{ 3, 2},{0,0, 0, 37,3,3,3, 3,30}}, - {{-3, 1},{0,0,37, 3,3,3,3, 3,30}}, {{-2, 1},{0,0, 7, 13,1,1, 1, 21,32}}, {{-1, 1},{0,86,6, 12,1,1,1, 1,2}}, {{ 0, 1},{0,86,6, 12,1,1,1, 77,2}}, {{ 1, 1},{0,86,6, 12,1,1,1, 1,2}}, {{ 2, 1},{0,0, 7, 13,1,1, 1, 21,32}}, {{ 3, 1},{0,0,37, 3,3,3,3, 3,30}}, - {{-3, 0},{0,0,37, 3,3,3,3, 3,30}}, {{-2, 0},{0,0, 7, 1,1,1,21, 32, 4}}, {{-1, 0},{0,86,6, 1,1,1,1, 2,4}}, {{ 0, 0},{0,86,5, 1,1,1,1, 2,4}}, {{ 1, 0},{0,86,6, 1,1,1,1, 2,4}}, {{ 2, 0},{0,0, 7, 1,1,1,21, 32, 4}}, {{ 3, 0},{0,0,37, 3,3,3,3, 3,30}}, - {{-3,-1},{0,0, 4, 4,4,4,4, 40, 0}}, {{-2,-1},{0,0, 4, 4,4,4, 4, 4, 0}}, {{-1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 0,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 2,-1},{0,0, 4, 4,4,4, 4, 4, 0}}, {{ 3,-1},{0,0, 4, 4,4,4,4, 40, 0}}, - }, + -- Orthogonal slope up (north reference). + -- Review water tunnel (-3,2), (-2,2), (2,2), 3,2) all at ref level (0 and 87) -- not solid seal, but water's not going to go up. + [11] = {{{-3, 3},{0,0, 0, 4,4,4,4, 4,40}}, {{-2, 3},{0,0, 0, 4,4,4, 4, 4, 4}}, {{-1, 3},{0, 0,0, 4,4,4,4, 4,4}}, {{ 0, 3},{0, 0,0, 4,4,4,4, 4,4}}, {{ 1, 3},{0, 0,0, 4,4,4,4, 4,4}}, {{ 2, 3},{0,0, 0, 4,4,4, 4, 4, 4}}, {{ 3, 3},{0,0, 0, 4,4,4,4, 4,40}}, + {{-3, 2},{0,0, 0, 37,3,3,3, 3,30}}, {{-2, 2},{0,0,87, 7,1,1, 1, 21,32}}, {{-1, 2},{0,86,8, 6,1,1,1, 1,2}}, {{ 0, 2},{0,86,8, 5,1,1,1, 1,2}}, {{ 1, 2},{0,86,8, 6,1,1,1, 1,2}}, {{ 2, 2},{0,0,87, 7,1,1, 1, 21,32}}, {{ 3, 2},{0,0, 0, 37,3,3,3, 3,30}}, + {{-3, 1},{0,0,37, 3,3,3,3, 3,30}}, {{-2, 1},{0,0, 7, 13,1,1, 1, 21,32}}, {{-1, 1},{0,86,6, 12,1,1,1, 1,2}}, {{ 0, 1},{0,86,6, 12,1,1,1, 77,2}}, {{ 1, 1},{0,86,6, 12,1,1,1, 1,2}}, {{ 2, 1},{0,0, 7, 13,1,1, 1, 21,32}}, {{ 3, 1},{0,0,37, 3,3,3,3, 3,30}}, + {{-3, 0},{0,0,37, 3,3,3,3, 3,30}}, {{-2, 0},{0,0, 7, 1,1,1,21, 32, 4}}, {{-1, 0},{0,86,6, 1,1,1,1, 2,4}}, {{ 0, 0},{0,86,5, 1,1,1,1, 2,4}}, {{ 1, 0},{0,86,6, 1,1,1,1, 2,4}}, {{ 2, 0},{0,0, 7, 1,1,1,21, 32, 4}}, {{ 3, 0},{0,0,37, 3,3,3,3, 3,30}}, + {{-3,-1},{0,0, 4, 4,4,4,4, 40, 0}}, {{-2,-1},{0,0, 4, 4,4,4, 4, 4, 0}}, {{-1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 0,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 1,-1},{0, 0,4, 4,4,4,4, 4,0}}, {{ 2,-1},{0,0, 4, 4,4,4, 4, 4, 0}}, {{ 3,-1},{0,0, 4, 4,4,4,4, 40, 0}}, + }, - -- Diagonal slope down (northwest reference). - -- Review water tunnel (-3,0), (0,3) stacked 32 -- with arch, overdoing seal, could raise height of 21 or remove top 32. - -- Review water tunnel (-1,-2), (2,1) -- not solid seal, but water's not going to go up. - [30] = { {{-1, 4},{ 0, 4, 4, 4,4,4, 4, 0,0}}, {{ 0, 4},{ 0,37, 3, 3,3, 3, 3, 0,0}}, {{ 1, 4},{ 0,37, 3, 3,3,3, 3, 0,0}}, - {{-1, 3},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{ 0, 3},{ 0, 7, 1, 1,1,21,32, 32,0}}, {{ 1, 3},{ 0,37, 3, 3,3,3, 3, 2,0}}, {{ 2, 3},{0,37,3, 3,3,3, 3, 30,0}}, - {{-2, 2},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{-1, 2},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{ 0, 2},{86, 6,11, 1,1, 1, 1, 2,0}}, {{ 1, 2},{ 0, 7,13, 1,1,1,21, 32,0}}, {{ 2, 2},{0,37,3, 3,3,3, 3, 2,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, - {{-4, 1},{0, 4,4, 4,4,4,4, 0,0}}, {{-3, 1},{0, 4,4, 4,4, 4, 4, 4,0}}, {{-2, 1},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{-1, 1},{86, 5,11, 1,1,1, 1, 2,0}}, {{ 0, 1},{86, 6,12, 1,1, 1, 1, 2,0}}, {{ 1, 1},{86, 8, 6, 10,1,1, 1, 2,0}}, {{ 2, 1},{0,87,7, 19,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, - {{-4, 0},{0,37,3, 3,3,3,3, 0,0}}, {{-3, 0},{0, 7,1, 1,1,21,32, 32,0}}, {{-2, 0},{86, 6,11, 1,1,1, 1, 2,0}}, {{-1, 0},{86, 6,12, 1,1,1, 1, 2,0}}, {{ 0, 0},{86, 8, 5, 10,1, 1,77, 2,0}}, {{ 1, 0},{ 0, 0, 4, 4,4,4, 4, 4,0}}, {{ 2, 0},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 3, 0},{0,0, 4, 4,4,4,4, 40,0}}, - {{-4,-1},{0,37,3, 3,3,3,3, 0,0}}, {{-3,-1},{0,37,3, 3,3, 3, 3, 2,0}}, {{-2,-1},{ 0, 7,13, 1,1,1,21, 32,0}}, {{-1,-1},{86, 8, 6, 10,1,1, 1, 2,0}}, {{ 0,-1},{ 0, 0, 4, 4,4, 4, 4, 4,0}}, {{ 1,-1},{ 0, 0, 4, 4,4,4, 4, 4,0}}, - {{-3,-2},{0,37,3, 3,3, 3, 3, 30,0}}, {{-2,-2},{ 0,37, 3, 3,3,3, 3, 2,0}}, {{-1,-2},{ 0,87, 7, 19,1,1,21, 32,0}}, {{ 0,-2},{ 0, 0, 4, 4,4, 4, 4, 4,0}}, - {{-2,-3},{ 0, 0,37, 3,3,3, 3, 30,0}}, {{-1,-3},{ 0, 0,37, 3,3,3, 3, 30,0}}, {{ 0,-3},{ 0, 0, 4, 4,4, 4, 4, 40,0}}, - }, + -- Diagonal slope down (northwest reference). + -- Review water tunnel (-3,0), (0,3) stacked 32 -- with arch, overdoing seal, could raise height of 21 or remove top 32. + -- Review water tunnel (-1,-2), (2,1) -- not solid seal, but water's not going to go up. + [30] = { {{-1, 4},{ 0, 4, 4, 4,4,4, 4, 0,0}}, {{ 0, 4},{ 0,37, 3, 3,3, 3, 3, 0,0}}, {{ 1, 4},{ 0,37, 3, 3,3,3, 3, 0,0}}, + {{-1, 3},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{ 0, 3},{ 0, 7, 1, 1,1,21,32, 32,0}}, {{ 1, 3},{ 0,37, 3, 3,3,3, 3, 2,0}}, {{ 2, 3},{0,37,3, 3,3,3, 3, 30,0}}, + {{-2, 2},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{-1, 2},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{ 0, 2},{86, 6,11, 1,1, 1, 1, 2,0}}, {{ 1, 2},{ 0, 7,13, 1,1,1,21, 32,0}}, {{ 2, 2},{0,37,3, 3,3,3, 3, 2,0}}, {{ 3, 2},{0,0,37, 3,3,3,3, 30,0}}, + {{-4, 1},{0, 4,4, 4,4,4,4, 0,0}}, {{-3, 1},{0, 4,4, 4,4, 4, 4, 4,0}}, {{-2, 1},{ 0, 4, 4, 4,4,4, 4, 4,0}}, {{-1, 1},{86, 5,11, 1,1,1, 1, 2,0}}, {{ 0, 1},{86, 6,12, 1,1, 1, 1, 2,0}}, {{ 1, 1},{86, 8, 6, 10,1,1, 1, 2,0}}, {{ 2, 1},{0,87,7, 19,1,1,21, 32,0}}, {{ 3, 1},{0,0,37, 3,3,3,3, 30,0}}, + {{-4, 0},{0,37,3, 3,3,3,3, 0,0}}, {{-3, 0},{0, 7,1, 1,1,21,32, 32,0}}, {{-2, 0},{86, 6,11, 1,1,1, 1, 2,0}}, {{-1, 0},{86, 6,12, 1,1,1, 1, 2,0}}, {{ 0, 0},{86, 8, 5, 10,1, 1,77, 2,0}}, {{ 1, 0},{ 0, 0, 4, 4,4,4, 4, 4,0}}, {{ 2, 0},{0, 0,4, 4,4,4, 4, 4,0}}, {{ 3, 0},{0,0, 4, 4,4,4,4, 40,0}}, + {{-4,-1},{0,37,3, 3,3,3,3, 0,0}}, {{-3,-1},{0,37,3, 3,3, 3, 3, 2,0}}, {{-2,-1},{ 0, 7,13, 1,1,1,21, 32,0}}, {{-1,-1},{86, 8, 6, 10,1,1, 1, 2,0}}, {{ 0,-1},{ 0, 0, 4, 4,4, 4, 4, 4,0}}, {{ 1,-1},{ 0, 0, 4, 4,4,4, 4, 4,0}}, + {{-3,-2},{0,37,3, 3,3, 3, 3, 30,0}}, {{-2,-2},{ 0,37, 3, 3,3,3, 3, 2,0}}, {{-1,-2},{ 0,87, 7, 19,1,1,21, 32,0}}, {{ 0,-2},{ 0, 0, 4, 4,4, 4, 4, 4,0}}, + {{-2,-3},{ 0, 0,37, 3,3,3, 3, 30,0}}, {{-1,-3},{ 0, 0,37, 3,3,3, 3, 30,0}}, {{ 0,-3},{ 0, 0, 4, 4,4, 4, 4, 40,0}}, + }, - -- Diagonal slope up (northwest reference). - -- Review water tunnel (-2,-3), (-1,-3), (0,-3), (3,0), (3,1), (3,2) -- without arch, same as slope down, overdoing seal. - -- Review water tunnel (-3,0), (0,3) -- not solid seal, but water's not going to go up. - [31] = { {{-1, 4},{0, 0, 0, 4,4,4, 4, 4,40}}, {{ 0, 4},{0, 0, 0, 37,3,3,3, 3,30}}, {{ 1, 4},{0, 0,37, 3,3,3,3, 3,30}}, - {{-1, 3},{0, 0, 0, 4,4,4, 4, 4, 4}}, {{ 0, 3},{0, 0,87, 7,1,1,1, 21,32}}, {{ 1, 3},{0, 0,37, 3,3,3,3, 3, 3}}, {{ 2, 3},{0,0,37, 3,3,3,3, 3,30}}, - {{-2, 2},{0, 0, 0, 4,4,4,4, 4, 4}}, {{-1, 2},{0, 0, 0, 4,4,4, 4, 4, 4}}, {{ 0, 2},{0,86, 8, 6,1,1,1, 1, 2}}, {{ 1, 2},{0, 0, 7, 13,1,1,1, 21,32}}, {{ 2, 2},{0,0,37, 3,3,3,3, 3, 3}}, {{ 3, 2},{0,0,37, 3,3,3,3, 3,0}}, - {{-4, 1},{0,0,0, 4,4,4,4, 4,40}}, {{-3, 1},{0,0, 0, 4,4,4,4, 4, 4}}, {{-2, 1},{0, 0, 0, 4,4,4,4, 4, 4}}, {{-1, 1},{0,86, 8, 5,1,1, 1, 1, 2}}, {{ 0, 1},{0,86, 6, 12,1,1,1, 1, 2}}, {{ 1, 1},{0,86, 6, 11,1,1,1, 1, 2}}, {{ 2, 1},{0,0, 7, 1,1,1,21, 32, 4}}, {{ 3, 1},{0,0,37, 3,3,3,3, 3,0}}, - {{-4, 0},{0,0,0, 37,3,3,3, 3,30}}, {{-3, 0},{0,0,87, 7,1,1,1, 21,32}}, {{-2, 0},{0,86, 8, 6,1,1,1, 1, 2}}, {{-1, 0},{0,86, 6, 12,1,1, 1, 1, 2}}, {{ 0, 0},{0,86, 5, 11,1,1,1, 77, 2}}, {{ 1, 0},{0, 0, 4, 4,4,4,4, 4, 4}}, {{ 2, 0},{0,0, 4, 4,4,4,4, 4, 4}}, {{ 3, 0},{0,0, 4, 4,4,4,4, 4,0}}, - {{-4,-1},{0,0,3, 37,3,3,3, 3,30}}, {{-3,-1},{0,0,37, 3,3,3,3, 3, 3}}, {{-2,-1},{0, 0, 7, 13,1,1,1, 21,32}}, {{-1,-1},{0,86, 6, 11,1,1, 1, 1, 2}}, {{ 0,-1},{0, 0, 4, 4,4,4,4, 4, 4}}, {{ 1,-1},{0, 0, 4, 4,4,4,4, 4, 4}}, - {{-3,-2},{0,0,37, 3,3,3,3, 3,30}}, {{-2,-2},{0, 0,37, 3,3,3,3, 3, 3}}, {{-1,-2},{0, 0, 7, 1,1,1,21, 32, 4}}, {{ 0,-2},{0, 0, 4, 4,4,4,4, 4, 4}}, - {{-2,-3},{0, 0,37, 3,3,3,3, 3, 0}}, {{-1,-3},{0, 0,37, 3,3,3, 3, 3, 0}}, {{ 0,-3},{0, 0, 4, 4,4,4,4, 4, 0}}, - }, - } + -- Diagonal slope up (northwest reference). + -- Review water tunnel (-2,-3), (-1,-3), (0,-3), (3,0), (3,1), (3,2) -- without arch, same as slope down, overdoing seal. + -- Review water tunnel (-3,0), (0,3) -- not solid seal, but water's not going to go up. + [31] = { {{-1, 4},{0, 0, 0, 4,4,4, 4, 4,40}}, {{ 0, 4},{0, 0, 0, 37,3,3,3, 3,30}}, {{ 1, 4},{0, 0,37, 3,3,3,3, 3,30}}, + {{-1, 3},{0, 0, 0, 4,4,4, 4, 4, 4}}, {{ 0, 3},{0, 0,87, 7,1,1,1, 21,32}}, {{ 1, 3},{0, 0,37, 3,3,3,3, 3, 3}}, {{ 2, 3},{0,0,37, 3,3,3,3, 3,30}}, + {{-2, 2},{0, 0, 0, 4,4,4,4, 4, 4}}, {{-1, 2},{0, 0, 0, 4,4,4, 4, 4, 4}}, {{ 0, 2},{0,86, 8, 6,1,1,1, 1, 2}}, {{ 1, 2},{0, 0, 7, 13,1,1,1, 21,32}}, {{ 2, 2},{0,0,37, 3,3,3,3, 3, 3}}, {{ 3, 2},{0,0,37, 3,3,3,3, 3,0}}, + {{-4, 1},{0,0,0, 4,4,4,4, 4,40}}, {{-3, 1},{0,0, 0, 4,4,4,4, 4, 4}}, {{-2, 1},{0, 0, 0, 4,4,4,4, 4, 4}}, {{-1, 1},{0,86, 8, 5,1,1, 1, 1, 2}}, {{ 0, 1},{0,86, 6, 12,1,1,1, 1, 2}}, {{ 1, 1},{0,86, 6, 11,1,1,1, 1, 2}}, {{ 2, 1},{0,0, 7, 1,1,1,21, 32, 4}}, {{ 3, 1},{0,0,37, 3,3,3,3, 3,0}}, + {{-4, 0},{0,0,0, 37,3,3,3, 3,30}}, {{-3, 0},{0,0,87, 7,1,1,1, 21,32}}, {{-2, 0},{0,86, 8, 6,1,1,1, 1, 2}}, {{-1, 0},{0,86, 6, 12,1,1, 1, 1, 2}}, {{ 0, 0},{0,86, 5, 11,1,1,1, 77, 2}}, {{ 1, 0},{0, 0, 4, 4,4,4,4, 4, 4}}, {{ 2, 0},{0,0, 4, 4,4,4,4, 4, 4}}, {{ 3, 0},{0,0, 4, 4,4,4,4, 4,0}}, + {{-4,-1},{0,0,3, 37,3,3,3, 3,30}}, {{-3,-1},{0,0,37, 3,3,3,3, 3, 3}}, {{-2,-1},{0, 0, 7, 13,1,1,1, 21,32}}, {{-1,-1},{0,86, 6, 11,1,1, 1, 1, 2}}, {{ 0,-1},{0, 0, 4, 4,4,4,4, 4, 4}}, {{ 1,-1},{0, 0, 4, 4,4,4,4, 4, 4}}, + {{-3,-2},{0,0,37, 3,3,3,3, 3,30}}, {{-2,-2},{0, 0,37, 3,3,3,3, 3, 3}}, {{-1,-2},{0, 0, 7, 1,1,1,21, 32, 4}}, {{ 0,-2},{0, 0, 4, 4,4,4,4, 4, 4}}, + {{-2,-3},{0, 0,37, 3,3,3,3, 3, 0}}, {{-1,-3},{0, 0,37, 3,3,3, 3, 3, 0}}, {{ 0,-3},{0, 0, 4, 4,4,4,4, 4, 0}}, + }, + } - local dig_lookup = { -- Defines dig pattern, flip, and rotation for each direction. - [0] = {1, 0, 0}, [1] = {2, 0, 0}, [2] = {3, 0, 0}, [3] = {2, 1, -1}, - [4] = {1, 0, -1}, [5] = {2, 0, -1}, [6] = {3, 1, 0}, [7] = {2, 1, 0}, - [8] = {1, 1, 0}, [9] = {2, 2, 0}, [10] = {3, 2, 0}, [11] = {2, 1, 1}, - [12] = {1, 0, 1}, [13] = {2, 0, 1}, [14] = {3, 0, 1}, [15] = {2, -1, 0}, - [16] = {11, 0, 0}, [17] = {31, 0, 0}, [18] = {11, 0, -1}, [19] = {31, 1, 0}, - [20] = {11, 1, 0}, [21] = {31, 2, 0}, [22] = {11, 0, 1}, [23] = {31, -1, 0}, - [24] = {10, 0, 0}, [25] = {30, 0, 0}, [26] = {10, 0, -1}, [27] = {30, 1, 0}, - [28] = {10, 1, 0}, [29] = {30, 2, 0}, [30] = {10, 0, 1}, [31] = {30, -1, 0} - } + local dig_lookup = { -- Defines dig pattern, flip, and rotation for each direction. + [0] = {1, 0, 0}, [1] = {2, 0, 0}, [2] = {3, 0, 0}, [3] = {2, 1, -1}, + [4] = {1, 0, -1}, [5] = {2, 0, -1}, [6] = {3, 1, 0}, [7] = {2, 1, 0}, + [8] = {1, 1, 0}, [9] = {2, 2, 0}, [10] = {3, 2, 0}, [11] = {2, 1, 1}, + [12] = {1, 0, 1}, [13] = {2, 0, 1}, [14] = {3, 0, 1}, [15] = {2, -1, 0}, + [16] = {11, 0, 0}, [17] = {31, 0, 0}, [18] = {11, 0, -1}, [19] = {31, 1, 0}, + [20] = {11, 1, 0}, [21] = {31, 2, 0}, [22] = {11, 0, 1}, [23] = {31, -1, 0}, + [24] = {10, 0, 0}, [25] = {30, 0, 0}, [26] = {10, 0, -1}, [27] = {30, 1, 0}, + [28] = {10, 1, 0}, [29] = {30, 2, 0}, [30] = {10, 0, 1}, [31] = {30, -1, 0} + } - -- Pass horizontal and vertical directions to region functions. - -- Horizontal needed for angledstairs nodes, vertical helped combine functions. - local dir = {} - if cdir >= 24 then - dir.horiz = (cdir - 24) * 2 - dir.vert = -1 - elseif cdir >= 16 then - dir.horiz = (cdir - 16) * 2 - dir.vert = 1 - else - dir.horiz = cdir - dir.vert = 0 - end - - local dig_list = dig_patterns[dig_lookup[cdir][1]] - local flip = dig_lookup[cdir][2] - local rotation = dig_lookup[cdir][3] - run_list(dig_list, flip, rotation, dir, user, pointed_thing) + -- Pass horizontal and vertical directions to region functions. + -- Horizontal needed for angledstairs nodes, vertical helped combine functions. + local dir = {} + if cdir >= 24 then + dir.horiz = (cdir - 24) * 2 + dir.vert = -1 + elseif cdir >= 16 then + dir.horiz = (cdir - 16) * 2 + dir.vert = 1 + else + dir.horiz = cdir + dir.vert = 0 end + + local dig_list = dig_patterns[dig_lookup[cdir][1]] + local flip = dig_lookup[cdir][2] + local rotation = dig_lookup[cdir][3] + run_list(dig_list, flip, rotation, dir, user, pointed_thing) end -- Display User Options menu. @@ -966,60 +966,66 @@ for i,img in ipairs(images) do -- Left mouse: Dig single node or dig tunnel. on_use = function(itemstack, player, pointed_thing) - local pname = player:get_player_name() - local pos = pointed_thing.under - local key_stats = player:get_player_control() - if key_stats.sneak or key_stats.aux1 then -- With sneak or aux1, dig tunnel - -- if advtrains_track, I lower positions of pointed_thing to right below track, but keep name the same. Same with snow cover. - local name = minetest.get_node(pointed_thing.under).name - -- if minetest.registered_nodes[name].groups.advtrains_track == 1 then - if string.match(name, "dtrack") or name == "default:snow" or name == angled_slab_not_desert or name == angled_slab_desert then - pointed_thing.under = vector.add(pointed_thing.under, {x=0, y=-1, z=0}) - --pointed_thing.above = vector.add(pointed_thing.above, {x=0, y=-1, z=0}) -- don't currently use this - end - minetest.sound_play("default_dig_dig_immediate", {pos=pointed_thing.under, max_hear_distance = 8, gain = 1.0}) - dig_tunnel(i-1, player, pointed_thing) - if not user_config[pname].continuous_updown then - tunnelmaker[pname].updown = 0 -- reset to horizontal after one use - end - else -- No modifiers, dig single node, if pointing to one - if pos ~= nil and minetest.check_player_privs(player, "tunneling") then - minetest.node_dig(pos, minetest.get_node(pos), player) - minetest.sound_play("default_dig_dig_immediate", {pos=pos, max_hear_distance = 8, gain = 0.5}) + if minetest.check_player_privs(player, "tunneling") then -- Must have tunneling privs. + local pname = player:get_player_name() + local pos = pointed_thing.under + local key_stats = player:get_player_control() + if key_stats.sneak or key_stats.aux1 then -- With sneak or aux1, dig tunnel + -- if advtrains_track, I lower positions of pointed_thing to right below track, but keep name the same. Same with snow cover. + local name = minetest.get_node(pointed_thing.under).name + -- if minetest.registered_nodes[name].groups.advtrains_track == 1 then + if string.match(name, "dtrack") or name == "default:snow" or name == angled_slab_not_desert or name == angled_slab_desert then + pointed_thing.under = vector.add(pointed_thing.under, {x=0, y=-1, z=0}) + --pointed_thing.above = vector.add(pointed_thing.above, {x=0, y=-1, z=0}) -- don't currently use this + end + minetest.sound_play("default_dig_dig_immediate", {pos=pointed_thing.under, max_hear_distance = 8, gain = 1.0}) + dig_tunnel(i-1, player, pointed_thing) + if not user_config[pname].continuous_updown then + tunnelmaker[pname].updown = 0 -- reset to horizontal after one use + end + else -- No modifiers, dig single node, if pointing to one + if pos ~= nil then + minetest.node_dig(pos, minetest.get_node(pos), player) + minetest.sound_play("default_dig_dig_immediate", {pos=pos, max_hear_distance = 8, gain = 0.5}) + end end end end, -- Right mouse: Toggle up/down or bring up User Options menu. (Also dig tunnel for android.) on_place = function(itemstack, placer, pointed_thing) - local pname = placer:get_player_name() - local key_stats = placer:get_player_control() - if key_stats.sneak then -- With sneak, bring up User Options menu. - display_menu(placer) - elseif key_stats.aux1 and pointed_thing.type=="node" then -- With aux1, dig tunnel. - -- if advtrains_track, I lower positions of pointed_thing to right below track, but keep name the same. Same with snow cover. - local name = minetest.get_node(pointed_thing.under).name - -- if minetest.registered_nodes[name].groups.advtrains_track == 1 then - if string.match(name, "dtrack") or name == "default:snow" or name == angled_slab_not_desert or name == angled_slab_desert then - pointed_thing.under = vector.add(pointed_thing.under, {x=0, y=-1, z=0}) - --pointed_thing.above = vector.add(pointed_thing.above, {x=0, y=-1, z=0}) -- don't currently use this + if minetest.check_player_privs(placer, "tunneling") then -- Must have tunneling privs. + local pname = placer:get_player_name() + local key_stats = placer:get_player_control() + if key_stats.sneak then -- With sneak, bring up User Options menu. + display_menu(placer) + elseif key_stats.aux1 and pointed_thing.type=="node" then -- With aux1, dig tunnel. + -- if advtrains_track, I lower positions of pointed_thing to right below track, but keep name the same. Same with snow cover. + local name = minetest.get_node(pointed_thing.under).name + -- if minetest.registered_nodes[name].groups.advtrains_track == 1 then + if string.match(name, "dtrack") or name == "default:snow" or name == angled_slab_not_desert or name == angled_slab_desert then + pointed_thing.under = vector.add(pointed_thing.under, {x=0, y=-1, z=0}) + --pointed_thing.above = vector.add(pointed_thing.above, {x=0, y=-1, z=0}) -- don't currently use this + end + minetest.sound_play("default_dig_dig_immediate", {pos=pointed_thing.under, max_hear_distance = 8, gain = 1.0}) + dig_tunnel(i-1, placer, pointed_thing) + if not user_config[pname].continuous_updown then + tunnelmaker[pname].updown = 0 -- reset to horizontal after one use + end + else -- No modifiers, toggle up/down digging directions. + tunnelmaker[pname].updown = (tunnelmaker[pname].updown + 1) % 3 + tunnelmaker[pname].lastpos = { x = placer:get_pos().x, y = placer:get_pos().y, z = placer:get_pos().z } end - minetest.sound_play("default_dig_dig_immediate", {pos=pointed_thing.under, max_hear_distance = 8, gain = 1.0}) - dig_tunnel(i-1, placer, pointed_thing) - if not user_config[pname].continuous_updown then - tunnelmaker[pname].updown = 0 -- reset to horizontal after one use - end - else -- No modifiers, toggle up/down digging directions. - tunnelmaker[pname].updown = (tunnelmaker[pname].updown + 1) % 3 - tunnelmaker[pname].lastpos = { x = placer:get_pos().x, y = placer:get_pos().y, z = placer:get_pos().z } end end, -- Also bring up User Options menu, when not pointing to anything. on_secondary_use = function(itemstack, placer, pointed_thing) - local key_stats = placer:get_player_control() - if key_stats.sneak then - display_menu(placer) + if minetest.check_player_privs(placer, "tunneling") then -- Must have tunneling privs. + local key_stats = placer:get_player_control() + if key_stats.sneak then + display_menu(placer) + end end end, }