diff --git a/README.md b/README.md index 8d74a6a..56f7c84 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,54 @@ +Tunnelmaker 2.0 +=============== + +A Minetest Mod to easily create arbitrarily curved tunnels, pathways, and bridges. + ![Tunnelmaker Screenshot](screenshot.png "Tunnelmaker") -A Minetest Mod to easily create arbitrarily curved tunnels. - -Especially designed to make laying track for the advtrains mod easier. - -by David G (kestral246@gmail.com) +By David G (kestral246@gmail.com), with significant contributions by Mikola. +Warning: Version 2 only supports Minetest 5.0+. +----------------------------------------------- +In addition there's been a MAJOR change with controls. +------------------------------------------------------ +For Minetest 0.4.x, use the git branch legacy, or the following zip file: [tunnelmaker-legacy.zip](https://github.com/kestral246/tunnelmaker/archive/legacy.zip). Features -------- -- Digs "arched" tunnels (5 nodes wide and 5 nodes tall) in all sixteen possible advtrains track directions with one click. Also digs up or down in the eight possible advtrains slope track directions. -- Fills in tunnel floor (central 3 nodes wide) with stone. Outside of tunnels this can be used to clear ground, provide cuts and fills, and build simple stone bridges. However, bridge supports will need to be added manually. -- **New:** Tunneling through water has been enabled by default. This will add a glass enclosure around the tunnel as you go. Configuration variable to disable, if desired. -- **New:** Height of tunnel and whether to use "arches" are now configuration options. (Defaults to height of 5 with "arches", which matches previous release.) -- Requires "tunneling" privilege, checks protections, and only works in creative mode. +- Create paths, bridges, and tunnels in all sixteen possible advtrains track directions with one click. +- Also digs up or down in the eight possible advtrains slope track directions. +- Digging mode and options can be set using new User Options menu. +- Supports Advanced trains mod with gravel embankment, arched and optionally lined tunnels, and two widths of bridges. +- Supports Bike mod with two widths of cobblestone pathways and bridges, along with unlined tunnels. +- Supports general excavation with unlined and lined tunnels. +- Adds reference nodes to help digging and laying advtrains track—now easy to remove when done. +- Adds glass enclosure when in water to create water tunnels. +- Requires "tunneling" privilege, and checks protections before digging. +- No crafting recipe, so needs to be given to player. +- Works in both creative and survival modes, but tunneling does not place any nodes into user's inventory. +- Supports client-side translation files. Currently only have Russian and my attempt at a French translation. **Other languages will be gratefully accepted.** Reference template file is available in locale directory. -![Simple Stone Bridge](images/simple_stone_bridge.png "Simple Stone Bridge") +![Bike path up mountain](images/bike_path.png "Bike path up mountain") +Controls (Caution MAJOR change!) +-------------------------------- +- **Left-click:** Super dig one node. One click digs any node (non-repeating) and places it in player's inventory. However, it can't be used to pick up dropped items. +- **Shift-left-click:** Dig tunnel in direction player pointed. Note that this won't place any of the dug nodes in player's inventory. +- **Right-click:** Cycle through vertical digging modes, up, down, and horizontal. +- **Shift-right-click:** Bring up User Options menu (see below). + +In addition: + +- **Aux-left-click:** Also digs tunnel (useful if flying). +- **Aux-right-click:** Also digs tunnel (needed for Android). + +The reason for this change is that while updating this mod I had to test it a lot, and I've lost track of the number of times I've accidentally pressed right-click and dug a tunnel when I didn't want to. The only solution was to move tunnel digging to another key combination. How to enable ------------- -- Enable creative mode. This mod is too overpowered for survival mode. -- Give player "tunneling" privilege (/grant <player> tunneling). -- To give player a tunnelmaker tool use (/give <player> tunnelmaker:1). *Or see below for crafting recipe.* - +- Install tunnelmaker mod, requires default and stairs. For nicer bike path ramps, I recommend installing the angledstairs mod, which was used for the picture above, but it's not required. +- Grant player "tunneling" privilege (/grant <player> tunneling). +- To give player a tunnelmaker tool use (/give <player> tunnelmaker:tool1). How to dig ---------- @@ -31,7 +56,7 @@ How to dig - Move to digging location and highlight node at ground level. (Gray node in diagrams marked with an '×'.) - Point player in desired digging direction. (Inventory icon will change to show current direction.) -- Right-click mouse to dig tunnel. +- Hold down shift key while left-clicking mouse to dig tunnel. Digging for slopes @@ -40,12 +65,26 @@ Digging for slopes - Move to digging location and highlight node at ground level. - Point player in desired digging direction. -- Hold sneak key (shift on pc) and right-click mouse to select digging mode. Inventory icon will cycle through possible modes with each click: 'U' for digging up, 'D' for digging down, and no letter for default horizontal. -- Release sneak key and right-click mouse to dig tunnel. -- *Mode will reset after each dig. It will also reset if player turns or moves.* +- Right-click mouse to select digging mode. Inventory icon will cycle through possible modes with each click: 'U' for digging up, 'D' for digging down, and no letter for default horizontal. +- Shift-left-click mouse to dig tunnel. +- There is a user option to control whether to reset direction after each dig or not (see below). ![Tunnelmaker Icons](images/icons.png "Tunnelmaker Icons") +User Options menu +---------------- +Use shift-right-click to bring up this menu. + +![Tunnelmaker User Options](images/user_options.gif "Tunnelmaker User Options") + +Descriptions of all the options: + +- **Digging mode** Select one of the three digging modes: General purpose, Advanced trains, or Bike paths. +- **Wide paths / lined tunnels** Select between narrow and wide paths, and whether tunnels are lined with stone or not. +- **Continuous up/down digging** Don't reset up/down after each dig. +- **Clear tree cover** Remove all plant material above dig up to 30 nodes above ground. CPU intensive, so shuts off after two minutes. +- **Remove reference nodes** Easily remove reference nodes by walking over them. Also shuts off after two minutes. +- **Lock desert mode to: either "Desert" or "Non-desert"** Option only available when "add_desert_material = true" has been added to minetest.conf. Overrides use of desert materials in desert biomes. Useful for transition regions. Advtrains digging reference --------------------------- @@ -60,36 +99,12 @@ The following diagrams show how to make curved tunnels that support the differen ![Turns from 45°](images/dir45.png "Turns from 45") - -Other details -------------- -- Using left-click digs similarly to a steel pickaxe, which is useful for making minor adjustments. -- Cobblestone references are placed to show where to continue digging for laying advtrains track. (Configuration variable to disable.) -- If the ceiling is going to be a falling node, it is replaced with cobblestone before digging out below it. -- Torches are placed only if ceiling is stone or desert_stone. (Torch configuration options added.) -- Continuous up/down digging configuration option added. -- For minetest version 5.0+, when in desert biomes the fills will change to the desert versions of stone or cobble. -- Won't dig advtrains track. Highlighting track will dig based on ground below it. However, be careful with slope track, since this probably isn't what you want. Also this won't work with ATC track, since it also uses right-click. - - -Crafting guide --------------- -``` - diamondblock mese_block diamondblock - mese_block diamondblock mese_block - diamondblock mese_block diamondblock -``` - -![Crafting guide](images/crafting.png "Crafting guide") - - License ------- - **textures:** License CC0-1.0 - **code:** My changes to original code are CC0-1.0 - **original compassgps license:** Original code by Echo, PilzAdam, and TeTpaAka is WTFPL. Kilarin (Donald Hines) changes are CC0 (No rights reserved) - Thanks ------ - [advtrains](https://github.com/orwell96/advtrains/) / orwell96, et. diff --git a/changelog.txt b/changelog.txt deleted file mode 100644 index 4128da1..0000000 --- a/changelog.txt +++ /dev/null @@ -1,100 +0,0 @@ -tunnelmaker change log --- Version 1.0 --- Add two additional user configurations: --- Set height of tunnels. --- Optionally disable "arches". --- Fixed bug in one reference block placement. - --- Version 0.9.9 --- Add additional user configurations. --- Optionally disable adding torches. --- Optionally change search distance for torches. --- Optionally allow continuous up/down digging, without resetting each time. - --- Version 0.9.8 --- Optionally add back in water tunnels. --- Optionally disable placing cobblestone references on the ground. --- Edit init.lua to change these configuration variables (near top of file). - --- Version 0.9.7 --- Revert back to checking for dtrack by name, instead of groups.advtrains_track. --- Groups doesn't work in latest versions of advtrains. --- Changed left-click digging to steel_pick equivalent instead of wood_pick. - --- Version 0.9.6 --- Delete player's global state when player leaves. - --- Version 0.9.5 --- Add cobble braces for bridges if they would be air. - --- Version 0.9.4 --- Major update to build in support for digging up and down. --- Digging up and down only supports orthogonal and 45deg directions to match advtrains track. --- (Note: advtrains track requires at least one horizontal track matching slope before making any turns.) --- To select updown direction, hold sneak key (shift) while right-clicking tunnelmaker. --- One click selects up (Yellow 'U' on icon), second click selects down (Yellow 'D' on icon), --- third click returns back to horizontal (no letter on icon). --- Updown state can also be reset by rotating to different icon, or moving by some amount (still tuning this). --- Once updown state is selected, release sneak key and use right-click like normal. --- After digging, updown state will also be reset to horizontal. --- Known changes/issues caused by using sneak key: --- • Can't dig up or down while flying. --- • Digall won't apply its function when right-clicking tunnelmaker. --- • Can't sneak right-click on ATC track to dig below them. - --- Version 0.9.3 --- Tweak cdir == 2 (nw) digging pattern. --- Clean up some old debug statements. - --- Version 0.9.2 --- Continue work making tunnelmaker play nice with advtrains track. --- Per Orwell's request, changed method for determining if node is advtrains track. --- Instead of searching for dtrack in name of node, --- I check whether the node belongs to the advtrains_track group using: --- if minetest.registered_nodes[name].groups.advtrains_track == 1 then --- --- Note that one can't right click ATC track with tunnelmaker, that track overrides right click. --- Trying to right click on slope track probably won't do what is wanted. Right now it treats --- it like any other track, and digs the ground level. - --- Version 0.9.1 --- 1. Try to play nicer with already placed advtrains track (dtrack*). --- A. Don't dig dtrack nodes. --- This allows expanding or extending tunnels where track has already been laid. --- However this causes issues when using tunnelmaker to raise or lower track. --- Trying to dig tunnel one node above track won't fill where placed track exists. --- Trying to dig tunnel one node below track will cause existing track to drop. --- B. If pointing to dtrack node, assume user actually wants to point to ground below track. --- Lower positions of pointed_thing by one node, while keeping name the same. --- This assumes that existing track is sitting on valid node. --- 2. Restruction direction code to make it much shorter. --- 3. Fixed bug in implementation of SSW digging pattern. --- --- Version 0.9.0 --- 1. Updated digging patterns to fix minor irregularities. --- 2. Added protections for tunneling in water. --- Adds glass walls around tunnel whenever there is water. --- Adds glass endcap at end to protect from flooding while tunneling. --- Note that this can place undesired glass when digging next to ground-level water. This --- won't happen as long as you're one node higher than the water. --- 3. Restructured code again. Code is longer, but simpler to understand. - --- Version 0.8.1 --- Test if air before digging. Cleans up air not diggable INFO messages. --- Added test for desert-type biomes, which lets me start using biome-appropriate fill. --- needs minetest 0.5.0+ to correctly flag desert biomes --- however, if api doesn't exist (using 0.4.x), test just always returns false - --- Version 0.8.0 --- Changed from dig_node to node_dig (based on what matyilona200 did for the Tunneltest mod) --- Places only a single instance of each type of block dug in inventory --- Doesn't cause blocks to drop in 0.5.0-dev --- Works with digall mod, but make sure it's deactivated before tunneling! - --- Version 0.7.0 --- Added test for fallable blocks in ceiling and replace them with cobblestone. --- Fixed bug where I was digging from lower blocks to higher blocks. --- Simplified and cleaned up tunneling code. - --- Version 0.6.0 --- Increased width and height of tunnel created. diff --git a/depends.txt b/depends.txt index 4ad96d5..2845b34 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1,3 @@ default +stairs +angledstairs? diff --git a/images/bike_path.png b/images/bike_path.png new file mode 100644 index 0000000..824e626 Binary files /dev/null and b/images/bike_path.png differ diff --git a/images/crafting.png b/images/crafting.png deleted file mode 100644 index c115048..0000000 Binary files a/images/crafting.png and /dev/null differ diff --git a/images/user_config.png b/images/user_config.png new file mode 100644 index 0000000..2132441 Binary files /dev/null and b/images/user_config.png differ diff --git a/images/user_options.gif b/images/user_options.gif new file mode 100644 index 0000000..5676e5a Binary files /dev/null and b/images/user_options.gif differ diff --git a/init.lua b/init.lua index c420920..7586780 100644 --- a/init.lua +++ b/init.lua @@ -4,10 +4,22 @@ -- all 16 track directions, along with slopes up and down. -- -- by David G (kestral246@gmail.com) +-- and by Mikola --- Version 1.0 - 2019-01-02 +-- Version 2.0 - 2019-03-04 --- based on compassgps 2.7 and compass 0.5 +-- New controls for operation +----------------------------- +-- Left-click: dig one node. +-- Shift-left-click: dig tunnel based on direction player pointing. +-- Right-click: cycle through vertical digging directions. +-- Shift-right-click: bring up User Options menu. +-- +-- In addition: +-- Aux-left-click also digs tunnels (useful if flying). +-- Aux-right-click also digs tunnels (needed for Android.) + +-- Icon display based on compassgps 2.7 and compass 0.5 -- To the extent possible under law, the author(s) have dedicated all copyright and related -- and neighboring rights to this software to the public domain worldwide. This software is @@ -17,59 +29,198 @@ -- software. If not, see . +-- User Options defaults (for minetest.conf) +------------------------------------------- +-- Initial digging mode for User Options (1, 2, or 3). +local tunnel_mode_default = tonumber(minetest.settings:get("tunnel_digging_mode") or 2) + +-- Train tunnels can be lined with a coating. +local add_lined_tunnels_default = minetest.settings:get_bool("add_lined_tunnels", false) + +-- Continuous updown digging, which allows digging up/down multiple times without resetting mode. +local continuous_updown_default = minetest.settings:get_bool("continuous_updown_digging", false) + +-- Enable desert mode - can use different materials when in the desert. Requires Minetest 5.0+. +-- When desert mode is enabled, user gets additional option to Lock desert mode to current state +-- of being in desert or not. Useful to define materials used when in desert transition regions. +local add_desert_material = minetest.settings:get_bool("add_desert_material", false) + +-- Can use other lights in tunnels instead of torches. +local lighting_raw = minetest.settings:get("tunnel_lights") or "default:torch" + +-- Determine is light specifies param2. This allows lights such as moreblocks:slab_meselamp_1,20 where ,20 specifies ceiling orientation in param2 +local lighting = lighting_raw +local lighting_p2 = 0 +local p2 = string.find(lighting_raw, ',') +if p2 ~= nil then + lighting = string.sub(lighting_raw, 1, p2-1) + lighting_p2 = tonumber(string.sub(lighting_raw, p2+1) or 0) +end + +-- Set height for train tunnels (5 to 8). Currently matching version 1. +local tunnel_height_train = tonumber(minetest.settings:get("train_tunnel_height") or 5) + +-- Train tunnels (only) can have "arches" along the sides. +local add_arches_config = minetest.settings:get_bool("train_tunnel_arches", true) + -- Configuration variables +-- (If you'd really like some of these available to minetest.conf, request them.) -------------------------- --- Change the way certain features of this mod work. +-- Tunnel height, can vary for each digging mode. +local tunnel_height_general = 4 +local tunnel_height_bike = 5 --- Define height of tunnel. (default = 5) -local tunnel_height = 5 +-- Material for walls and floors (general and train path beyond embankment). +local tunnel_material = "default:stone" +local tunnel_material_desert = "default:desert_stone" --- Define whether to add "arches" along the sides. (default = true) -local tunnel_arch = true +-- Material for train track embankment +local embankment = "default:gravel" --- Allow tunneling through water. (default = true) --- Builds a glass enclosure around tunnel as you go. -local water_tunnels = true +-- Material for reference marks to help laying advtrains track. +-- This should be a fairly uncommon material with a distinctive look. +-- If this is changed, old reference marks won't be able to be removed by tunnelmaker tool. +local reference_marks = "default:stone_block" --- Add cobblestone reference points in ground. (default = true) --- This is helpful if creating tunnels for advtrains track. -local add_references = true +-- Time that reference marks are removed when this command enabled by the user. +local remove_refs_enable_time = 120 --- Add torches in ceiling. (default = true) --- Warning, tunnels will get really dark without this. -local add_torches = true +-- Material for bike paths. +local bike_path_material = "default:cobble" +local slab_not_desert = "stairs:slab_cobble" +local angled_slab_not_desert = "angledstairs:angled_slab_left_cobble" +local angled_stair_not_desert = "angledstairs:angled_stair_left_cobble" --- Radius to search for adjacent torches before placing torch. (default = 1) --- Values from 0 to 4 are reasonable. -local torch_search_radius = 1 +local bike_path_material_desert = "default:desert_cobble" +local slab_desert = "stairs:slab_desert_cobble" +local angled_slab_desert = "angledstairs:angled_slab_left_desert_cobble" +local angled_stair_desert = "angledstairs:angled_stair_left_desert_cobble" --- Allow digging up/down multiple times without resetting mode. (default = false) --- Changing direction will still reset, but moving or digging will not. -local continuous_updown_digging = false +-- Material for coating for walls in the water. +local glass_walls = "default:glass" --- End of configuration. +-- Max height to clear trees and other brush, when clear tree cover enabled. +local clear_trees_max = 30 + +-- Lights are placed in tunnel ceilings to light the way. +local add_lighting = true + +-- Light spacing: 1 for default:torch, 2 for brighter lights like default:mese_post_light. +-- Checked after mods loaded, so lights in mods don't need to be a dependency. +local lighting_search_radius = 1 + +-- Angledstairs mod gives much nicer bike path diagonal slopes. +local angledstairs_exists = false +if minetest.registered_nodes["angledstairs:angled_slab_left_cobble"] then + angledstairs_exists = true +end + +-- Determine if lights for tunnels support multiple orientations like torches. +-- Ceiling version should be defined in minetest.conf, but don't want other orientations to be deleted either. +local multi_orient = false +local base_lighting = "" +-- End of configuration +-- Require "tunneling" priviledge to be able to user tunnelmaker tool. minetest.register_privilege("tunneling", {description = "Allow use of tunnelmaker tool"}) +-- Support client-side translations +local S = minetest.get_translator(minetest.get_current_modname()) + -- Define top level variable to maintain per player state -local tunnelmaker = {} +tunnelmaker = {} +local user_config = {} + +-- Adjust light spacing and deal with multi-orientation lights. +minetest.register_on_mods_loaded(function() + if minetest.registered_nodes[lighting] then + if minetest.registered_nodes[lighting].light_source > 13 then + lighting_search_radius = 2 + end + if minetest.registered_nodes[lighting].drop then + multi_orient = true + base_lighting = minetest.registered_nodes[lighting].drop + -- minetest.debug("base = "..base_lighting) -- debug + end + end +end) -- Initialize player's state when player joins minetest.register_on_joinplayer(function(player) local pname = player:get_player_name() tunnelmaker[pname] = {updown = 0, lastdir = -1, lastpos = {x = 0, y = 0, z = 0}} + if tunnel_mode_default == 1 then + user_config[pname] = { + digging_mode = 1, -- General purpose mode + height = tunnel_height_general, + add_arches = false, + add_embankment = false, + add_refs = false, + add_floors = add_lined_tunnels_default, + add_wide_floors = add_lined_tunnels_default, + add_bike_ramps = false, + add_lined_tunnels = add_lined_tunnels_default, + continuous_updown = continuous_updown_default, + lock_desert_mode = false, + clear_trees = 0, + remove_refs = 0, + use_desert_material = add_desert_material and minetest.get_biome_data and + string.match(minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome), "desert"), + coating_not_desert = tunnel_material, + coating_desert = tunnel_material_desert, + } + elseif tunnel_mode_default == 2 then + user_config[pname] = { + digging_mode = 2, -- Advanced train mode + height = tunnel_height_train, + add_arches = add_arches_config, + add_embankment = true, + add_refs = true, + add_floors = true, + add_wide_floors = add_lined_tunnels_default, + add_bike_ramps = false, + add_lined_tunnels = add_lined_tunnels_default, + continuous_updown = continuous_updown_default, + lock_desert_mode = false, + clear_trees = 0, + remove_refs = 0, + use_desert_material = add_desert_material and minetest.get_biome_data and + string.match(minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome), "desert"), + coating_not_desert = tunnel_material, + coating_desert = tunnel_material_desert, + } + else + user_config[pname] = { + digging_mode = 3, -- Bike path mode + height = tunnel_height_bike, + add_arches = false, + add_embankment = false, + add_refs = true, + add_floors = true, + add_wide_floors = add_lined_tunnels_default, + add_bike_ramps = true, + add_lined_tunnels = add_lined_tunnels_default, + continuous_updown = continuous_updown_default, + lock_desert_mode = false, + clear_trees = 0, + remove_refs = 0, + use_desert_material = add_desert_material and minetest.get_biome_data and + string.match(minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome), "desert"), + coating_not_desert = bike_path_material, + coating_desert = bike_path_material_desert, + } + end end) -- Delete player's state when player leaves minetest.register_on_leaveplayer(function(player) local pname = player:get_player_name() - if tunnelmaker[pname] then - tunnelmaker[pname] = nil - end + if tunnelmaker[pname] then tunnelmaker[pname] = nil end + if user_config[pname] then user_config[pname] = nil end end) -local activewidth=8 --until I can find some way to get it from minetest +local activewidth=8 -- until I can find some way to get it from minetest minetest.register_globalstep(function(dtime) local players = minetest.get_connected_players() @@ -82,7 +233,7 @@ minetest.register_globalstep(function(dtime) -- first check to see if the user has a tunnelmaker, because if they don't -- there is no reason to waste time calculating bookmarks or spawnpoints. local wielded_item = player:get_wielded_item():get_name() - if string.sub(wielded_item, 0, 12) == "tunnelmaker:" then + if string.sub(wielded_item, 0, 16) == "tunnelmaker:tool" then -- if the player is wielding a tunnelmaker, change the wielded image wielded=true stackidx=player:get_wield_index() @@ -93,7 +244,7 @@ minetest.register_globalstep(function(dtime) -- is there a way to only check the activewidth items instead of entire list? -- problem being that arrays are not sorted in lua for i,stack in ipairs(player:get_inventory():get_list("main")) do - if i<=activewidth and string.sub(stack:get_name(), 0, 12) == "tunnelmaker:" then + if i<=activewidth and string.sub(stack:get_name(), 0, 16) == "tunnelmaker:tool" then activeinv=stack -- store the stack so we can update it later with new image stackidx=i -- store the index so we can add image at correct location gotatunnelmaker=true @@ -113,12 +264,12 @@ minetest.register_globalstep(function(dtime) return x*x + y*y + z*z end -- Calculate distance player has moved since setting up or down - local delta = distance2((player:getpos().x - tunnelmaker[pname].lastpos.x), - (player:getpos().y - tunnelmaker[pname].lastpos.y), - (player:getpos().z - tunnelmaker[pname].lastpos.z)) + local delta = distance2((player:get_pos().x - tunnelmaker[pname].lastpos.x), + (player:get_pos().y - tunnelmaker[pname].lastpos.y), + (player:get_pos().z - tunnelmaker[pname].lastpos.z)) -- If rotate to different direction, or move far enough from set position, reset to horizontal - if rawdir ~= tunnelmaker[pname].lastdir or (not continuous_updown_digging and delta > 0.2) then -- tune to make distance moved feel right + if rawdir ~= tunnelmaker[pname].lastdir or (not user_config[pname].continuous_updown and delta > 0.2) then -- tune to make distance moved feel right tunnelmaker[pname].lastdir = rawdir -- tunnelmaker[pname].lastpos = pos tunnelmaker[pname].updown = 0 -- reset updown to horizontal @@ -129,9 +280,9 @@ minetest.register_globalstep(function(dtime) end -- update tunnelmaker image to point at target if wielded then - player:set_wielded_item("tunnelmaker:"..tunnelmaker_image) + player:set_wielded_item("tunnelmaker:tool"..tunnelmaker_image) elseif activeinv then - player:get_inventory():set_stack("main",stackidx,"tunnelmaker:"..tunnelmaker_image) + player:get_inventory():set_stack("main",stackidx,"tunnelmaker:tool"..tunnelmaker_image) end end end @@ -150,567 +301,630 @@ local images = { "tunnelmaker_28.png", "tunnelmaker_29.png", "tunnelmaker_30.png", "tunnelmaker_31.png", } --- tests whether position is in desert-type biomes, such as desert, sandstone_desert, cold_desert, etc --- always just returns false if can't determine biome (i.e., using 0.4.x version) -local is_desert = function(pos) - if minetest.get_biome_data then - local cur_biome = minetest.get_biome_name( minetest.get_biome_data(pos).biome ) - return string.match(cur_biome, "desert") +-- Tests whether position is in desert-type biomes, such as desert, sandstone_desert, cold_desert, etc. +-- Always just returns false if can't determine biome (i.e., using 0.4.x version). +local is_desert = function(user, pos) + local pname = user:get_player_name() + if add_desert_material and minetest.get_biome_data then + if user_config[pname].lock_desert_mode then + return user_config[pname].use_desert_material + else + local cur_biome = minetest.get_biome_name( minetest.get_biome_data(pos).biome ) + return string.match(cur_biome, "desert") + end else return false end end --- add cobble reference block to point to next target location and to aid laying track --- in minetest 5.0+, desert biomes will use desert_cobble -local add_ref = function(x, y0, y1, z, user, pointed_thing) - local pos = vector.add(pointed_thing.under, {x=x, y=y0, z=z}) - if add_references and not minetest.is_protected(pos, user) then - if is_desert(pos) then - minetest.set_node(pos, {name = "default:desert_cobble"}) - else - minetest.set_node(pos, {name = "default:cobble"}) - end +-- Returns correct lining material based on whether to use desert or not. +local lining_material = function(user, pos) + local pname = user:get_player_name() + if is_desert(user, pos) then + return user_config[pname].coating_desert + else + return user_config[pname].coating_not_desert end end --- add cobble braces for bridges if they would be air --- in minetest 5.0+, desert biomes will use desert_cobble -local add_brace = function(x, y0, y1, z, user, pointed_thing) - local pos = vector.add(pointed_thing.under, {x=x, y=y0, z=z}) - local name = minetest.get_node(pos).name - if not minetest.is_protected(pos, user) and name == "air" then - if is_desert(pos) then - minetest.set_node(pos, {name = "default:desert_cobble"}) - else - minetest.set_node(pos, {name = "default:cobble"}) +-- Tests whether node is flammable, mainly vegetation. +local is_flammable = function(name) + local group_flammable = false + if minetest.registered_nodes[name] then + group_flammable = minetest.registered_nodes[name].groups.flammable and minetest.registered_nodes[name].groups.flammable > 0 + end + return group_flammable +end + +-- Test for torch or defined tunnel_lights (including multi-orientation versions). +local is_light = function(name) + local light = false + if minetest.registered_nodes[name] then + if minetest.registered_nodes[name].drop then -- multi-orient light, so compare with base light + local base = minetest.registered_nodes[name].drop + light = (base == "default:torch") or (multi_orient and base == base_lighting) + else -- not multi-orient or is base light + light = (name == lighting) or (name == base_lighting) end end + return light +end + +-- Combine all the checks to determine if digging should be allowed. +-- Currently supports area protection, unbreakable, and can_dig(). Others TBD. +local ok_to_tunnel = function(user, pos, name) + local ndef = minetest.registered_nodes[name] + if minetest.is_protected(pos, user) then + --minetest.debug("Protection error") + return false + elseif not (minetest.get_item_group(name, "unbreakable") == 0) then -- Unbreakable + --minetest.debug("Unbreakable node = "..name) + return false + elseif ndef.can_dig ~= nil then + --minetest.debug("Test can_dig = "..name) + return ndef.can_dig(pos, user) + else + return true + end end --- dig single node, but not torches, air (not diggable), or advtrain track -local dig_single = function(x, y, z, user, pointed_thing) - local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) - local name = minetest.get_node(pos).name - -- local isAdvtrack = minetest.registered_nodes[name].groups.advtrains_track == 1 - local isAdvtrack = string.match(name, "dtrack") - if not minetest.is_protected(pos, user) then - if water_tunnels and string.match(name, "water") then - minetest.set_node(pos, {name = "air"}) - elseif name ~= "air" and name ~= "default:torch_ceiling" and not isAdvtrack then - minetest.node_dig(pos, minetest.get_node(pos), user) - end +-- Support on_dignodes callbacks like used in borders mod for barriers. +local call_on_dignodes = function(pos, node, user) + for _, callback in ipairs(core.registered_on_dignodes) do + local pos_copy = {x=pos.x, y=pos.y, z=pos.z} + local node_copy = {name=node.name, param1=node.param1, param2=node.param2} + callback(pos_copy, node_copy, user) end end --- add stone floor if air or water or glass --- in minetest 5.0+, desert biomes will use desert_stone -local replace_floor = function(x, y, z, user, pointed_thing) - local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) - if not minetest.is_protected(pos, user) then - local name = minetest.get_node(pos).name - if name == "air" or string.match(name, "water") or name == "default:glass" then - if is_desert(pos) then - minetest.set_node(pos, {name = "default:desert_stone"}) - else - minetest.set_node(pos, {name = "default:stone"}) +-- Lookup table to map direction to appropriate rotation for angled_stair_left nodes. +local astairs_lu = { + [-1] ={[2]=1,[6]=0,[10]=3,[14]=2}, -- down + [1] = {[2]=3,[6]=2,[10]=1,[14]=0} -- up +} + +local region -- Declare so I can use these functions recursively. +region = { + [0] = -- Null. + function(x, y, z, dir, user, pointed_thing) + end, + [1] = -- Air. Don't delete lights or track. (Works with torches, but not with ceiling mounted lamps.) + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + if not (node.name == "air" or is_light(node.name) or string.match(node.name, "dtrack")) then + minetest.set_node(pos, {name = "air"}) + call_on_dignodes(pos, node, user) + end end + end, + [2] = -- Ceiling. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + if string.match(node.name, "water") then -- Always line water with glass. + minetest.set_node(pos, {name = glass_walls}) + call_on_dignodes(pos, node, user) + elseif user_config[pname].add_lined_tunnels and user_config[pname].digging_mode ~= 3 then -- Line tunnel ... + if not (node.name == "air" or node.name == glass_walls or node.name == "default:snow" or is_flammable(node.name)) then -- except for these. + minetest.set_node(pos, {name = lining_material(user, pos)}) + call_on_dignodes(pos, node, user) + end + else -- Don't line tunnel, but convert sand to sandstone and gravel to cobble. + if string.match(node.name, "default:sand") then + minetest.set_node(pos, {name = "default:sandstone"}) + call_on_dignodes(pos, node, user) + elseif string.match(node.name, "default:desert_sand") then + minetest.set_node(pos, {name = "default:desert_sandstone"}) + call_on_dignodes(pos, node, user) + elseif string.match(node.name, "default:silver_sand") then + minetest.set_node(pos, {name = "default:silver_sandstone"}) + call_on_dignodes(pos, node, user) + elseif string.match(node.name, "default:gravel") then + minetest.set_node(pos, {name = "default:cobble"}) + call_on_dignodes(pos, node, user) + end + end + if user_config[pname].clear_trees > 0 then -- Check if need to clear tree cover above dig. + for i = y, clear_trees_max do + local posi = vector.add(pointed_thing.under, {x=x, y=i, z=z}) + local nodei = minetest.get_node(posi) + if nodei.name == "default:snow" or is_flammable(nodei.name) then + minetest.set_node(posi, {name = "air"}) + call_on_dignodes(posi, nodei, user) + elseif namei ~= "air" then + break + end + end + end + end + end, + [3] = -- Side walls. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + if string.match(node.name, "water") then + minetest.set_node(pos, {name = glass_walls}) -- Always line water with glass. + call_on_dignodes(pos, node, user) + elseif user_config[pname].add_lined_tunnels and user_config[pname].digging_mode ~= 3 then -- Line tunnel ... + if not (node.name == "air" or node.name == glass_walls or node.name == "default:snow" or is_flammable(node.name) or string.match(node.name, "dtrack")) then -- except for these. + minetest.set_node(pos, {name = lining_material(user,pos)}) + call_on_dignodes(pos, node, user) + end + end + end + end, + [4] = -- Temporary endcaps. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + if string.match(node.name, "water") then -- Place temporary endcap if water. + minetest.set_node(pos, {name = glass_walls}) + call_on_dignodes(pos, node, user) + end + end + end, + [5] = -- Reference markers. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + -- Figure out what replacement material should be. + local rep_mat + if user_config[pname].add_refs then -- Add reference marks. + if user_config[pname].add_embankment then + rep_mat = embankment + else + rep_mat = lining_material(user, pos) + end + minetest.set_node(pos, {name = reference_marks}) + call_on_dignodes(pos, node, user) + local meta = minetest.get_meta(pos) + meta:set_string("replace_with", rep_mat) + else -- No refs. + if user_config[pname].add_floors or string.match(node.name, "water") or node.name == "air" or node.name == glass_walls or node.name == "default:snow" or is_flammable(node.name) then + minetest.set_node(pos, {name = lining_material(user, pos)}) + call_on_dignodes(pos, node, user) + end + end + end + end, + [6] = -- Embankment area. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + if user_config[pname].add_floors then -- Going to set all. + if user_config[pname].add_embankment then + minetest.set_node(pos, {name = embankment, param2 = 42}) + call_on_dignodes(pos, node, user) + else + minetest.set_node(pos, {name = lining_material(user, pos)}) + call_on_dignodes(pos, node, user) + end + else -- Only fill holes. + if string.match(node.name, "water") or node.name == "air" or node.name == glass_walls or node.name == "default:snow" or is_flammable(node.name) then + minetest.set_node(pos, {name = lining_material(user, pos)}) + call_on_dignodes(pos, node, user) + end + end + end + end, + [7] = -- Wide floors. (starting to refine) + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + if user_config[pname].add_floors and user_config[pname].add_wide_floors then + local pos0 = vector.add(pos, {x=0, y=-1, z=0}) + local node0 = minetest.get_node(pos0) + if not ((node0.name == user_config[pname].coating_desert or node0.name == user_config[pname].coating_not_desert) and node0.param2 == 7) and -- Exception to match diagonal up and down digging. + not (user_config[pname].add_embankment and ((node.name == embankment and node.param2 == 42) or node.name == reference_marks)) and -- Don't overwrite embankment or refs in train mode. + not (user_config[pname].add_bike_ramps and node.name == reference_marks) then -- Don't overwrite refs in bike mode. + minetest.set_node(pos, {name = lining_material(user, pos), param2 = 7}) + call_on_dignodes(pos, node, user) + end + else -- Not wide. However, this makes double-wide glass when digging at water surface level. + if string.match(node.name, "water") then + minetest.set_node(pos, {name = glass_walls}) + call_on_dignodes(pos, node, user) + end + end + end + end, + [8] = -- Underfloor, only used directly for slope up and slope down where embankment or brace is always needed. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + minetest.set_node(pos, {name = lining_material(user, pos)}) + call_on_dignodes(pos, node, user) + end + end, + [10] = -- Bike slope down narrow (air or angled slab). + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local pname = user:get_player_name() + local name = minetest.get_node(pos).name + if user_config[pname].add_bike_ramps and angledstairs_exists then + if not (name == angled_slab_desert or name == angled_slab_not_desert) then -- Don't overwrite angled_slab on ref when going diagonally down. + region[1](x, y, z, dir, user, pointed_thing) + end + else + region[1](x, y, z, dir, user, pointed_thing) + end + end, + [11] = -- Bike slope up or down narrow (air or angled slab). + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + if user_config[pname].add_bike_ramps and angledstairs_exists then + if is_desert(user, pos) then + minetest.set_node(pos, {name = angled_slab_desert, param2 = astairs_lu[dir.vert][dir.horiz]}) + call_on_dignodes(pos, node, user) + else + minetest.set_node(pos, {name = angled_slab_not_desert, param2 = astairs_lu[dir.vert][dir.horiz]}) + call_on_dignodes(pos, node, user) + end + else + region[1](x, y, z, dir, user, pointed_thing) + end + end + end, + [12] = -- Bike slope up or down narrow (slab or angled stair). + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + if user_config[pname].add_bike_ramps then + if angledstairs_exists and math.fmod(dir.horiz, 4) == 2 then -- diagonal slope + if is_desert(user, pos) then + minetest.set_node(pos, {name = angled_stair_desert, param2 = astairs_lu[dir.vert][dir.horiz]}) + call_on_dignodes(pos, node, user) + else + minetest.set_node(pos, {name = angled_stair_not_desert, param2 = astairs_lu[dir.vert][dir.horiz]}) + call_on_dignodes(pos, node, user) + end + else -- no angledstairs + if is_desert(user, pos) then + minetest.set_node(pos, {name = slab_desert, param2 = 2}) + call_on_dignodes(pos, node, user) + else + minetest.set_node(pos, {name = slab_not_desert, param2 = 2}) + call_on_dignodes(pos, node, user) + end + end + else + region[1](x, y, z, dir, user, pointed_thing) + end + end + end, + [13] = -- Bike slope wide up or down (slabs). + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + if user_config[pname].add_bike_ramps and user_config[pname].add_wide_floors then + if is_desert(user, pos) then + minetest.set_node(pos, {name = slab_desert, param2 = 2}) + call_on_dignodes(pos, node, user) + else + minetest.set_node(pos, {name = slab_not_desert, param2 = 2}) + call_on_dignodes(pos, node, user) + end + else + region[1](x, y, z, dir, user, pointed_thing) + end + end + end, + [19] = -- Bike slopes. Don't remove bike slopes placed by previous down slope. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local pname = user:get_player_name() + local node = minetest.get_node(pos) + if not user_config[pname].add_bike_ramps or + (user_config[pname].add_bike_ramps and + not ((node.name == slab_not_desert or node.name == slab_desert) and node.param2 == 2) and + not (node.name == angled_slab_not_desert or node.name == angled_slab_desert)) then + region[1](x, y, z, dir, user, pointed_thing) + end + end, + [21] = -- Arch or air, (use for arch). + function(x, y, z, dir, user, pointed_thing) + local pname = user:get_player_name() + if user_config[pname].add_arches then -- arches + region[2](x, y, z, dir, user, pointed_thing) + else + region[1](x, y, z, dir, user, pointed_thing) + end + end, + [30] = -- Wall or null (based on arches). + function(x, y, z, dir, user, pointed_thing) + local pname = user:get_player_name() + if not user_config[pname].add_arches then + region[3](x, y, z, dir, user, pointed_thing) + end + end, + [32] = -- Wall or ceiling, (use above arch). + function(x, y, z, dir, user, pointed_thing) + local pname = user:get_player_name() + if user_config[pname].add_arches then + region[3](x, y, z, dir, user, pointed_thing) + else + region[2](x, y, z, dir, user, pointed_thing) + end + end, + [37] = -- Floor under wall. Only place floor under wall if wall right above floor. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local node = minetest.get_node(pos) + if ok_to_tunnel(user, pos, node.name) then + local pname = user:get_player_name() + local pos1 = vector.add(pos, {x=0, y=1, z=0}) + local name1 = minetest.get_node(pos1).name + if string.match(node.name, "water") then + minetest.set_node(pos, {name = glass_walls}) + call_on_dignodes(pos, node, user) + elseif name1 == user_config[pname].coating_not_desert or name1 == user_config[pname].coating_desert then + minetest.set_node(pos, {name = lining_material(user, pos)}) + call_on_dignodes(pos, node, user) + end + end + end, + [40] = -- Endcap or null (based on arches). + function(x, y, z, dir, user, pointed_thing) + local pname = user:get_player_name() + if not user_config[pname].add_arches then + region[4](x, y, z, dir, user, pointed_thing) + end + end, + [77] = -- Add light. + function(x, y, z, dir, user, pointed_thing) + local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) + local name = minetest.get_node(pos).name + if ok_to_tunnel(user, pos, name) then + region[1](x, y, z, dir, user, pointed_thing) + name = minetest.get_node(pos).name -- Should now be air, unless undiggable. + if add_lighting and name == "air" then + local pname = user:get_player_name() + local pos1 = vector.add(pos, {x=0, y=1, z=0}) + local name1 = minetest.get_node(pos1).name + if name1 == "air" then -- Sometimes ceiling is one node higher. + local name2 = minetest.get_node(vector.add(pos1, {x=0, y=1, z=0})).name + if (name2 == user_config[pname].coating_not_desert or name2 == "default:stone" or name2 == user_config[pname].coating_desert or name2 == "default:desert_stone" or name2 == glass_walls) and + minetest.find_node_near(pos1, lighting_search_radius, {name = lighting}) == nil then + minetest.set_node(pos1, {name = lighting, param2 = lighting_p2}) + end + else -- Regular height ceiling. + if (name1 == user_config[pname].coating_not_desert or name1 == "default:stone" or name1 == user_config[pname].coating_desert or name1 == "default:desert_stone" or name1 == glass_walls) and + minetest.find_node_near(pos, lighting_search_radius, {name = lighting}) == nil then + minetest.set_node(pos, {name = lighting, param2 = lighting_p2}) + end + end + end + end + end, + [86] = -- Underfloor under embankment. + function(x, y, z, dir, user, pointed_thing) + local pname = user:get_player_name() + if user_config[pname].add_floors and user_config[pname].add_embankment then + region[8](x, y, z, dir, user, pointed_thing) + end + end, + [87] = -- Underfloor under wide floor. + function(x, y, z, dir, user, pointed_thing) + local pname = user:get_player_name() + if user_config[pname].add_floors and user_config[pname].add_wide_floors then + region[8](x, y, z, dir, user, pointed_thing) + end + end, +} + +-- Add flips and rotates so I only need to define the seven basic digging patterns. +-- For flip: 1 = vertical, -1 = horizontal, 2 = both. +-- For rotate: 1 = clockwise, -1 = counterclockwise. + +local fliprot = function(xzpos, f, r) + local xzres = {xzpos[1], xzpos[2]} -- identity + if f == 2 then -- double flip + xzres[1] = -xzpos[1] + xzres[2] = -xzpos[2] + elseif f ~= 0 and r == 0 then -- single flip + xzres[1] = f * xzpos[1] + xzres[2] = -f * xzpos[2] + elseif f == 0 and r ~= 0 then -- rotate + xzres[1] = r * xzpos[2] + xzres[2] = -r * xzpos[1] + elseif f ~= 0 and r ~= 0 then -- flip + rotate + xzres[1] = f * r * xzpos[2] + xzres[2] = f * r * xzpos[1] + end + return xzres +end + +local run_list = function(dir_list, f, r, dir, user, pointed_thing) + local pname = user:get_player_name() + local height = user_config[pname].height + for _,v in ipairs(dir_list) do + local newpos = fliprot(v[1], f, r) + for i = 9, 6, -1 do -- ceiling + region[v[2][i]](newpos[1], i + height - 7, newpos[2], dir, user, pointed_thing) + end + for y = (height - 2), 2, -1 do -- variable mid region repeats element 5 + region[v[2][5]](newpos[1], y, newpos[2], dir, user, pointed_thing) + end + for i = 4, 1, -1 do -- floor + region[v[2][i]](newpos[1], i-3, newpos[2], dir, user, pointed_thing) end end end --- check for blocks that can fall in future ceiling and convert to cobble before digging --- in minetest 5.0+, desert biomes will use desert_cobble -local replace_ceiling = function(x, y, z, user, pointed_thing) - local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) - local ceiling = minetest.get_node(pos).name - if (ceiling == "default:sand" or ceiling == "default:desert_sand" or - ceiling == "default:silver_sand" or ceiling == "default:gravel") and - not minetest.is_protected(pos, user) then - if is_desert(pos) then - minetest.set_node(pos, {name = "default:desert_cobble"}) - else - minetest.set_node(pos, {name = "default:cobble"}) - end - end -end - --- add torch -local add_light = function(spacing, user, pointed_thing) - local pos = vector.add(pointed_thing.under, {x=0, y=tunnel_height, z=0}) - local ceiling = minetest.get_node(vector.add(pos, {x=0, y=1, z=0})).name - if add_torches and (ceiling == "default:stone" or ceiling == "default:desert_stone") and - minetest.get_node(pos).name == "air" and not minetest.is_protected(pos, user) and - minetest.find_node_near(pos, spacing, {name = "default:torch_ceiling"}) == nil then - minetest.set_node(pos, {name = "default:torch_ceiling"}) - end - -- roof height can now be 5 or six so try again one higher - pos = vector.add(pointed_thing.under, {x=0, y=tunnel_height+1, z=0}) - ceiling = minetest.get_node(vector.add(pos, {x=0, y=1, z=0})).name - if add_torches and (ceiling == "default:stone" or ceiling == "default:desert_stone") and - minetest.get_node(pos).name == "air" and not minetest.is_protected(pos, user) and - minetest.find_node_near(pos, spacing, {name = "default:torch_ceiling"}) == nil then - minetest.set_node(pos, {name = "default:torch_ceiling"}) - end -end - --- build glass barrier to water --- if node is water, replace with glass -local check_for_water = function(x, y, z, user, pointed_thing) - local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z}) - if water_tunnels and not minetest.is_protected(pos, user) then - local name = minetest.get_node(pos).name - if string.match(name, "water") then - minetest.set_node(pos, {name = "default:glass"}) - end - -- if string.match(name, "air") or string.match(name, "water") then -- debug - -- minetest.set_node(pos, {name = "small:box"}) - -- end - end -end - --- The wall and endcap functions replace water nodes with glass --- They build a continuous column from y0 to y1 (e.g., 0:6). - --- add wall (pink) -local aw = function(x, y0, y1, z, user, pointed_thing) - if water_tunnels then - for y=y0, y1 do - check_for_water(x, y, z, user, pointed_thing) - end - end -end - --- add endcap (light orange shorter, darker orange taller) -local ec = function(x, y0, y1, z, user, pointed_thing) - if water_tunnels then - for y=y0, y1 do - check_for_water(x, y, z, user, pointed_thing) - end - end -end - --- dig side column, don't replace floor (light gray) -local ds = function(x, y0, y1, z, user, pointed_thing) - local height = y1 - replace_ceiling(x, height+1, z, user, pointed_thing) - check_for_water(x, height+1, z, user, pointed_thing) - for y=height, y0+1, -1 do -- dig from high to low - dig_single(x, y, z, user, pointed_thing) - end - check_for_water(x, y0, z, user, pointed_thing) -end - --- dig tall column, fill in floor if air (light yellow, origin, or next ref) -local dt = function(x, y0, y1, z, user, pointed_thing) - local height = y1 - replace_ceiling(x, height+1, z, user, pointed_thing) - check_for_water(x, height+1, z, user, pointed_thing) - for y=height, y0+1, -1 do -- dig from high to low - dig_single(x, y, z, user, pointed_thing) - end - replace_floor(x, y0, z, user, pointed_thing) -end - --- To shorten the code, this function takes a list of lists with {function, x-coord, y-coord} and executes them in sequence. -local run_list = function(dir_list, user, pointed_thing) - for i,v in ipairs(dir_list) do - v[1](v[2], v[3], v[4], v[5], user, pointed_thing) - end -end - --- dig tunnel based on direction given +-- Dig tunnel based on direction given. + -- [9] = h + 2 (up ceiling) + -- [8] = h + 1 (default ceiling) + -- + -- [7] = h (default arch) + -- [6] = h - 1 (down arch) + -- [5] = 2 to h - 2 (middle repeated, hmin = 3, zero instances,) + -- [4] = 1 (up floor) + -- + -- [3] = 0 (default floor) + -- [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 - -- Short abbreviations: "c" (ceiling) and "a" (arch) - local c = tunnel_height - local a = tunnel_height - 1 - if not tunnel_arch then a = tunnel_height end --- Dig horizontal - if cdir == 0 then -- pointed north - run_list({{aw,-3, 0, a, 0},{aw,-3, 0, a, 1},{aw,-3, 0, a, 2}, - {aw, 3, 0, a, 0},{aw, 3, 0, a, 1},{aw, 3, 0, a, 2}, - {ec,-3, 0, a, 3},{ec,-2, 0, a+1, 3},{ec,-1, 0, c+1, 3},{ec, 0, 0, c+1, 3},{ec, 1, 0, c+1, 3},{ec, 2, 0, a+1, 3},{ec, 3, 0, a, 3}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {ds,-2, 0, a, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c, 1},{dt, 1, 0, c, 1},{ds, 2, 0, a, 1}, - {ds,-2, 0, a, 2},{dt,-1, 0, c, 2},{dt, 0, 0, c, 2},{dt, 1, 0, c, 2},{ds, 2, 0, a, 2}, - {add_ref, 0, 0, 0, 2}}, user, pointed_thing) + 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}}, + }, - elseif cdir == 1 then -- pointed north-northwest - run_list({{aw,-3, 0, a, 0},{aw,-4, 0, a, 1},{aw,-4, 0, a, 2}, - {aw, 3, 0, a, 1},{aw, 2, 0, a, 2},{aw, 2, 0, a, 3}, - {ec,-4, 0, a, 3},{ec,-3, 0, a+1, 3},{ec,-2, 0, c+1, 3},{ec,-1, 0, c+1, 3},{ec, 0, 0, c+1, 3},{ec, 1, 0, a+1, 3}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0}, - {ds,-3, 0, a, 1},{dt,-2, 0, c, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c, 1},{dt, 1, 0, c, 1},{ds, 2, 0, a, 1}, - {ds,-3, 0, a, 2},{dt,-2, 0, c, 2},{dt,-1, 0, c, 2},{dt, 0, 0, c, 2},{ds, 1, 0, a, 2}, - {add_ref,-1, 0, 0, 2}}, user, pointed_thing) + -- 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}}, + }, - elseif cdir == 2 then -- pointed northwest - run_list({{aw,-2, 0, a,-2},{aw,-3, 0, a,-1}, - {aw, 2, 0, a, 2},{aw, 1, 0, a, 3}, - {ec,-4, 0, a, 0},{ec,-3, 0, a, 1},{ec,-2, 0, c, 1},{ec,-1, 0, c, 2},{ec,-1, 0, a, 3},{ec, 0, 0, a, 4}, - {ds,-1, 0, a,-2}, - {ds,-2, 0, a,-1},{dt,-1, 0, c,-1}, - {ds,-3, 0, a, 0},{dt,-2, 0, c, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0}, - {dt,-1, 0, c, 1},{dt, 0, 0, c, 1},{dt, 1, 0, c, 1},{ds, 2, 0, a, 1}, - {dt, 0, 0, c, 2},{ds, 1, 0, a, 2}, - {ds, 0, 0, a, 3}, - {add_ref,-1, 0, 0, 1}}, user, pointed_thing) + -- 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}}, + }, - elseif cdir == 3 then -- pointed west-northwest - run_list({{aw,-1, 0, a,-3},{aw,-2, 0, a,-2},{aw,-3, 0, a,-2}, - {aw, 0, 0, a, 3},{aw,-1, 0, a, 4},{aw,-2, 0, a, 4}, - {ec,-3, 0, a+1,-1},{ec,-3, 0, c+1, 0},{ec,-3, 0, c+1, 1},{ec,-3, 0, c+1, 2},{ec,-3, 0, a+1, 3},{ec,-3, 0, a, 4}, - {ds,-1, 0, a,-2}, - {ds,-2, 0, a,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c,-1}, - {dt,-2, 0, c, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0}, - {dt,-2, 0, c, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c, 1}, - {dt,-2, 0, c, 2},{dt,-1, 0, c, 2},{ds, 0, 0, a, 2}, - {ds,-2, 0, a, 3},{ds,-1, 0, a, 3}, - {add_ref,-2, 0, 0, 1}}, user, pointed_thing) + -- 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}}, + }, - elseif cdir == 4 then -- pointed west - run_list({{aw, 0, 0, a,-3},{aw,-1, 0, a,-3},{aw,-2, 0, a,-3}, - {aw, 0, 0, a, 3},{aw,-1, 0, a, 3},{aw,-2, 0, a, 3}, - {ec,-3, 0, a,-3},{ec,-3, 0, a+1,-2},{ec,-3, 0, c+1,-1},{ec,-3, 0, c+1, 0},{ec,-3, 0, c+1, 1},{ec,-3, 0, a+1, 2},{ec,-3, 0, a, 3}, - {ds,-2, 0, a,-2},{ds,-1, 0, a,-2},{ds, 0, 0, a,-2}, - {dt,-2, 0, c,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c,-1}, - {dt,-2, 0, c, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0}, - {dt,-2, 0, c, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c, 1}, - {ds,-2, 0, a, 2},{ds,-1, 0, a, 2},{ds, 0, 0, a, 2}, - {add_ref,-2, 0, 0, 0}}, user, pointed_thing) + -- 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}}, + }, - elseif cdir == 5 then -- pointed west-southwest - run_list({{aw, 0, 0, a,-3},{aw,-1, 0, a,-4},{aw,-2, 0, a,-4}, - {aw,-1, 0, a, 3},{aw,-2, 0, a, 2},{aw,-3, 0, a, 2}, - {ec,-3, 0, a,-4},{ec,-3, 0, a+1,-3},{ec,-3, 0, c+1,-2},{ec,-3, 0, c+1,-1},{ec,-3, 0, c+1, 0},{ec,-3, 0, a+1, 1}, - {ds,-2, 0, a,-3},{ds,-1, 0, a,-3}, - {dt,-2, 0, c,-2},{dt,-1, 0, c,-2},{ds, 0, 0, a,-2}, - {dt,-2, 0, c,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c,-1}, - {dt,-2, 0, c, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0}, - {ds,-2, 0, a, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c, 1}, - {ds,-1, 0, a, 2}, - {add_ref,-2, 0, 0,-1}}, user, pointed_thing) + -- 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}}, + }, - elseif cdir == 6 then -- pointed southwest - run_list({{aw, 2, 0, a,-2},{aw, 1, 0, a,-3}, - {aw,-2, 0, a, 2},{aw,-3, 0, a, 1}, - {ec, 0, 0, a,-4},{ec,-1, 0, a,-3},{ec,-1, 0, c,-2},{ec,-2, 0, c,-1},{ec,-3, 0, a,-1},{ec,-4, 0, a, 0}, - {ds, 0, 0, a,-3}, - {dt, 0, 0, c,-2},{ds, 1, 0, a,-2}, - {dt,-1, 0, c,-1},{dt, 0, 0, c,-1},{dt, 1, 0, c,-1},{ds, 2, 0, a,-1}, - {ds,-3, 0, a, 0},{dt,-2, 0, c, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0}, - {ds,-2, 0, a, 1},{dt,-1, 0, c, 1}, - {ds,-1, 0, a, 2}, - {add_ref,-1, 0, 0,-1}}, user, pointed_thing) + -- 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}}, + }, + } - elseif cdir == 7 then -- pointed south-southwest - run_list({{aw, 3, 0, a,-1},{aw, 2, 0, a,-2},{aw, 2, 0, a,-3}, - {aw,-3, 0, a, 0},{aw,-4, 0, a,-1},{aw,-4, 0, a,-2}, - {ec, 1, 0, a+1,-3},{ec, 0, 0, c+1,-3},{ec,-1, 0, c+1, -3},{ec,-2, 0, c+1,-3},{ec,-3, 0, a+1,-3},{ec,-4, 0, a,-3}, - {ds,-3, 0, a,-2},{dt,-2, 0, c,-2},{dt,-1, 0, c,-2},{dt, 0, 0, c,-2},{ds, 1, 0, a,-2}, - {ds,-3, 0, a,-1},{dt,-2, 0, c,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c,-1},{dt, 1, 0, c,-1},{ds, 2, 0, a,-1}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0}, - {add_ref,-1, 0, 0,-2}}, user, pointed_thing) + 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} + } - elseif cdir == 8 then -- pointed south - run_list({{aw, 3, 0, a, 0},{aw, 3, 0, a,-1},{aw, 3, 0, a,-2}, - {aw,-3, 0, a, 0},{aw,-3, 0, a,-1},{aw,-3, 0, a,-2}, - {ec, 3, 0, a,-3},{ec, 2, 0, a+1,-3},{ec, 1, 0, c+1,-3},{ec, 0, 0, c+1,-3},{ec,-1, 0, c+1,-3},{ec,-2, 0, a+1,-3},{ec,-3, 0, a,-3}, - {ds,-2, 0, a,-2},{dt,-1, 0, c,-2},{dt, 0, 0, c,-2},{dt, 1, 0, c,-2},{ds, 2, 0, a,-2}, - {ds,-2, 0, a,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c,-1},{dt, 1, 0, c,-1},{ds, 2, 0, a,-1}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {add_ref,0, 0, 0,-2}}, user, pointed_thing) - - elseif cdir == 9 then -- pointed south-southeast - run_list({{aw, 3, 0, a, 0},{aw, 4, 0, a,-1},{aw, 4, 0, a,-2}, - {aw,-3, 0, a,-1},{aw,-2, 0, a,-2},{aw,-2, 0, a,-3}, - {ec, 4, 0, a,-3},{ec, 3, 0, a+1,-3},{ec, 2, 0, c+1,-3},{ec, 1, 0, c+1,-3},{ec, 0, 0, c+1,-3},{ec,-1, 0, a+1,-3}, - {ds,-1, 0, a,-2},{dt, 0, 0, c,-2},{dt, 1, 0, c,-2},{dt, 2, 0, c,-2},{ds, 3, 0, a,-2}, - {ds,-2, 0, a,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c,-1},{dt, 1, 0, c,-1},{dt, 2, 0, c,-1},{ds, 3, 0, a,-1}, - {dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {add_ref,1, 0, 0,-2}}, user, pointed_thing) - - elseif cdir == 10 then -- pointed southeast - run_list({{aw, 2, 0, a, 2},{aw, 3, 0, a, 1}, - {aw,-2, 0, a,-2},{aw,-1, 0, a,-3}, - {ec, 4, 0, a, 0},{ec, 3, 0, a,-1},{ec, 2, 0, c,-1},{ec, 1, 0, c,-2},{ec, 1, 0, a,-3},{ec, 0, 0, a,-4}, - {ds, 0, 0, a,-3}, - {ds,-1, 0, a,-2},{dt, 0, 0, c,-2}, - {ds,-2, 0, a,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c,-1},{dt, 1, 0, c,-1}, - {dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{dt, 2, 0, c, 0},{ds, 3, 0, a, 0}, - {dt, 1, 0, c, 1},{ds, 2, 0, a, 1}, - {ds, 1, 0, a, 2}, - {add_ref, 1, 0, 0,-1}}, user, pointed_thing) - - elseif cdir == 11 then -- pointed east-southeast - run_list({{aw, 1, 0, a, 3},{aw, 2, 0, a, 2},{aw, 3, 0, a, 2}, - {aw, 0, 0, a,-3},{aw, 1, 0, a,-4},{aw, 2, 0, a,-4}, - {ec, 3, 0, a+1, 1},{ec, 3, 0, c+1, 0},{ec, 3, 0, c+1,-1},{ec, 3, 0, c+1,-2},{ec, 3, 0, a+1,-3},{ec, 3, 0, a,-4}, - {ds, 1, 0, a,-3},{ds, 2, 0, a,-3}, - {ds, 0, 0, a,-2},{dt, 1, 0, c,-2},{dt, 2, 0, c,-2}, - {dt, 0, 0, c,-1},{dt, 1, 0, c,-1},{dt, 2, 0, c,-1}, - {dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{dt, 2, 0, c, 0}, - {dt, 0, 0, c, 1},{dt, 1, 0, c, 1},{ds, 2, 0, a, 1}, - {ds, 1, 0, a, 2}, - {add_ref, 2, 0, 0,-1}}, user, pointed_thing) - - elseif cdir == 12 then -- pointed east - run_list({{aw, 0, 0, a, 3},{aw, 1, 0, a, 3},{aw, 2, 0, a, 3}, - {aw, 0, 0, a,-3},{aw, 1, 0, a,-3},{aw, 2, 0, a,-3}, - {ec, 3, 0, a, 3},{ec, 3, 0, a+1, 2},{ec, 3, 0, c+1, 1},{ec, 3, 0, c+1, 0},{ec, 3, 0, c+1,-1},{ec, 3, 0, a+1,-2},{ec, 3, 0, a,-3}, - {ds, 0, 0, a,-2},{ds, 1, 0, a,-2},{ds, 2, 0, a,-2}, - {dt, 0, 0, c,-1},{dt, 1, 0, c,-1},{dt, 2, 0, c,-1}, - {dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{dt, 2, 0, c, 0}, - {dt, 0, 0, c, 1},{dt, 1, 0, c, 1},{dt, 2, 0, c, 1}, - {ds, 0, 0, a, 2},{ds, 1, 0, a, 2},{ds, 2, 0, a, 2}, - {add_ref, 2, 0, 0, 0}}, user, pointed_thing) - - elseif cdir == 13 then -- pointed east-northeast - run_list({{aw, 0, 0, a, 3},{aw, 1, 0, a, 4},{aw, 2, 0, a, 4}, - {aw, 1, 0, a,-3},{aw, 2, 0, a,-2},{aw, 3, 0, a,-2}, - {ec, 3, 0, a, 4},{ec, 3, 0, a+1, 3},{ec, 3, 0, c+1, 2},{ec, 3, 0, c+1, 1},{ec, 3, 0, c+1, 0},{ec, 3, 0, a+1,-1}, - {ds, 1, 0, a,-2}, - {dt, 0, 0, c,-1},{dt, 1, 0, c,-1},{ds, 2, 0, a,-1}, - {dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{dt, 2, 0, c, 0}, - {dt, 0, 0, c, 1},{dt, 1, 0, c, 1},{dt, 2, 0, c, 1}, - {ds, 0, 0, a, 2},{dt, 1, 0, c, 2},{dt, 2, 0, c, 2}, - {ds, 1, 0, a, 3},{ds, 2, 0, a, 3}, - {add_ref, 2, 0, 0, 1}}, user, pointed_thing) - - elseif cdir == 14 then -- pointed northeast - run_list({{aw,-2, 0, a, 2},{aw,-1, 0, a, 3}, - {aw, 2, 0, a,-2},{aw, 3, 0, a,-1}, - {ec, 0, 0, a, 4},{ec, 1, 0, a, 3},{ec, 1, 0, c, 2},{ec, 2, 0, c, 1},{ec, 3, 0, a, 1},{ec, 4, 0, a, 0}, - {ds, 1, 0, a,-2}, - {dt, 1, 0, c,-1},{ds, 2, 0, a,-1}, - {dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{dt, 2, 0, c, 0},{ds, 3, 0, a, 0}, - {ds,-2, 0, a, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c, 1},{dt, 1, 0, c, 1}, - {ds,-1, 0, a, 2},{dt, 0, 0, c, 2}, - {ds, 0, 0, a, 3}, - {add_ref, 1, 0, 0, 1}}, user, pointed_thing) - - elseif cdir == 15 then -- pointed north-northeast - run_list({{aw,-3, 0, a, 1},{aw,-2, 0, a, 2},{aw,-2, 0, a, 3}, - {aw, 3, 0, a, 0},{aw, 4, 0, a, 1},{aw, 4, 0, a, 2}, - {ec,-1, 0, a+1, 3},{ec, 0, 0, c+1, 3},{ec, 1, 0, c+1, 3},{ec, 2, 0, c+1, 3},{ec, 3, 0, a+1, 3},{ec, 4, 0, a, 3}, - {dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {ds,-2, 0, a, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c, 1},{dt, 1, 0, c, 1},{dt, 2, 0, c, 1},{ds, 3, 0, a, 1}, - {ds,-1, 0, a, 2},{dt, 0, 0, c, 2},{dt, 1, 0, c, 2},{dt, 2, 0, c, 2},{ds, 3, 0, a, 2}, - {add_ref, 1, 0, 0, 2}}, user, pointed_thing) - --- Dig for slope up - elseif cdir == 16 then -- pointed north (0, dig up) - run_list({{aw,-3, 0, a, 0},{aw,-3, 0, a+1, 1},{aw,-3, 1, a+1, 2}, - {aw, 3, 0, a, 0},{aw, 3, 0, a+1, 1},{aw, 3, 1, a+1, 2}, - {ec,-3, 1, a+1, 3},{ec,-2, 1, a+2, 3},{ec,-1, 1, c+2, 3},{ec, 0, 1, c+2, 3},{ec, 1, 1, c+2, 3},{ec, 2, 1, a+2, 3},{ec, 3, 1, a+1, 3}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {ds,-2, 0, a+1, 1},{dt,-1, 0, c+1, 1},{dt, 0, 0, c+1, 1},{dt, 1, 0, c+1, 1},{ds, 2, 0, a+1, 1}, - {ds,-2, 1, a+1, 2},{dt,-1, 1, c+1, 2},{dt, 0, 1, c+1, 2},{dt, 1, 1, c+1, 2},{ds, 2, 1, a+1, 2}, - {add_ref, 0, 1, 0, 2}, - {add_brace,-1, 0, 0, 2}, - {add_brace, 1, 0, 0, 2}}, user, pointed_thing) - - elseif cdir == 17 then -- pointed northwest (2, dig up) - run_list({{aw,-2, 0, a+1,-2},{aw,-3, 1, a+1,-1}, - {aw, 2, 0, a+1, 2},{aw, 1, 1, a+1, 3}, - {ec,-4, 1, a+1, 0},{ec,-3, 1, c+1, 1},{ec,-2, 1, c+2, 1},{ec,-1, 1, c+2, 2},{ec,-1, 1, c+1, 3},{ec, 0, 1, a+1, 4}, - {ds,-1, 0, a,-2}, - {ds,-2, 0, a+1,-1},{dt,-1, 0, c,-1}, - {ds,-3, 1, a+1, 0},{dt,-2, 1, c+1, 0},{dt,-1, 0, c+1, 0},{dt, 0, 0, c+1, 0}, - {dt,-1, 1, c+1, 1},{dt, 0, 0, c+1, 1},{dt, 1, 0, c, 1},{ds, 2, 0, a, 1}, - {dt, 0, 1, c+1, 2},{ds, 1, 0, a+1, 2}, - {ds, 0, 1, a+1, 3}, - {add_ref,-1, 1, 0, 1}, - {add_brace,-2, 0, 0, 0}, - {add_brace, 0, 0, 0, 2}}, user, pointed_thing) - - elseif cdir == 18 then -- pointed west (4, dig up) - run_list({{aw, 0, 0, a,-3},{aw,-1, 0, a+1,-3},{aw,-2, 1, a+1,-3}, - {aw, 0, 0, a, 3},{aw,-1, 0, a+1, 3},{aw,-2, 1, a+1, 3}, - {ec,-3, 1, a+1,-3},{ec,-3, 1, a+2,-2},{ec,-3, 1, c+2,-1},{ec,-3, 1, c+2, 0},{ec,-3, 1, c+2, 1},{ec,-3, 1, a+2, 2},{ec,-3, 1, a+1, 3}, - {ds,-2, 1, a+1,-2},{ds,-1, 0, a+1,-2},{ds, 0, 0, a,-2}, - {dt,-2, 1, c+1,-1},{dt,-1, 0, c+1,-1},{dt, 0, 0, c,-1}, - {dt,-2, 1, c+1, 0},{dt,-1, 0, c+1, 0},{dt, 0, 0, c, 0}, - {dt,-2, 1, c+1, 1},{dt,-1, 0, c+1, 1},{dt, 0, 0, c, 1}, - {ds,-2, 1, a+1, 2},{ds,-1, 0, a+1, 2},{ds, 0, 0, a, 2}, - {add_ref,-2, 1, 0, 0}, - {add_brace,-2, 0, 0,-1}, - {add_brace,-2, 0, 0, 1}}, user, pointed_thing) - - elseif cdir == 19 then -- pointed southwest (6, dig up) - run_list({{aw, 2, 0, a+1,-2},{aw, 1, 1, a+1,-3}, - {aw,-2, 0, a+1, 2},{aw,-3, 1, a+1, 1}, - {ec, 0, 1, a+1,-4},{ec,-1, 1, c+1,-3},{ec,-1, 1, c+2,-2},{ec,-2, 1, c+2,-1},{ec,-3, 1, c+1,-1},{ec,-4, 1, a+1, 0}, - {ds, 0, 1, a+1,-3}, - {dt, 0, 1, c+1,-2},{ds, 1, 0, a+1,-2}, - {dt,-1, 1, c+1,-1},{dt, 0, 0, c+1,-1},{dt, 1, 0, c,-1},{ds, 2, 0, a,-1}, - {ds,-3, 1, a+1, 0},{dt,-2, 1, c+1, 0},{dt,-1, 0, c+1, 0},{dt, 0, 0, c+1, 0}, - {ds,-2, 0, a+1, 1},{dt,-1, 0, c, 1}, - {ds,-1, 0, a, 2}, - {add_ref,-1, 1, 0,-1}, - {add_brace,-2, 0, 0, 0}, - {add_brace, 0, 0, 0,-2}}, user, pointed_thing) - - elseif cdir == 20 then -- pointed south (8, dig up) - run_list({{aw, 3, 0, a, 0},{aw, 3, 0, a+1,-1},{aw, 3, 1, a+1,-2}, - {aw,-3, 0, a, 0},{aw,-3, 0, a+1,-1},{aw,-3, 1, a+1,-2}, - {ec, 3, 1, a+1,-3},{ec, 2, 1, a+2,-3},{ec, 1, 1, c+2,-3},{ec, 0, 1, c+2,-3},{ec,-1, 1, c+2,-3},{ec,-2, 1, a+2,-3},{ec,-3, 1, a+1,-3}, - {ds,-2, 1, a+1,-2},{dt,-1, 1, c+1,-2},{dt, 0, 1, c+1,-2},{dt, 1, 1, c+1,-2},{ds, 2, 1, a+1,-2}, - {ds,-2, 0, a+1,-1},{dt,-1, 0, c+1,-1},{dt, 0, 0, c+1,-1},{dt, 1, 0, c+1,-1},{ds, 2, 0, a+1,-1}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {add_ref,0, 1, 0,-2}, - {add_brace,-1, 0, 0,-2}, - {add_brace, 1, 0, 0,-2}}, user, pointed_thing) - - elseif cdir == 21 then -- pointed southeast (10, dig up) - run_list({{aw, 2, 0, a+1, 2},{aw, 3, 1, a+1, 1}, - {aw,-2, 0, a+1,-2},{aw,-1, 1, a+1,-3}, - {ec, 4, 1, a+1, 0},{ec, 3, 1, c+1,-1},{ec, 2, 1, c+2,-1},{ec, 1, 1, c+2,-2},{ec, 1, 1, c+1,-3},{ec, 0, 1, a+1,-4}, - {ds, 0, 1, a+1,-3}, - {ds,-1, 0, a+1,-2},{dt, 0, 1, c+1,-2}, - {ds,-2, 0, a,-1},{dt,-1, 0, c,-1},{dt, 0, 0, c+1,-1},{dt, 1, 1, c+1,-1}, - {dt, 0, 0, c+1, 0},{dt, 1, 0, c+1, 0},{dt, 2, 1, c+1, 0},{ds, 3, 1, a+1, 0}, - {dt, 1, 0, c, 1},{ds, 2, 0, a+1, 1}, - {ds, 1, 0, a, 2}, - {add_ref, 1, 1, 0,-1}, - {add_brace, 2, 0, 0, 0}, - {add_brace, 0, 0, 0,-2}}, user, pointed_thing) - - elseif cdir == 22 then -- pointed east (12, dig up) - run_list({{aw, 0, 0, a, 3},{aw, 1, 0, a+1, 3},{aw, 2, 1, a+1, 3}, - {aw, 0, 0, a,-3},{aw, 1, 0, a+1,-3},{aw, 2, 1, a+1,-3}, - {ec, 3, 1, a+1, 3},{ec, 3, 1, a+2, 2},{ec, 3, 1, c+2, 1},{ec, 3, 1, c+2, 0},{ec, 3, 1, c+2,-1},{ec, 3, 1, a+2,-2},{ec, 3, 1, a+1,-3}, - {ds, 0, 0, a,-2},{ds, 1, 0, a+1,-2},{ds, 2, 1, a+1,-2}, - {dt, 0, 0, c,-1},{dt, 1, 0, c+1,-1},{dt, 2, 1, c+1,-1}, - {dt, 0, 0, c, 0},{dt, 1, 0, c+1, 0},{dt, 2, 1, c+1, 0}, - {dt, 0, 0, c, 1},{dt, 1, 0, c+1, 1},{dt, 2, 1, c+1, 1}, - {ds, 0, 0, a, 2},{ds, 1, 0, a+1, 2},{ds, 2, 1, a+1, 2}, - {add_ref, 2, 1, 0, 0}, - {add_brace, 2, 0, 0, 1}, - {add_brace, 2, 0, 0,-1}}, user, pointed_thing) - - elseif cdir == 23 then -- pointed northeast (14, dig up) - run_list({{aw,-2, 0, a+1, 2},{aw,-1, 1, a+1, 3}, - {aw, 2, 0, a+1,-2},{aw, 3, 1, a+1,-1}, - {ec, 0, 1, a+1, 4},{ec, 1, 1, c+1, 3},{ec, 1, 1, c+2, 2},{ec, 2, 1, c+2, 1},{ec, 3, 1, c+1, 1},{ec, 4, 1, a+1, 0}, - {ds, 1, 0, a,-2}, - {dt, 1, 0, c,-1},{ds, 2, 0, a+1,-1}, - {dt, 0, 0, c+1, 0},{dt, 1, 0, c+1, 0},{dt, 2, 1, c+1, 0},{ds, 3, 1, a+1, 0}, - {ds,-2, 0, a, 1},{dt,-1, 0, c, 1},{dt, 0, 0, c+1, 1},{dt, 1, 1, c+1, 1}, - {ds,-1, 0, a+1, 2},{dt, 0, 1, c+1, 2}, - {ds, 0, 1, a+1, 3}, - {add_ref, 1, 1, 0, 1}, - {add_brace, 0, 0, 0, 2}, - {add_brace, 2, 0, 0, 0}}, user, pointed_thing) - --- Dig for slope down - elseif cdir == 24 then -- pointed north (0, dig down) - run_list({{aw,-3, 0, a, 0},{aw,-3,-1, a, 1},{aw,-3,-1, a-1, 2}, - {aw, 3, 0, a, 0},{aw, 3,-1, a, 1},{aw, 3,-1, a-1, 2}, - {ec,-3,-1, a-1, 3},{ec,-2,-1, a, 3},{ec,-1,-1, c, 3},{ec, 0,-1, c, 3},{ec, 1,-1, c, 3},{ec, 2,-1, a, 3},{ec, 3,-1, a-1, 3}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {ds,-2,-1, a, 1},{dt,-1,-1, c, 1},{dt, 0,-1, c, 1},{dt, 1,-1, c, 1},{ds, 2,-1, a, 1}, - {ds,-2,-1, a-1, 2},{dt,-1,-1, c-1, 2},{dt, 0,-1, c-1, 2},{dt, 1,-1, c-1, 2},{ds, 2,-1, a-1, 2}, - {add_ref, 0,-1, 0, 2}, - {add_brace,-1,-1, 0, 0}, - {add_brace, 1,-1, 0, 0}}, user, pointed_thing) - - elseif cdir == 25 then -- pointed northwest (2, dig down) - run_list({{aw,-2,-1, a,-2},{aw,-3,-1, a,-1}, - {aw, 2,-1, a, 2},{aw, 1,-1, a, 3}, - {ec,-4,-1, a-1, 0},{ec,-3,-1, a, 1},{ec,-2,-1, c, 1},{ec,-1,-1, c, 2},{ec,-1,-1, a, 3},{ec, 0,-1, a-1, 4}, - {ds,-1, 0, a,-2}, - {ds,-2,-1, a,-1},{dt,-1, 0, c,-1}, - {ds,-3,-1, a-1, 0},{dt,-2,-1, c-1, 0},{dt,-1,-1, c, 0},{dt, 0, 0, c, 0}, - {dt,-1,-1, c, 1},{dt, 0,-1, c, 1},{dt, 1, 0, c, 1},{ds, 2, 0, a, 1}, - {dt, 0,-1, c-1, 2},{ds, 1,-1, a, 2}, - {ds, 0,-1, a-1, 3}, - {add_ref,-1,-1, 0, 1}, - {add_brace,-1,-1, 0,-1}, - {add_brace, 1,-1, 0, 1}}, user, pointed_thing) - - elseif cdir == 26 then -- pointed west (4, dig down) - run_list({{aw, 0, 0, a,-3},{aw,-1,-1, a,-3},{aw,-2,-1, a-1,-3}, - {aw, 0, 0, a, 3},{aw,-1,-1, a, 3},{aw,-2,-1, a-1, 3}, - {ec,-3,-1, a-1,-3},{ec,-3,-1, a,-2},{ec,-3,-1, c,-1},{ec,-3,-1, c, 0},{ec,-3,-1, c, 1},{ec,-3,-1, a, 2},{ec,-3,-1, a-1, 3}, - {ds,-2,-1, a-1,-2},{ds,-1,-1, a,-2},{ds, 0, 0, a,-2}, - {dt,-2,-1, c-1,-1},{dt,-1,-1, c,-1},{dt, 0, 0, c,-1}, - {dt,-2,-1, c-1, 0},{dt,-1,-1, c, 0},{dt, 0, 0, c, 0}, - {dt,-2,-1, c-1, 1},{dt,-1,-1, c, 1},{dt, 0, 0, c, 1}, - {ds,-2,-1, a-1, 2},{ds,-1,-1, a, 2},{ds, 0, 0, a, 2}, - {add_ref,-2,-1, 0, 0}, - {add_brace, 0,-1, 0, 1}, - {add_brace, 0,-1, 0,-1}}, user, pointed_thing) - - elseif cdir == 27 then -- pointed southwest (6, dig down) - run_list({{aw, 2,-1, a,-2},{aw, 1,-1, a,-3}, - {aw,-2,-1, a, 2},{aw,-3,-1, a, 1}, - {ec, 0,-1, a-1,-4},{ec,-1,-1, a,-3},{ec,-1, -1, c,-2},{ec,-2,-1, c,-1},{ec,-3,-1, a,-1},{ec,-4,-1, a-1, 0}, - {ds, 0,-1, a-1,-3}, - {dt, 0,-1, c-1,-2},{ds, 1,-1, a,-2}, - {dt,-1,-1, c,-1},{dt, 0,-1, c,-1},{dt, 1, 0, c,-1},{ds, 2, 0, a,-1}, - {ds,-3,-1, a-1, 0},{dt,-2,-1, c-1, 0},{dt,-1,-1, c, 0},{dt, 0, 0, c, 0}, - {ds,-2,-1, a, 1},{dt,-1, 0, c, 1}, - {ds,-1, 0, a, 2}, - {add_ref,-1,-1, 0,-1}, - {add_brace,-1,-1, 0, 1}, - {add_brace, 1,-1, 0,-1}}, user, pointed_thing) - - elseif cdir == 28 then -- pointed south (8, dig down) - run_list({{aw, 3, 0, a, 0},{aw, 3,-1, a,-1},{aw, 3,-1, a-1,-2}, - {aw,-3, 0, a, 0},{aw,-3,-1, a,-1},{aw,-3,-1, a-1,-2}, - {ec, 3,-1, a-1,-3},{ec, 2,-1, a,-3},{ec, 1,-1, c,-3},{ec, 0,-1, c,-3},{ec,-1,-1, c,-3},{ec,-2,-1, a,-3},{ec,-3,-1, a-1,-3}, - {ds,-2,-1, a-1,-2},{dt,-1,-1, c-1,-2},{dt, 0,-1, c-1,-2},{dt, 1,-1, c-1,-2},{ds, 2,-1, a-1,-2}, - {ds,-2,-1, a,-1},{dt,-1,-1, c,-1},{dt, 0,-1, c,-1},{dt, 1,-1, c,-1},{ds, 2,-1, a,-1}, - {ds,-2, 0, a, 0},{dt,-1, 0, c, 0},{dt, 0, 0, c, 0},{dt, 1, 0, c, 0},{ds, 2, 0, a, 0}, - {add_ref, 0,-1, 0,-2}, - {add_brace,-1,-1, 0, 0}, - {add_brace, 1,-1, 0, 0}}, user, pointed_thing) - - elseif cdir == 29 then -- pointed southeast (10, dig down) - run_list({{aw, 2,-1, a, 2},{aw, 3,-1, a, 1}, - {aw,-2,-1, a,-2},{aw,-1,-1, a,-3}, - {ec, 4,-1, a-1, 0},{ec, 3,-1, a,-1},{ec, 2,-1, c,-1},{ec, 1,-1, c,-2},{ec, 1,-1, a,-3},{ec, 0,-1, a-1,-4}, - {ds, 0,-1, a-1,-3}, - {ds,-1,-1, a,-2},{dt, 0,-1, c-1,-2}, - {ds,-2, 0, a,-1},{dt,-1, 0, c,-1},{dt, 0,-1, c,-1},{dt, 1,-1, c,-1}, - {dt, 0, 0, c, 0},{dt, 1,-1, c, 0},{dt, 2,-1, c-1, 0},{ds, 3,-1, a-1, 0}, - {dt, 1, 0, c, 1},{ds, 2,-1, a, 1}, - {ds, 1, 0, a, 2}, - {add_ref, 1,-1, 0,-1}, - {add_brace,-1,-1, 0,-1}, - {add_brace, 1,-1, 0, 1}}, user, pointed_thing) - - elseif cdir == 30 then -- pointed east (12, dig down) - run_list({{aw, 0, 0, a, 3},{aw, 1,-1, a, 3},{aw, 2,-1, a-1, 3}, - {aw, 0, 0, a,-3},{aw, 1,-1, a,-3},{aw, 2,-1, a-1,-3}, - {ec, 3,-1, a-1, 3},{ec, 3,-1, a, 2},{ec, 3,-1, c, 1},{ec, 3,-1, c, 0},{ec, 3,-1, c,-1},{ec, 3,-1, a,-2},{ec, 3,-1, a-1,-3}, - {ds, 0, 0, a,-2},{ds, 1,-1, a,-2},{ds, 2,-1, a-1,-2}, - {dt, 0, 0, c,-1},{dt, 1,-1, c,-1},{dt, 2,-1, c-1,-1}, - {dt, 0, 0, c, 0},{dt, 1,-1, c, 0},{dt, 2,-1, c-1, 0}, - {dt, 0, 0, c, 1},{dt, 1,-1, c, 1},{dt, 2,-1, c-1, 1}, - {ds, 0, 0, a, 2},{ds, 1,-1, a, 2},{ds, 2,-1, a-1, 2}, - {add_ref, 2,-1, 0, 0}, - {add_brace, 0,-1, 0, 1}, - {add_brace, 0,-1, 0,-1}}, user, pointed_thing) - - elseif cdir == 31 then -- pointed northeast (14, dig down) - run_list({{aw,-2,-1, a, 2},{aw,-1,-1, a, 3}, - {aw, 2,-1, a,-2},{aw, 3,-1, a,-1}, - {ec, 0,-1, a-1, 4},{ec, 1,-1, a, 3},{ec, 1,-1, c, 2},{ec, 2,-1, c, 1},{ec, 3,-1, a, 1},{ec, 4,-1, a-1, 0}, - {ds, 1, 0, a,-2}, - {dt, 1, 0, c,-1},{ds, 2,-1, a,-1}, - {dt, 0, 0, c, 0},{dt, 1,-1, c, 0},{dt, 2,-1, c-1, 0},{ds, 3,-1, a-1, 0}, - {ds,-2, 0, a, 1},{dt,-1, 0, c, 1},{dt, 0,-1, c, 1},{dt, 1,-1, c, 1}, - {ds,-1,-1, a, 2},{dt, 0,-1, c-1, 2}, - {ds, 0,-1, a-1, 3}, - {add_ref, 1,-1, 0, 1}, -- fixed bug - {add_brace,-1,-1, 0, 0}, - {add_brace, 1,-1, 0,-1}}, user, pointed_thing) - end - add_light(torch_search_radius, 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. +local display_menu = function(player) + local pname = player:get_player_name() + local remove_refs_on = false + if user_config[pname].remove_refs > 0 then + remove_refs_on = true + end + local clear_trees_on = false + if user_config[pname].clear_trees > 0 then + clear_trees_on = true + end + local formspec = "size[6.0,6.5]".. + "label[0.25,0.25;"..S("Tunnelmaker - User Options").."]".. + "dropdown[0.25,1.00;4;digging_mode;"..S("General purpose mode")..","..S("Advanced trains mode")..","..S("Bike path mode")..";"..tostring(user_config[pname].digging_mode).."]".. + "checkbox[0.25,1.75;add_lined_tunnels;"..S("Wide paths / lined tunnels")..";"..tostring(user_config[pname].add_lined_tunnels).."]".. + "checkbox[0.25,2.20;continuous_updown;"..S("Continuous up/down digging")..";"..tostring(user_config[pname].continuous_updown).."]".. + "checkbox[0.25,2.75;clear_trees;"..S("Clear tree cover").."*;"..tostring(clear_trees_on).."]".. + "checkbox[0.25,3.20;remove_refs;"..S("Remove reference nodes").."*;"..tostring(remove_refs_on).."]".. + "button_exit[2,5.00;2,0.4;exit;"..S("Exit").."]".. + "label[0.25,5.75;"..minetest.colorize("#888","* "..S("Automatically disabled after 2 min.")).."]" + local formspec_dm = "" + local dmat = "" + local use_desert_material = user_config[pname].use_desert_material + if add_desert_material and minetest.get_biome_data then + if not user_config[pname].lock_desert_mode then + use_desert_material = string.match(minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome), "desert") + user_config[pname].use_desert_material = use_desert_material + end + if use_desert_material then + dmat = S("Desert") + else + dmat = S("Non-desert") + end + formspec_dm = "checkbox[0.25,3.75;lock_desert_mode;"..S("Lock desert mode to:").." "..dmat..";"..tostring(user_config[pname].lock_desert_mode).."]" + end + minetest.show_formspec(pname, "tunnelmaker:form", formspec..formspec_dm) end local i @@ -720,7 +934,7 @@ for i,img in ipairs(images) do inv = 0 end - minetest.register_tool("tunnelmaker:"..(i-1), + minetest.register_tool("tunnelmaker:tool"..(i-1), { description = "Tunnel Maker", groups = {not_in_creative_inventory=inv}, @@ -728,42 +942,68 @@ for i,img in ipairs(images) do wield_image = img, stack_max = 1, range = 7.0, - -- Dig single node with left mouse click, upgraded from wood to steel pickaxe equivalent. - -- Works in both regular and creative modes. - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=1, - groupcaps={ - cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, maxlevel=2}, - }, - damage_groups = {fleshy=4}, - }, - -- Dig tunnel with right mouse click (double tap on android) - -- tunneling only works if in creative mode - on_place = function(itemstack, placer, pointed_thing) - local pname = placer and placer:get_player_name() or "" - local creative_enabled = (creative and creative.is_enabled_for - and creative.is_enabled_for(pname)) - if creative_enabled then - -- If sneak button held down when right-clicking tunnelmaker, toggle updown dig direction: up, down, horizontal, ... - -- Rotating or moving will reset to horizontal. - if placer:get_player_control().sneak then - tunnelmaker[pname].updown = (tunnelmaker[pname].updown + 1) % 3 - tunnelmaker[pname].lastpos = { x = placer:getpos().x, y = placer:getpos().y, z = placer:getpos().z } - -- Otherwise dig tunnel based on direction pointed and current updown direction - elseif pointed_thing.type=="node" then - -- if advtrains_track, I lower positions of pointed_thing to right below track, but keep name the same. + -- Left mouse: Dig single node or dig tunnel. + on_use = function(itemstack, player, pointed_thing) + 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") 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 - dig_tunnel(i-1, placer, pointed_thing) - if not continuous_updown_digging then + 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) + 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 + end + end, + + -- Also bring up User Options menu, when not pointing to anything. + on_secondary_use = function(itemstack, placer, pointed_thing) + 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, @@ -771,11 +1011,119 @@ for i,img in ipairs(images) do ) end -minetest.register_craft({ - output = 'tunnelmaker:1', - recipe = { - {'default:diamondblock', 'default:mese_block', 'default:diamondblock'}, - {'default:mese_block', 'default:diamondblock', 'default:mese_block'}, - {'default:diamondblock', 'default:mese_block', 'default:diamondblock'} - } -}) +-- Register configuration callback +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname ~= "tunnelmaker:form" then + return false + end + local pname = player:get_player_name() + if fields.continuous_updown == "true" then + user_config[pname].continuous_updown = true + elseif fields.continuous_updown == "false" then + user_config[pname].continuous_updown = false + elseif fields.add_lined_tunnels == "true" then + user_config[pname].add_lined_tunnels = true + user_config[pname].add_floors = true + user_config[pname].add_wide_floors = true + elseif fields.add_lined_tunnels == "false" then + user_config[pname].add_lined_tunnels = false + user_config[pname].add_floors = user_config[pname].digging_mode ~= 1 -- gp no floors when not lined + user_config[pname].add_wide_floors = false + elseif fields.clear_trees == "true" then + user_config[pname].clear_trees = remove_refs_enable_time + elseif fields.clear_trees == "false" then + user_config[pname].clear_trees = 0 + elseif fields.remove_refs == "true" then + user_config[pname].remove_refs = remove_refs_enable_time + elseif fields.remove_refs == "false" then + user_config[pname].remove_refs = 0 + elseif fields.lock_desert_mode == "false" then + user_config[pname].lock_desert_mode = false + elseif fields.lock_desert_mode == "true" then + user_config[pname].lock_desert_mode = true + elseif fields.digging_mode == S("General purpose mode") then + user_config[pname].digging_mode = 1 + user_config[pname].height = tunnel_height_general + user_config[pname].add_arches = false + user_config[pname].add_embankment = false + user_config[pname].add_refs = false + user_config[pname].add_floors = user_config[pname].add_lined_tunnels + user_config[pname].add_wide_floors = user_config[pname].add_lined_tunnels + user_config[pname].add_bike_ramps = false + user_config[pname].coating_not_desert = tunnel_material + user_config[pname].coating_desert = tunnel_material_desert + elseif fields.digging_mode == S("Advanced trains mode") then + user_config[pname].digging_mode = 2 + user_config[pname].height = tunnel_height_train + user_config[pname].add_arches = add_arches_config + user_config[pname].add_embankment = true + user_config[pname].add_refs = true + user_config[pname].add_floors = true + user_config[pname].add_wide_floors = user_config[pname].add_lined_tunnels + user_config[pname].add_bike_ramps = false + user_config[pname].coating_not_desert = tunnel_material + user_config[pname].coating_desert = tunnel_material_desert + elseif fields.digging_mode == S("Bike path mode") then + user_config[pname].digging_mode = 3 + user_config[pname].height = tunnel_height_bike + user_config[pname].add_arches = false + user_config[pname].add_embankment = false + user_config[pname].add_refs = true + user_config[pname].add_floors = true + user_config[pname].add_wide_floors = user_config[pname].add_lined_tunnels + user_config[pname].add_bike_ramps = true + user_config[pname].coating_not_desert = bike_path_material + user_config[pname].coating_desert = bike_path_material_desert + end + return true +end) + +-- Decrement remove_refs countdown timers. +minetest.register_globalstep(function(dtime) + local players = minetest.get_connected_players() + for _,player in ipairs(players) do + local pname = player:get_player_name() + local rr = user_config[pname].remove_refs + if rr > 0 then + rr = rr - dtime + if rr <= 0 then + user_config[pname].remove_refs = 0 + else + user_config[pname].remove_refs = rr + end + end + local ct = user_config[pname].clear_trees + if ct > 0 then + ct = ct - dtime + if ct <= 0 then + user_config[pname].clear_trees = 0 + else + user_config[pname].clear_trees = ct + end + end + end +end) + +-- Remove reference marks +local remove_refs = function(player) + local ppos = player:get_pos() + local refpos = minetest.find_node_near(ppos, 1, reference_marks) + if refpos then + if not minetest.is_protected(refpos, player) then + local meta = minetest.get_meta(refpos) + local rep_mat = meta:get("replace_with") + if rep_mat and string.len(rep_mat) > 0 then + minetest.set_node(refpos, {name = rep_mat, param2 = 42}) + end + end + end +end + +-- Replaces reference marks with appropriate material. +minetest.register_globalstep(function(dtime) + for _, player in ipairs(minetest.get_connected_players()) do + if user_config[player:get_player_name()].remove_refs > 0 then + remove_refs(player) + end + end +end) diff --git a/locale/tunnelmaker.fr.tr b/locale/tunnelmaker.fr.tr new file mode 100644 index 0000000..5cfe1e6 --- /dev/null +++ b/locale/tunnelmaker.fr.tr @@ -0,0 +1,15 @@ +# textdomain: tunnelmaker +# Translated by kestral +Tunnelmaker - User Options=Tunnelmaker - Options utilisateur +General purpose mode=Usage général +Advanced trains mode=Trains avancés +Bike path mode=Pistes cyclables +Wide paths / lined tunnels=Chemins larges / tunnels doublés +Continuous up/down digging=Creuser en haut/en bas continuellment +Clear tree cover=Enlever la couverture d'arbre +Remove reference nodes=Enlever les nodes de références +Lock desert mode to:=Fixer le mode de désert à: +Desert=Désert +Non-desert=Non-désert +Exit=Quitter +Automatically disabled after 2 min.=Désactiver automatiquement après 2 min. diff --git a/locale/tunnelmaker.ru.tr b/locale/tunnelmaker.ru.tr new file mode 100644 index 0000000..adbdee3 --- /dev/null +++ b/locale/tunnelmaker.ru.tr @@ -0,0 +1,15 @@ +# textdomain: tunnelmaker +# Translated by Mikola +Tunnelmaker - User Options=Настройки туннелепроходчика +General purpose mode=Обычный туннель +Advanced trains mode=Железнодорожный туннель +Bike path mode=Сглаженный туннель +Wide paths / lined tunnels=Широкие дорожки / облицованные туннели +Continuous up/down digging=Непрерывное копание вверх / вниз +Clear tree cover=Спилить растительность над дорогой +Remove reference nodes=Убрать разметку на дороге +Lock desert mode to:=Блокировка режима пустыни для: +Desert=Пустыня +Non-desert=Вне пустыни +Exit=Закрыть +Automatically disabled after 2 min.=Автоматически отключается через 2 минуты. diff --git a/locale/tunnelmaker.template b/locale/tunnelmaker.template new file mode 100644 index 0000000..e730989 --- /dev/null +++ b/locale/tunnelmaker.template @@ -0,0 +1,15 @@ +# textdomain: tunnelmaker +# Translated by your_name +Tunnelmaker - User Options= +General purpose mode= +Advanced trains mode= +Bike path mode= +Wide paths / lined tunnels= +Continuous up/down digging= +Clear tree cover= +Remove reference nodes= +Lock desert mode to:= +Desert= +Non-desert= +Exit= +Automatically disabled after 2 min.= diff --git a/mod.conf b/mod.conf index 4ebf49a..be4dd77 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,4 @@ name = tunnelmaker -description = Easily dig arbitrarily curved tunnels. -depends = default +description = Easily create arbitrarily curved tunnels and paths. +depends = default, stairs +optional_depends = angledstairs diff --git a/screenshot.png b/screenshot.png index 178a09a..e0f59a2 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..01b3640 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,31 @@ +# This file contains settings of tunnelmaker that can be changed in +# minetest.conf + +# Default for digging mode in User config menu. +# (default = 2) +tunnel_digging_mode (Tunnel digging mode) int 2 1 3 + +# Default for width/lined tunnels option in User config menu. +# (default = false) +add_lined_tunnels (Add lined tunnels) bool false + +# Default for up/down digging option in User config menu. +# (default = false) +continuous_updown_digging (Continuous updown digging) bool false + +# Allow the use of other materials in desert biomes. +# Material changes in "Marking desert" and "Coating desert" +# (default = false) +add_desert_material (Add desert material) bool false + +# Type of light to use in tunnels. +# (default = default:torch) +tunnel_lights (Tunnel lights) string default:torch + +# Set height for train tunnels. +# (default = 5) +train_tunnel_height (Train tunnel height) int 5 5 8 + +# Define if train tunnels have arches. +# (default = true) +train_tunnel_arches (Train tunnel arches) bool true