User:Hybrid Dog
-- recently modified by beautifier.lua
or string.find(node.name, "default:water_")
minetest.set_node(pos, {name="tnt:tnt_burning"})
end
interval = 2,
description = "TNT",
nodes[p_pos] = tnt_c_fire
if not drop_items
local p_node = area:index(p.x, p.y, p.z)
if obj == nil then
tnt_c_fire = minetest.get_content_id("fire:basic_flame")
end
for dy=-1,1 do
l = l-1
if puncher:get_wielded_item():get_name() == "default:torch" then
-- )
local function combine_texture(texture_size, frame_count, texture, ani_texture)
boom({x=p.x, y=p.y, z=p.z}, 0, player)
px = px+texture_size
sounds = default.node_sound_wood_defaults(),
obj:setacceleration({x=0, y=-10, z=0})
tiles = {"default_tnt_top.png", "default_tnt_bottom.png", tnt_side},
}
nodes[p_node] = tnt_c_tnt_burning
if nodename ~= "tnt:gunpowder" then
--minetest.set_node(pos, {name="tnt:boom"})
return
drop_items = true
manip:update_map()
end
-- recently modified by beautifier.lua
end
minetest.after(0.5, function(pos)
end
or (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item") then
else
destroy(p, player)
for dz=-1,1 do
output = "tnt:tnt",
tiles = {{name="tnt_gunpowder_burning_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}}},
pos.y = pos.y+dy
tnt_c_air = minetest.get_content_id("air")
if node.name == "tnt:tnt" then
light_source = 5,
-- recently modified by beautifier.lua
chance = 10,
end
burn({x=pos.x, y=pos.y, z=pos.z}, player)
},
for _,item in ipairs(drop) do
end, {x=pos.x, y=pos.y, z=pos.z})
{"", "group:wood", "" }
end
100, --amount
tiles = {"tnt_gunpowder.png",},
{x=pos.x-3, y=pos.y-3, z=pos.z-3}, --minpos
minetest.set_node(pos, {name="tnt:tnt_burning"})
pos.z = pos.z-dz
minetest.set_node(pos, {name="tnt:tnt_burning"})
minetest.add_particle(pos, {x=0,y=0,z=0}, {x=0,y=0,z=0}, 0.5, 16, false, "tnt_boom.png")
end
if not (math.abs(dx) == 1 and math.abs(dz) == 1) then
else
end
return
tiles = {{name=animated_tnt_texture, animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1}},
-- recently modified by beautifier.lua
minetest.register_abm({
selection_box = {
local tnt_preserve_items = false
neighbors = {"fire:basic_flame"},
for _,obj in ipairs(objects) do
end
burn(pos)
enable = function(pos)
minetest.sound_play("tnt_ignite", {pos=pos})
else
end
if obj == nil then
return
"default_tnt_bottom.png", tnt_side},
end
if minetest.get_node(pos).name ~= "tnt:gunpowder_burning" then
if minetest.setting_get("log_mods") then
end
for dz=-tnt_range,tnt_range do
minetest.register_craft({
minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=tnt_range*64})
end
local function destroy(pos, player)
sounds = default.node_sound_leaves_defaults(),
print(string.format("[tnt] exploded in: %.2fs", os.clock() - t1))
action_on = function(pos, node)
})
area = VoxelArea:new{MinEdge=emerged_pos1, MaxEdge=emerged_pos2}
end
or not tnt_preserve_items then
})
if type(item) == "string" then
if obj:is_player()
damage_groups={fleshy=damage},
false, --collisiondetection
{x=0.5,y=5,z=0.5}, --maxacc
end
sounds = default.node_sound_leaves_defaults(),
burn(pos, puncher)
manip:set_data(nodes)
local objects = minetest.get_objects_inside_radius(pos, 7)
local animated_tnt_texture = combine_texture(16, 4, "default_tnt_top.png", "tnt_top_burning_animated.png")
minetest.register_node(":tnt:tnt", {
1, --maxexptime
while l ~= 0 do
end
local tnt_side = "default_tnt_side.png^tnt_shadows.png"
obj:get_luaentity().collect = true
description = "Gun Powder",
end
15, --maxsize
type = "shapeless",
})
or string.find(node.name, "default:lava_")) then
end
return
local obj = minetest.add_item(pos, item)
if math.abs(dx) == 1 or math.abs(dz) == 1 then
},
drawtype = "raillike",
end
local combine_textures = ":0,"..px.."="..texture
on_punch = function(pos, node, puncher)
minetest.set_node(pos, {name="tnt:tnt_burning"})
0.1, --time
end
end
local px = 0
obj:setvelocity({x=pr:next(0,6)-3, y=10, z=pr:next(0,6)-3})
local function drop_item(pos, nodename, player)
for i=1,item:get_count() do
else
manip:write_to_map()
tnt_c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
sunlight_propagates = true,
obj:setvelocity({x=pr:next(0,6)-3, y=10, z=pr:next(0,6)-3})
0.1, --minexptime
{"group:wood", "tnt:gunpowder", "group:wood"},
drop = "",
minetest.add_particlespawner(
return
nodenames = {"tnt:tnt", "tnt:gunpowder"},
destroy(p, player)
return PseudoRandom(math.abs(pos.x+pos.y*3+pos.z*5)+tnt_seed)
return
full_punch_interval=1.0,
groups = {dig_immediate=2,attached_node=1},
minetest.register_craft({
)
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
laser = {
recipe = {"default:coal_lump", "default:gravel"}
local t1 = os.clock()
local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
function boom(pos, time, player)
minetest.register_node(":tnt:gunpowder", {
})
pos.x = pos.x+dx
minetest.register_node(":tnt:gunpowder_burning", {
obj:punch(obj, 1.0, {
end
end
minetest.register_node(":tnt:tnt_burning", {
inv:add_item("main", item)
output = "tnt:gunpowder",
minetest.sound_play("tnt_ignite", {pos=pos})
local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
{x=pos.x+3, y=pos.y+3, z=pos.z+3}, --maxpos
if not player then
end
selection_box = {
nodes = manip:get_data()
end
local obj_p = obj:getpos()
})
paramtype = "light",
end
return
else
pr = get_tnt_random(pos)
pos.x = pos.x-dx
inv = player:get_inventory()
end,
})
end
end
end
effector = {
minetest.after(time, function(pos)
local emerged_pos1, emerged_pos2 = manip:read_from_map({x=pos.x-width, y=pos.y-width, z=pos.z-width},
local node = minetest.get_node(p)
end
minetest.set_node(pos, {name="tnt:tnt_burning"})
end
type = "fixed",
if minetest.get_node(pos).name ~= "tnt:tnt_burning" then
on_punch = function(pos, node, puncher)
boom(pos, 2)
local tnt_range = 2
boom({x=pos.x, y=pos.y, z=pos.z}, 0)
local manip = minetest.get_voxel_manip()
end
-- minetest.remove_node(pos)
drop_item(pos, nodename, player)
elseif not ( d_p_node == tnt_c_fire
if nodes[p_pos] ~= tnt_c_air then
-- recently modified by beautifier.lua
-- end, {x=pos.x, y=pos.y, z=pos.z}
burn({x=pos.x, y=pos.y, z=pos.z}, player)
local obj = minetest.add_item(pos, item:get_name())
minetest.after(1, function(pos)
-- minetest.after(0.5, function(pos)
end,
end
wield_image = "tnt_gunpowder_inventory.png",
minetest.remove_node(pos)
{x=0, y=0, z=0}, --maxvel
boom(pos, 1, player)
end
if puncher:get_wielded_item():get_name() == "default:torch" then
local nodename = minetest.get_node(pos).name
end
end
paramtype = "light",
pos.y = pos.y-dy
sounds = default.node_sound_wood_defaults(),
local d_p_node = nodes[p_node]
{"", "group:wood", "" },
minetest.set_node(pos, {name="tnt:gunpowder_burning"})
}, vec)
obj:get_luaentity().collect = true
})
local damage = (80*0.5^dist)*2
if dy == 0 then
"tnt_smoke.png" --texture
walkable = false,
local p_pos = area:index(pos.x, pos.y, pos.z)
local function get_tnt_random(pos)
8, --minsize
drawtype = "raillike",
groups = {dig_immediate=2, mesecon=2},
},
drop = "",
end
return
function burn(pos, player)
end, pos)
--minetest.register_node("tnt:boom", {drop="", groups={dig_immediate=3}})
boom(pos, 4, puncher)
if not inv then
local drop_items = tnt_drop_items
else
and inv:room_for_item("main", item) then
tnt_c_tnt = minetest.get_content_id("tnt:tnt")
light_source = 5,
end
local tnt_drop_items = false
nodes[p_pos] = tnt_c_air
{x=-0.5,y=5,z=-0.5}, --minacc
end, pos)
if pr:next(1,3) == 3
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
inventory_image = "tnt_gunpowder_inventory.png",
combine_textures = combine_textures..":0,"..px.."="..texture
{x=-0, y=-0, z=-0}, --minvel
local t1 = os.clock()
boom(pos, 0)
nodes[p_pos] = tnt_c_air
if pr:next(1,5) <= 4 then
minetest.sound_play("tnt_gunpowder_burning", {pos=pos, gain=2})
end
local width = tnt_range
-- nodeupdate(pos)
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
-- minetest.remove_node(pos)
minetest.log("action", "tnt loaded")
if d_p_node == tnt_c_tnt
sunlight_propagates = true,
local drop = minetest.get_node_drops(nodename)
end
if math.abs(dx)<tnt_range and math.abs(dy)<tnt_range and math.abs(dz)<tnt_range then
recipe = {
type = "fixed",
if nodename == "tnt:tnt" then
end
for dx=-1,1 do
for dx=-tnt_range,tnt_range do
end
local nodename = minetest.get_node(pos).name
action = function(pos, node)
groups = {dig_immediate=2,attached_node=1},
}
pos.z = pos.z+dz
{x=pos.x+width, y=pos.y+width, z=pos.z+width})
},
walkable = false,
minetest.sound_play("tnt_ignite", {pos=pos})
print(string.format("[tnt] map updated after: %.2fs", os.clock() - t1))
local l = frame_count
return ani_texture.."^[combine:"..texture_size.."x"..texture_size*frame_count..":"..combine_textures.."^"..ani_texture
obj:setacceleration({x=0, y=-10, z=0})
mesecons = {
for dy=tnt_range,-tnt_range,-1 do
drop_items = true
local p_pos = area:index(pos.x, pos.y, pos.z)
or d_p_node == tnt_c_tnt_burning then
if minetest.registered_nodes[nodename].groups.flammable ~= nil then
local tnt_seed = 15
minetest.on_place
Syntax
minetest.on_place(nodename, func)
Description
This changes on_place of a node after it was defined.
It is not implemented into minetest but can be added via mod(s):
minetest.on_place = minetest.on_place or function(name, func)
local previous_on_place = minetest.registered_nodes[name].on_place
minetest.override_item(name, {
on_place = function(...)
if func(...) then
return previous_on_place(...)
end
end
})
end
nodename
The name of the node which should become changed
func
should return true if the node becomes set
function(itemstack, placer, pointed_thing)
Example
minetest.on_place("hydro:growlamp", function(itemstack, placer, pointed_thing)
if not pointed_thing then
return
end
local pos = minetest.get_pointed_thing_position(pointed_thing, true)
if not pos then
return
end
local nd_above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name
local nd_above_info = minetest.registered_nodes[nd_above]
if nd_above == "air"
or nd_above == "hydro:growlamp"
or not nd_above_info.walkable
or nd_above_info.buildable_to then
return
end
return true
end)
Mods
vector_extras
Those are added as fields of the vector table, e.g. vector.pos_to_string(pos)
Function | Return value | Comments | Status |
---|---|---|---|
pos_to_string(pos)
|
string | similar to minetest.pos_to_string, but better readable in my opinion | works |
line([pos, dir[, range][, alt]])
|
table of vectors | dir can be following:
if alt then the old path calculation is used |
works |
fine_line([pos, dir[, range], scale])
|
table of vectors |
|
works but old and slow |
twoline(x, y)
|
table |
|
works |
threeline(x, y, z)
|
table |
|
works |
sort(ps, [preferred_coords])
|
nil | ps, which gets changed, is a list of vectors,
which become sorted by the coord in the order of preferred_coords |
untested |
scalar(v1, v2)
|
number | v1 and v2 are vectors, returns scalar product | works |
cross(v1, v2)
|
vector | v1 and v2 are vectors, returns cross product | works |
plane(ps)
|
table of vectors | ps is a table of three vectors
returns a list of vectors which make a filled triangle plane together |
unfinished |
straightdelay([s, v[, a]])
|
number |
|
works |
sun_dir(t)
|
vector |
|
works |
inside(pos, minp, maxp)
|
bool | returns true if pos is inside or on the corners of minp and maxp | untested |
minmax(p1, p2)
|
vector, vector | the first vector's x, y and z are smaller than the second one's | untested |
move(p1, p2, s)
|
vector |
|
untested |
from_number(i)
|
vector | returns {x=i, y=i, z=i} | works |
explosion_table(r)
|
table |
|
works |
explosion_perlin(rmin, rmax[, nparams])
|
table | it is used to make perlin noise surface on spheres, which looks good for explosions | works |
circle(r)
|
table of vectors |
|
works |
ring(r)
|
table of vectors |
|
works |
chunkcorner(pos)
|
vector | should return the chunkcorner near pos | could work |
point_distance_minmax(p1, p2)
|
2 numbers | ||
collision(p1, p2)
|
|||
get_data_from_pos(tab, z,y,x)
|
tab[z][y][x] or nil | used to get stored information in a table about these coords | works |
set_data_to_pos(tab, z,y,x, data)
|
nil | used to store information in a table about these coords | works |
set_data_to_pos_optional(tab, z,y,x, data)
|
nil | runs set_data_from_pos if get_data_from_pos returned nil there | works |
remove_data_from_pos(tab, z,y,x)
|
nil | used to remove information from a table about these coords | works |
get_data_pos_table(tab)
|
table |
|
works |
update_minp_maxp(minp, maxp, pos)
|
nil | changes minp and maxp to exceed their borders | works |
quickadd(pos[, z,y,x])
|
nil | adds those to pos' | works |
unpack(pos)
|
3 numbers | returns pos.z, pos.y, pos.x | works |
zero
|
{x=0, y=0, z=0} | not a function | works |