Replace the horribly outdated minetest.env stuff
This commit is contained in:
parent
c13823bcfc
commit
bc0879911f
35 changed files with 335 additions and 335 deletions
|
@ -1,6 +1,6 @@
|
|||
function spawn_tnt(pos, entname)
|
||||
minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,})
|
||||
return minetest.env:add_entity(pos, entname)
|
||||
return minetest.add_entity(pos, entname)
|
||||
end
|
||||
|
||||
function activate_if_tnt(nname, np, tnt_np, tntr)
|
||||
|
@ -11,7 +11,7 @@ function activate_if_tnt(nname, np, tnt_np, tntr)
|
|||
end
|
||||
|
||||
function do_tnt_physics(tnt_np,tntr)
|
||||
local objs = minetest.env:get_objects_inside_radius(tnt_np, tntr)
|
||||
local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
|
||||
for k, obj in pairs(objs) do
|
||||
local oname = obj:get_entity_name()
|
||||
local v = obj:getvelocity()
|
||||
|
@ -43,7 +43,7 @@ minetest.register_node("tnt:tnt", {
|
|||
description = "TNT",
|
||||
mesecons = {effector = {
|
||||
action_on = (function(p, node)
|
||||
minetest.env:remove_node(p)
|
||||
minetest.remove_node(p)
|
||||
spawn_tnt(p, "tnt:tnt")
|
||||
nodeupdate(p)
|
||||
end),
|
||||
|
@ -53,7 +53,7 @@ minetest.register_node("tnt:tnt", {
|
|||
|
||||
minetest.register_on_punchnode(function(p, node)
|
||||
if node.name == "tnt:tnt" then
|
||||
minetest.env:remove_node(p)
|
||||
minetest.remove_node(p)
|
||||
spawn_tnt(p, "tnt:tnt")
|
||||
nodeupdate(p)
|
||||
end
|
||||
|
@ -102,9 +102,9 @@ function TNT:on_step(dtime)
|
|||
pos.y = math.floor(pos.y+0.5)
|
||||
pos.z = math.floor(pos.z+0.5)
|
||||
do_tnt_physics(pos, TNT_RANGE)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.sound_play("tnt_explode", {pos = pos,gain = 1.0,max_hear_distance = 16,})
|
||||
if minetest.env:get_node(pos).name == "default:water_source" or minetest.env:get_node(pos).name == "default:water_flowing" or minetest.env:get_node(pos).name == "default:bedrock" or minetest.env:get_node(pos).name == "protector:display" or minetest.is_protected(pos, "tnt") then
|
||||
if minetest.get_node(pos).name == "default:water_source" or minetest.get_node(pos).name == "default:water_flowing" or minetest.get_node(pos).name == "default:bedrock" or minetest.get_node(pos).name == "protector:display" or minetest.is_protected(pos, "tnt") then
|
||||
-- Cancel the Explosion
|
||||
self.object:remove()
|
||||
return
|
||||
|
@ -114,17 +114,17 @@ function TNT:on_step(dtime)
|
|||
for z=-TNT_RANGE,TNT_RANGE do
|
||||
if x*x+y*y+z*z <= TNT_RANGE * TNT_RANGE + TNT_RANGE then
|
||||
local np={x=pos.x+x,y=pos.y+y,z=pos.z+z}
|
||||
local n = minetest.env:get_node(np)
|
||||
local n = minetest.get_node(np)
|
||||
if n.name ~= "air" and n.name ~= "default:obsidian" and n.name ~= "default:bedrock" and n.name ~= "protector:protect" then
|
||||
activate_if_tnt(n.name, np, pos, 3)
|
||||
minetest.env:remove_node(np)
|
||||
minetest.remove_node(np)
|
||||
nodeupdate(np)
|
||||
if n.name ~= "tnt:tnt" and math.random() > 0.9 then
|
||||
local drop = minetest.get_node_drops(n.name, "")
|
||||
for _,item in ipairs(drop) do
|
||||
if type(item) == "string" then
|
||||
if math.random(1,100) > 40 then
|
||||
local obj = minetest.env:add_item(np, item)
|
||||
local obj = minetest.add_item(np, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue