Skip to content

Commit

Permalink
Added Readme and License file, minimum depth can now be configured, g…
Browse files Browse the repository at this point in the history
…unpowder cannot be lighted above that minimum depth so players are not annoyed.
  • Loading branch information
gpcf committed Oct 22, 2016
1 parent 50e5c52 commit ead9f0f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
3 changes: 3 additions & 0 deletions LICENSE
@@ -0,0 +1,3 @@
Sounds: alarm.ogg
Source: https://commons.wikimedia.org/wiki/File:BABS_-_Allgemeiner_Alarm.ogg
License: Public domain
37 changes: 37 additions & 0 deletions README.txt
@@ -0,0 +1,37 @@
Minetest Game mod: tnt
======================
by PilzAdam and ShadowNinja

Introduction:
This mod adds TNT to Minetest. TNT is a tool to help the player
in mining.

How to use the mod:
Craft gunpowder by placing coal and gravel in the crafting area. The
gunpowder can be used to craft TNT or as fuze for TNT. To craft TNT
surround gunpowder with 4 wood in a + shape.
There are different ways to blow up TNT:
1. Hit it with a torch.
2. Hit a gunpowder fuze that leads to a TNT block with a torch.
3. Activate it with mesecons (fastest way)
Be aware of the damage radius of 7 blocks!

License:
WTFPL (see below)

See also:
http://minetest.net/

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
13 changes: 8 additions & 5 deletions init.lua
Expand Up @@ -3,6 +3,8 @@ tnt = {}
local singleplayer = minetest.is_singleplayer()
local setting = minetest.setting_getbool("enable_tnt")
setting = true -- this mod is multiplayer-safe, so enable it.
local tntmindepth = tonumber(minetest.setting_get("tnt_mindepth")) or -100

if (not singleplayer and setting ~= true) or
(singleplayer and setting == false) then
return
Expand Down Expand Up @@ -364,8 +366,8 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)
end

function tnt.boom(pos, def)
if pos.y > -100 then
-- minetest.chat_send_all("TNT can only explode when deeper than -100")
if pos.y > tntmindepth then
-- check if we're deep enough
minetest.set_node(pos, {name = "tnt:tnt"})
return
end
Expand Down Expand Up @@ -417,9 +419,10 @@ minetest.register_node("tnt:gunpowder", {
sounds = default.node_sound_leaves_defaults(),

on_punch = function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "default:torch" then
tnt.burn(pos)
end
if puncher:get_wielded_item():get_name() == "default:torch" and pos.y < (tntmindepth + 16)then
-- check if we're deep enough, don't annoy people with the air-raid sound.
tnt.burn(pos)
end
end,
on_blast = function(pos, intensity)
tnt.burn(pos)
Expand Down

0 comments on commit ead9f0f

Please sign in to comment.