Initial commit.

master
David G 2017-04-21 09:40:51 -07:00
commit 94c739402c
26 changed files with 441 additions and 0 deletions

121
LICENSE.txt Normal file
View File

@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

70
README.md Normal file
View File

@ -0,0 +1,70 @@
![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.
*This mod is intended for creative mode—it can do great damage if misused.*
by David G (kestral246@gmail.com)
Features
--------
- Creates tunnel segments in any of sixteen possible directions with one click.
- Direction of digging based on direction player is pointing.
- Provides changing icons to help player align in proper direction.
- Uses privileges, requires "tunneling" privilege to be able to use.
- Checks protection, and doesn't dig any protected nodes.
- Reference point is at ground level: possible to increase or decrease the grade by changing the height of the reference node.
- Fills in holes in flooring with cobblestone.
- Adds torches to ceiling if ceiling is stone or desert_stone.
- Works outside of tunnels to clear ground and provide cuts and fills.
How to use
----------
Player needs to have tunneling privilege to be able to use the tunnelmaker tool (/grant <player> tunneling).
To give player a tunnelmaker tool use (/give <player> tunnelmaker:1). *See below for crafting recipe.*
The following diagrams show how to make curved tunnels that support the different track configurations used by advtrains. There are three basic directions that are supported: 0° (orthogonal, rook moves), 45° (diagonal, bishop moves), and 26.6° (knight moves, two blocks forward and one block to the side).
To use this mod, move your character to the existing end of the tunnel, highlight the gray node marked with an x, and point character in direction of red arrow. The icon in the inventory, if visible, will change it's image to confirm direction. Then right-click mouse to dig the green highlighted area. (Note that turns with angles other than those show are possible, but aren't supported by advtrains track.)
Using left-click digs similarly to a wooden pickaxe, which is useful for making minor adjustments.
To increase the grade, place a block on the gray node and select that before right-clicking. To decrease the grade, dig out the gray node and select the lower node before right-clicking. (Note that advtrains only supports slopes for 0° and 45° track.)
![Turns from 0°](images/dir0.png "Turns from 0")
![Turns from 26.6°](images/dir26.png "Turns from 26.6")
![Turns from 45°](images/dir45.png "Turns from 45")
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.
al. - For providing the amazing advtrains mod that this mod tries to make
just a little easier to use.
- [compassgps](https://github.com/Kilarin/compassgps) / Kilarin (Donald Hines),
et. al. - Top level code to change icon based on direction player is pointing.

1
depends.txt Normal file
View File

@ -0,0 +1 @@
default

2
description.txt Normal file
View File

@ -0,0 +1,2 @@
Easily create arbitrarily curved tunnels.
Useful for advtrains mod. Intended for creative mode--can do great damage if misused. Requires "tunneling" privilege to use (/grant <name> tunneling).

BIN
images/crafting.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/dir0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
images/dir26.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
images/dir45.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

247
init.lua Normal file
View File

@ -0,0 +1,247 @@
-- tunnelmaker
-- Another tunnel digging mod for minetest.
-- by David G (kestral246@gmail.com)
-- Version 0.5.0
-- 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
-- distributed without any warranty.
-- You should have received a copy of the CC0 Public Domain Dedication along with this
-- software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
minetest.register_privilege("tunneling", {description = "Allow use of tunnelmaker tool"})
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()
for i,player in ipairs(players) do
local gotatunnelmaker=false
local wielded=false
local activeinv=nil
local stackidx=0
--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 the player is wielding a tunnelmaker, change the wielded image
wielded=true
stackidx=player:get_wield_index()
gotatunnelmaker=true
else
--check to see if tunnelmaker is in active inventory
if player:get_inventory() then
--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
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
break
end --if i<=activewidth
end --for loop
end -- get_inventory
end --if wielded else
--don't mess with the rest of this if they don't have a tunnelmaker
if gotatunnelmaker then
local pos = player:getpos()
local dir = player:get_look_yaw()
local angle_north = 0
local angle_dir = 90 - math.deg(dir)
local angle_relative = (angle_north - angle_dir) % 360
local tunnelmaker_image = math.floor((angle_relative/22.5) + 0.5)%16
--update tunnelmaker image to point at target
if wielded then
player:set_wielded_item("tunnelmaker:"..tunnelmaker_image)
elseif activeinv then
player:get_inventory():set_stack("main",stackidx,"tunnelmaker:"..tunnelmaker_image)
end --if wielded elsif activin
end --if gotatunnelmaker
end --for i,player in ipairs(players)
end) -- register_globalstep
local images = {
"tunnelmaker_0.png",
"tunnelmaker_1.png",
"tunnelmaker_2.png",
"tunnelmaker_3.png",
"tunnelmaker_4.png",
"tunnelmaker_5.png",
"tunnelmaker_6.png",
"tunnelmaker_7.png",
"tunnelmaker_8.png",
"tunnelmaker_9.png",
"tunnelmaker_10.png",
"tunnelmaker_11.png",
"tunnelmaker_12.png",
"tunnelmaker_13.png",
"tunnelmaker_14.png",
"tunnelmaker_15.png",
}
-- dig rectangular shape for non-45 degree angles
local dig_rect = function(xmin, xmax, zmin, zmax, user, pointed_thing)
for x=xmin,xmax do
for z=zmin,zmax do
-- delete nodes (not torches)
for y=1,4 do
local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z})
if minetest.get_node(pos).name ~= "default:torch_ceiling" and not minetest.is_protected(pos, user) then
minetest.dig_node(pos)
end
end
-- add flooring (if air)
local pos = vector.add(pointed_thing.under, {x=x, y=0, z=z})
if minetest.get_node(pos).name == "air" and not minetest.is_protected(pos, user) then
minetest.set_node(pos, {name = "default:cobble"})
end
end
end
-- add lighting
local pos = vector.add(pointed_thing.under, {x=0, y=4, z=0})
local ceiling = minetest.get_node(vector.add(pos, {x=0, y=1, z=0})).name
if (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, 3, {name = "default:torch_ceiling"}) == nil then
minetest.set_node(pos, {name = "default:torch_ceiling"})
end
end
-- dig plus shape for 45 degree angles
local dig_plus = function(xmin, xmax, zmin, zmax, user, pointed_thing)
-- center section
for x=xmin,xmax do
for z=zmin+1,zmax-1 do
-- delete nodes (not torches)
for y=1,4 do
local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z})
if minetest.get_node(pos).name ~= "default:torch_ceiling" and not minetest.is_protected(pos, user) then
minetest.dig_node(pos)
end
end
-- add flooring (if air)
local pos = vector.add(pointed_thing.under, {x=x, y=0, z=z})
if minetest.get_node(pos).name == "air" and not minetest.is_protected(pos, user) then
minetest.set_node(pos, {name = "default:cobble"})
end
end
end
-- top and bottom sections
for x=xmin+1,xmax-1 do
for z=zmin,zmax,3 do
-- delete nodes (not torches)
for y=1,4 do
local pos = vector.add(pointed_thing.under, {x=x, y=y, z=z})
if minetest.get_node(pos).name ~= "default:torch_ceiling" and not minetest.is_protected(pos, user) then
minetest.dig_node(pos)
end
end
-- add flooring (if air)
local pos = vector.add(pointed_thing.under, {x=x, y=0, z=z})
if minetest.get_node(pos).name == "air" and not minetest.is_protected(pos, user) then
minetest.set_node(pos, {name = "default:cobble"})
end
end
end
-- add lighting
local pos = vector.add(pointed_thing.under, {x=0, y=4, z=0})
local ceiling = minetest.get_node(vector.add(pos, {x=0, y=1, z=0})).name
if (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, 2, {name = "default:torch_ceiling"}) == nil then
minetest.set_node(pos, {name = "default:torch_ceiling"})
end
end
-- dig tunnel based on direction given
local dig_tunnel = function(cdir, user, pointed_thing)
if minetest.check_player_privs(user, "tunneling") then
if cdir == 0 then -- pointed 0 (north)
dig_rect(-1, 1, 0, 2, user, pointed_thing)
elseif cdir == 1 then -- pointed -22.5
dig_rect(-2, 1, 0, 2, user, pointed_thing)
elseif cdir == 2 then -- pointed -45 (northwest)
dig_plus(-2, 1, -1, 2, user, pointed_thing)
elseif cdir == 3 then -- pointed -67.5
dig_rect(-2, 0, -1, 2, user, pointed_thing)
elseif cdir == 4 then -- pointed -90 (west)
dig_rect(-2, 0, -1, 1, user, pointed_thing)
elseif cdir == 5 then -- pointed -90-22.5
dig_rect(-2, 0, -2, 1, user, pointed_thing)
elseif cdir == 6 then -- pointed -90-45 (southwest)
dig_plus(-2, 1, -2, 1, user, pointed_thing)
elseif cdir == 7 then -- pointed -90-67.5
dig_rect(-2, 1, -2, 0, user, pointed_thing)
elseif cdir == 8 then -- pointed +/-180 (south)
dig_rect(-1, 1, -2, 0, user, pointed_thing)
elseif cdir == 9 then -- pointed +22.5
dig_rect(-1, 2, -2, 0, user, pointed_thing)
elseif cdir == 10 then -- pointed +45 (northeast)
dig_plus(-1, 2, -2, 1, user, pointed_thing)
elseif cdir == 11 then -- pointed +67.5
dig_rect(0, 2, -2, 1, user, pointed_thing)
elseif cdir == 12 then -- pointed +90 (east)
dig_rect(0, 2, -1, 1, user, pointed_thing)
elseif cdir == 13 then -- pointed +90+22.5
dig_rect(0, 2, -1, 2, user, pointed_thing)
elseif cdir == 14 then -- pointed +90+45 (southeast)
dig_plus(-1, 2, -1, 2, user, pointed_thing)
elseif cdir == 15 then -- pointed +90+67.5
dig_rect(-1, 2, 0, 2, user, pointed_thing)
end
end
end
local i
for i,img in ipairs(images) do
local inv = 1
if i == 2 then
inv = 0
end
minetest.register_tool("tunnelmaker:"..(i-1),
{
description = "Tunnel Maker (easily create curved tunnels)",
groups = {not_in_creative_inventory=inv},
inventory_image = img,
wield_image = img,
stack_max = 1,
range = 7.0,
-- dig single node like wood pickaxe with left mouse click
tool_capabilities = {
full_punch_interval = 1.2,
max_drop_level=0,
groupcaps={
cracky = {times={[3]=1.6}, maxlevel=1},
},
damage_groups = {fleshy=2},
},
-- dig tunnel with right mouse click (double tap on android)
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type=="node" then
dig_tunnel(i-1, placer, pointed_thing)
end
end,
}
)
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'}
}
})

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

BIN
textures/tunnelmaker_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

BIN
textures/tunnelmaker_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
textures/tunnelmaker_10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

BIN
textures/tunnelmaker_11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

BIN
textures/tunnelmaker_12.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

BIN
textures/tunnelmaker_13.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
textures/tunnelmaker_14.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

BIN
textures/tunnelmaker_15.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

BIN
textures/tunnelmaker_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

BIN
textures/tunnelmaker_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

BIN
textures/tunnelmaker_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

BIN
textures/tunnelmaker_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
textures/tunnelmaker_6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

BIN
textures/tunnelmaker_7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

BIN
textures/tunnelmaker_8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

BIN
textures/tunnelmaker_9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB