1
0
Fork 0

Replace the horribly outdated minetest.env stuff

This commit is contained in:
Wuzzy 2017-01-11 18:21:46 +01:00
parent c13823bcfc
commit bc0879911f
35 changed files with 335 additions and 335 deletions

View File

@ -5,13 +5,13 @@ local old_yaw = 0
local function get_dir(pos) local function get_dir(pos)
local btop = "beds:bed_top" local btop = "beds:bed_top"
if minetest.env:get_node({x=pos.x+1,y=pos.y,z=pos.z}).name == btop then if minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).name == btop then
return 7.9 return 7.9
elseif minetest.env:get_node({x=pos.x-1,y=pos.y,z=pos.z}).name == btop then elseif minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).name == btop then
return 4.75 return 4.75
elseif minetest.env:get_node({x=pos.x,y=pos.y,z=pos.z+1}).name == btop then elseif minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).name == btop then
return 3.15 return 3.15
elseif minetest.env:get_node({x=pos.x,y=pos.y,z=pos.z-1}).name == btop then elseif minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).name == btop then
return 6.28 return 6.28
end end
end end
@ -28,15 +28,15 @@ function plock(start, max, tick, player, yaw)
end end
function exit(pos) function exit(pos)
local npos = minetest.env:find_node_near(pos, 1, "beds:bed_bottom") local npos = minetest.find_node_near(pos, 1, "beds:bed_bottom")
if npos ~= nil then pos = npos end if npos ~= nil then pos = npos end
if minetest.env:get_node({x=pos.x+1,y=pos.y,z=pos.z}).name == "air" then if minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).name == "air" then
return {x=pos.x+1,y=pos.y,z=pos.z} return {x=pos.x+1,y=pos.y,z=pos.z}
elseif minetest.env:get_node({x=pos.x-1,y=pos.y,z=pos.z}).name == "air" then elseif minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).name == "air" then
return {x=pos.x-1,y=pos.y,z=pos.z} return {x=pos.x-1,y=pos.y,z=pos.z}
elseif minetest.env:get_node({x=pos.x,y=pos.y,z=pos.z+1}).name == "air" then elseif minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).name == "air" then
return {x=pos.x,y=pos.y,z=pos.z+1} return {x=pos.x,y=pos.y,z=pos.z+1}
elseif minetest.env:get_node({x=pos.x,y=pos.y,z=pos.z-1}).name == "air" then elseif minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).name == "air" then
return {x=pos.x,y=pos.y,z=pos.z-1} return {x=pos.x,y=pos.y,z=pos.z-1}
else else
return {x=pos.x,y=pos.y,z=pos.z} return {x=pos.x,y=pos.y,z=pos.z}
@ -67,7 +67,7 @@ minetest.register_node("beds:bed_bottom", {
}, },
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer, itemstack)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local param2 = node.param2 local param2 = node.param2
local npos = {x=pos.x, y=pos.y, z=pos.z} local npos = {x=pos.x, y=pos.y, z=pos.z}
if param2 == 0 then if param2 == 0 then
@ -79,17 +79,17 @@ minetest.register_node("beds:bed_bottom", {
elseif param2 == 3 then elseif param2 == 3 then
npos.x = npos.x-1 npos.x = npos.x-1
end end
if minetest.registered_nodes[minetest.env:get_node(npos).name].buildable_to == true and minetest.env:get_node({x=npos.x, y=npos.y-1, z=npos.z}).name ~= "air" then if minetest.registered_nodes[minetest.get_node(npos).name].buildable_to == true and minetest.get_node({x=npos.x, y=npos.y-1, z=npos.z}).name ~= "air" then
minetest.env:set_node(npos, {name="beds:bed_top", param2 = param2}) minetest.set_node(npos, {name="beds:bed_top", param2 = param2})
else else
minetest.env:dig_node(pos) minetest.dig_node(pos)
return true return true
end end
end, end,
on_destruct = function(pos) on_destruct = function(pos)
pos = minetest.env:find_node_near(pos, 1, "beds:bed_top") pos = minetest.find_node_near(pos, 1, "beds:bed_top")
if pos ~= nil then minetest.env:remove_node(pos) end if pos ~= nil then minetest.remove_node(pos) end
end, end,
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
@ -97,7 +97,7 @@ minetest.register_node("beds:bed_bottom", {
return return
end end
if minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.805 then if minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.805 then
minetest.chat_send_all("You can only sleep at night") minetest.chat_send_all("You can only sleep at night")
return return
else else
@ -110,7 +110,7 @@ minetest.register_node("beds:bed_bottom", {
end end
if not clicker:get_player_control().sneak then if not clicker:get_player_control().sneak then
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local param2 = node.param2 local param2 = node.param2
if param2 == 0 then if param2 == 0 then
pos.z = pos.z+1 pos.z = pos.z+1
@ -191,10 +191,10 @@ minetest.register_globalstep(function(dtime)
local players = #minetest.get_connected_players() local players = #minetest.get_connected_players()
if players == player_in_bed and players ~= 0 then if players == player_in_bed and players ~= 0 then
if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.805 then if minetest.get_timeofday() < 0.2 or minetest.get_timeofday() > 0.805 then
if not wait then if not wait then
minetest.after(2, function() minetest.after(2, function()
minetest.env:set_timeofday(0.23) minetest.set_timeofday(0.23)
wait = false wait = false
guy:set_physics_override(1,1,1) guy:set_physics_override(1,1,1)
guy:setpos(exit(guy:getpos())) guy:setpos(exit(guy:getpos()))
@ -227,7 +227,7 @@ minetest.register_abm({
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_string("player") ~= "" then if meta:get_string("player") ~= "" then
local param2 = node.param2 local param2 = node.param2
if param2 == 0 then if param2 == 0 then
@ -239,7 +239,7 @@ minetest.register_abm({
elseif param2 == 3 then elseif param2 == 3 then
pos.x = pos.x-1 pos.x = pos.x-1
end end
local player = minetest.env:get_player_by_name(meta:get_string("player")) local player = minetest.get_player_by_name(meta:get_string("player"))
if player == nil then if player == nil then
meta:set_string("player", "") meta:set_string("player", "")
player_in_bed = player_in_bed-1 player_in_bed = player_in_bed-1

View File

@ -43,7 +43,7 @@ minetest.register_node("cake:cake", {
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
clicker:set_hp(clicker:get_hp()+2) clicker:set_hp(clicker:get_hp()+2)
minetest.env:add_node(pos,{type="node",name="cake:cake_5",param2=param2}) minetest.add_node(pos,{type="node",name="cake:cake_5",param2=param2})
end end
end, end,
}) })
@ -67,7 +67,7 @@ minetest.register_node("cake:cake_5", {
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
clicker:set_hp(clicker:get_hp()+2) clicker:set_hp(clicker:get_hp()+2)
minetest.env:add_node(pos,{type="node",name="cake:cake_4",param2=param2}) minetest.add_node(pos,{type="node",name="cake:cake_4",param2=param2})
end end
end, end,
}) })
@ -91,7 +91,7 @@ minetest.register_node("cake:cake_4", {
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
clicker:set_hp(clicker:get_hp()+2) clicker:set_hp(clicker:get_hp()+2)
minetest.env:add_node(pos,{type="node",name="cake:cake_3",param2=param2}) minetest.add_node(pos,{type="node",name="cake:cake_3",param2=param2})
end end
end, end,
}) })
@ -115,7 +115,7 @@ minetest.register_node("cake:cake_3", {
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
clicker:set_hp(clicker:get_hp()+2) clicker:set_hp(clicker:get_hp()+2)
minetest.env:add_node(pos,{type="node",name="cake:cake_2",param2=param2}) minetest.add_node(pos,{type="node",name="cake:cake_2",param2=param2})
end end
end, end,
}) })
@ -139,7 +139,7 @@ minetest.register_node("cake:cake_2", {
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
clicker:set_hp(clicker:get_hp()+2) clicker:set_hp(clicker:get_hp()+2)
minetest.env:add_node(pos,{type="node",name="cake:cake_1",param2=param2}) minetest.add_node(pos,{type="node",name="cake:cake_1",param2=param2})
end end
end, end,
}) })
@ -163,7 +163,7 @@ minetest.register_node("cake:cake_1", {
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
clicker:set_hp(clicker:get_hp()+2) clicker:set_hp(clicker:get_hp()+2)
minetest.env:remove_node(pos) minetest.remove_node(pos)
end end
end, end,
}) })

View File

@ -7,7 +7,7 @@ local function item_drop(itemstack, dropper, pos)
local p = {x=pos.x, y=pos.y+1.2, z=pos.z} local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
p.x = p.x+(math.random(1,3)*0.2) p.x = p.x+(math.random(1,3)*0.2)
p.z = p.z+(math.random(1,3)*0.2) p.z = p.z+(math.random(1,3)*0.2)
local obj = minetest.env:add_item(p, itemstack) local obj = minetest.add_item(p, itemstack)
if obj then if obj then
v.x = v.x*4 v.x = v.x*4
v.y = v.y*4 + 2 v.y = v.y*4 + 2

View File

@ -292,8 +292,8 @@ function default.generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume
local y2 = y0+y1 local y2 = y0+y1
local z2 = z0+z1 local z2 = z0+z1
local p2 = {x=x2, y=y2, z=z2} local p2 = {x=x2, y=y2, z=z2}
if minetest.env:get_node(p2).name == wherein then if minetest.get_node(p2).name == wherein then
minetest.env:set_node(p2, {name=name}) minetest.set_node(p2, {name=name})
end end
end end
end end
@ -307,10 +307,10 @@ end
function default.make_reeds(pos, size) function default.make_reeds(pos, size)
for y=0,size-1 do for y=0,size-1 do
local p = {x=pos.x, y=pos.y+y, z=pos.z} local p = {x=pos.x, y=pos.y+y, z=pos.z}
local nn = minetest.env:get_node(p).name local nn = minetest.get_node(p).name
if minetest.registered_nodes[nn] and if minetest.registered_nodes[nn] and
minetest.registered_nodes[nn].buildable_to then minetest.registered_nodes[nn].buildable_to then
minetest.env:set_node(p, {name="default:reeds"}) minetest.set_node(p, {name="default:reeds"})
else else
return return
end end
@ -320,10 +320,10 @@ end
function default.make_cactus(pos, size) function default.make_cactus(pos, size)
for y=0,size-1 do for y=0,size-1 do
local p = {x=pos.x, y=pos.y+y, z=pos.z} local p = {x=pos.x, y=pos.y+y, z=pos.z}
local nn = minetest.env:get_node(p).name local nn = minetest.get_node(p).name
if minetest.registered_nodes[nn] and if minetest.registered_nodes[nn] and
minetest.registered_nodes[nn].buildable_to then minetest.registered_nodes[nn].buildable_to then
minetest.env:set_node(p, {name="default:cactus"}) minetest.set_node(p, {name="default:cactus"})
else else
return return
end end
@ -341,17 +341,17 @@ minetest.register_on_generated(function(minp, maxp, seed)
for divz=0+1,divs-1-1 do for divz=0+1,divs-1-1 do
local cx = minp.x + math.floor((divx+0.5)*divlen) local cx = minp.x + math.floor((divx+0.5)*divlen)
local cz = minp.z + math.floor((divz+0.5)*divlen) local cz = minp.z + math.floor((divz+0.5)*divlen)
if minetest.env:get_node({x=cx,y=1,z=cz}).name == "default:water_source" and if minetest.get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then minetest.get_node({x=cx,y=0,z=cz}).name == "default:sand" then
local is_shallow = true local is_shallow = true
local num_water_around = 0 local num_water_around = 0
if minetest.env:get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then if minetest.get_node({x=cx-divlen*2,y=1,z=cz+0}).name == "default:water_source" then
num_water_around = num_water_around + 1 end num_water_around = num_water_around + 1 end
if minetest.env:get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then if minetest.get_node({x=cx+divlen*2,y=1,z=cz+0}).name == "default:water_source" then
num_water_around = num_water_around + 1 end num_water_around = num_water_around + 1 end
if minetest.env:get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then if minetest.get_node({x=cx+0,y=1,z=cz-divlen*2}).name == "default:water_source" then
num_water_around = num_water_around + 1 end num_water_around = num_water_around + 1 end
if minetest.env:get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then if minetest.get_node({x=cx+0,y=1,z=cz+divlen*2}).name == "default:water_source" then
num_water_around = num_water_around + 1 end num_water_around = num_water_around + 1 end
if num_water_around >= 2 then if num_water_around >= 2 then
is_shallow = false is_shallow = false
@ -359,8 +359,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
if is_shallow then if is_shallow then
for x1=-divlen,divlen do for x1=-divlen,divlen do
for z1=-divlen,divlen do for z1=-divlen,divlen do
if minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" or minetest.env:get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sandstone" then if minetest.get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sand" or minetest.get_node({x=cx+x1,y=0,z=cz+z1}).name == "default:sandstone" then
minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"}) minetest.set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
end end
end end
end end
@ -369,7 +369,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
-- Generate reeds -- Generate reeds
local perlin1 = minetest.env:get_perlin(354, 3, 0.7, 100) local perlin1 = minetest.get_perlin(354, 3, 0.7, 100)
-- Assume X and Z lengths are equal -- Assume X and Z lengths are equal
local divlen = 8 local divlen = 8
local divs = (maxp.x-minp.x)/divlen+1; local divs = (maxp.x-minp.x)/divlen+1;
@ -386,12 +386,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
for i=0,reeds_amount do for i=0,reeds_amount do
local x = pr:next(x0, x1) local x = pr:next(x0, x1)
local z = pr:next(z0, z1) local z = pr:next(z0, z1)
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and if minetest.get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then minetest.find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
default.make_reeds({x=x,y=2,z=z}, pr:next(2, 4)) default.make_reeds({x=x,y=2,z=z}, pr:next(2, 4))
end end
local p = {x=x,y=1,z=z} local p = {x=x,y=1,z=z}
if minetest.env:get_node(p).name == "default:sand" then if minetest.get_node(p).name == "default:sand" then
if math.random(0,1000) == 1 then -- 0,12000 if math.random(0,1000) == 1 then -- 0,12000
random_struct.call_struct(p,2) random_struct.call_struct(p,2)
end end
@ -401,7 +401,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
-- Generate cactuses -- Generate cactuses
local perlin1 = minetest.env:get_perlin(230, 3, 0.6, 100) local perlin1 = minetest.get_perlin(230, 3, 0.6, 100)
-- Assume X and Z lengths are equal -- Assume X and Z lengths are equal
local divlen = 16 local divlen = 16
local divs = (maxp.x-minp.x)/divlen+1; local divs = (maxp.x-minp.x)/divlen+1;
@ -421,20 +421,20 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- Find ground level (0...15) -- Find ground level (0...15)
local ground_y = nil local ground_y = nil
for y=30,0,-1 do for y=30,0,-1 do
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
ground_y = y ground_y = y
break break
end end
end end
-- If desert sand, make cactus -- If desert sand, make cactus
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then if ground_y and minetest.get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4)) default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
end end
end end
end end
end end
-- Generate grass -- Generate grass
local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100) local perlin1 = minetest.get_perlin(329, 3, 0.6, 100)
-- Assume X and Z lengths are equal -- Assume X and Z lengths are equal
local divlen = 5 local divlen = 5
local divs = (maxp.x-minp.x)/divlen+1; local divs = (maxp.x-minp.x)/divlen+1;
@ -454,7 +454,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- Find ground level (0...15) -- Find ground level (0...15)
local ground_y = nil local ground_y = nil
for y=30,0,-1 do for y=30,0,-1 do
if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
ground_y = y ground_y = y
break break
end end
@ -462,18 +462,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
if ground_y then if ground_y then
local p = {x=x,y=ground_y+1,z=z} local p = {x=x,y=ground_y+1,z=z}
local nn = minetest.env:get_node(p).name local nn = minetest.get_node(p).name
-- Check if the node can be replaced -- Check if the node can be replaced
if minetest.registered_nodes[nn] and if minetest.registered_nodes[nn] and
minetest.registered_nodes[nn].buildable_to then minetest.registered_nodes[nn].buildable_to then
nn = minetest.env:get_node({x=x,y=ground_y,z=z}).name nn = minetest.get_node({x=x,y=ground_y,z=z}).name
-- If desert sand, add dry shrub -- If desert sand, add dry shrub
if nn == "default:desert_sand" then if nn == "default:desert_sand" then
minetest.env:set_node(p,{name="default:dry_shrub"}) minetest.set_node(p,{name="default:dry_shrub"})
-- If dirt with grass, add grass -- If dirt with grass, add grass
elseif nn == "default:dirt_with_grass" then elseif nn == "default:dirt_with_grass" then
minetest.env:set_node(p,{name="default:grass"}) minetest.set_node(p,{name="default:grass"})
if math.random(0,12000) == 1 then if math.random(0,12000) == 1 then
random_struct.call_struct(p,1) random_struct.call_struct(p,1)
end end

View File

@ -1118,7 +1118,7 @@ minetest.register_node("default:vine", {
local ptr = 1 local ptr = 1
while next_find == true do while next_find == true do
local pos2 = {x=pos.x, y=pos.y-ptr, z=pos.z} local pos2 = {x=pos.x, y=pos.y-ptr, z=pos.z}
local node = minetest.env:get_node(pos2) local node = minetest.get_node(pos2)
if node.name == "default:vine" and check_attached_node(pos2, node) == false then if node.name == "default:vine" and check_attached_node(pos2, node) == false then
drop_attached_node(pos2) drop_attached_node(pos2)
nodeupdate(pos2) nodeupdate(pos2)
@ -1318,16 +1318,16 @@ local function get_chest_neighborpos(pos, param2, side)
end end
local function hacky_swap_node(pos,name, param2) local function hacky_swap_node(pos,name, param2)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if node.name == name then if node.name == name then
return return
end end
node.name = name node.name = name
node.param2 = param2 or node.param2 node.param2 = param2 or node.param2
local meta0 = meta:to_table() local meta0 = meta:to_table()
minetest.env:set_node(pos,node) minetest.set_node(pos,node)
meta = minetest.env:get_meta(pos) meta = minetest.get_meta(pos)
meta:from_table(meta0) meta:from_table(meta0)
end end
@ -1341,10 +1341,10 @@ minetest.register_node("default:chest", {
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local param2 = minetest.env:get_node(pos).param2 local param2 = minetest.get_node(pos).param2
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if minetest.env:get_node(get_chest_neighborpos(pos, param2, "right")).name == "default:chest" then if minetest.get_node(get_chest_neighborpos(pos, param2, "right")).name == "default:chest" then
minetest.env:set_node(pos, {name="default:chest_right",param2=param2}) minetest.set_node(pos, {name="default:chest_right",param2=param2})
local p = get_chest_neighborpos(pos, param2, "right") local p = get_chest_neighborpos(pos, param2, "right")
meta:set_string("formspec", meta:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
@ -1358,7 +1358,7 @@ minetest.register_node("default:chest", {
"listring[current_name;main]") "listring[current_name;main]")
meta:set_string("infotext", "Large Chest") meta:set_string("infotext", "Large Chest")
hacky_swap_node(p, "default:chest_left", param2) hacky_swap_node(p, "default:chest_left", param2)
local m = minetest.env:get_meta(p) local m = minetest.get_meta(p)
m:set_string("formspec", m:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
"list[current_name;main;0,0;9,3;]".. "list[current_name;main;0,0;9,3;]"..
@ -1370,8 +1370,8 @@ minetest.register_node("default:chest", {
"listring[current_player;main]".. "listring[current_player;main]"..
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]") "listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]")
m:set_string("infotext", "Large Chest") m:set_string("infotext", "Large Chest")
elseif minetest.env:get_node(get_chest_neighborpos(pos, param2, "left")).name == "default:chest" then elseif minetest.get_node(get_chest_neighborpos(pos, param2, "left")).name == "default:chest" then
minetest.env:set_node(pos, {name="default:chest_left",param2=param2}) minetest.set_node(pos, {name="default:chest_left",param2=param2})
local p = get_chest_neighborpos(pos, param2, "left") local p = get_chest_neighborpos(pos, param2, "left")
meta:set_string("formspec", meta:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
@ -1385,7 +1385,7 @@ minetest.register_node("default:chest", {
"listring[nodemeta:"..p.x..","..p.y..","..p.z..";main]") "listring[nodemeta:"..p.x..","..p.y..","..p.z..";main]")
meta:set_string("infotext", "Large Chest") meta:set_string("infotext", "Large Chest")
hacky_swap_node(p, "default:chest_right", param2) hacky_swap_node(p, "default:chest_right", param2)
local m = minetest.env:get_meta(p) local m = minetest.get_meta(p)
m:set_string("formspec", m:set_string("formspec",
"size[9,11.5]".. "size[9,11.5]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0;9,3;]".. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0;9,3;]"..
@ -1413,7 +1413,7 @@ minetest.register_node("default:chest", {
inv:set_size("main", 9*3) inv:set_size("main", 9*3)
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local meta2 = meta local meta2 = meta
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -1421,7 +1421,7 @@ minetest.register_node("default:chest", {
local stack = inv:get_stack("main", i) local stack = inv:get_stack("main", i)
if not stack:is_empty() then if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.env:add_item(p, stack) minetest.add_item(p, stack)
end end
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
@ -1449,16 +1449,16 @@ minetest.register_node("default:chest_left", {
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_destruct = function(pos) on_destruct = function(pos)
local m = minetest.env:get_meta(pos) local m = minetest.get_meta(pos)
if m:get_string("infotext") == "Chest" then if m:get_string("infotext") == "Chest" then
return return
end end
local param2 = minetest.env:get_node(pos).param2 local param2 = minetest.get_node(pos).param2
local p = get_chest_neighborpos(pos, param2, "left") local p = get_chest_neighborpos(pos, param2, "left")
if not p or minetest.env:get_node(p).name ~= "default:chest_right" then if not p or minetest.get_node(p).name ~= "default:chest_right" then
return return
end end
local meta = minetest.env:get_meta(p) local meta = minetest.get_meta(p)
meta:set_string("formspec", meta:set_string("formspec",
"size[9,8.75]".. "size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]".. "background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
@ -1472,7 +1472,7 @@ minetest.register_node("default:chest_left", {
hacky_swap_node(p, "default:chest") hacky_swap_node(p, "default:chest")
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local meta2 = meta local meta2 = meta
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -1480,7 +1480,7 @@ minetest.register_node("default:chest_left", {
local stack = inv:get_stack("main", i) local stack = inv:get_stack("main", i)
if not stack:is_empty() then if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.env:add_item(p, stack) minetest.add_item(p, stack)
end end
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
@ -1508,16 +1508,16 @@ minetest.register_node("default:chest_right", {
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_destruct = function(pos) on_destruct = function(pos)
local m = minetest.env:get_meta(pos) local m = minetest.get_meta(pos)
if m:get_string("infotext") == "Chest" then if m:get_string("infotext") == "Chest" then
return return
end end
local param2 = minetest.env:get_node(pos).param2 local param2 = minetest.get_node(pos).param2
local p = get_chest_neighborpos(pos, param2, "right") local p = get_chest_neighborpos(pos, param2, "right")
if not p or minetest.env:get_node(p).name ~= "default:chest_left" then if not p or minetest.get_node(p).name ~= "default:chest_left" then
return return
end end
local meta = minetest.env:get_meta(p) local meta = minetest.get_meta(p)
meta:set_string("formspec", meta:set_string("formspec",
"size[9,8.75]".. "size[9,8.75]"..
"background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]".. "background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]"..
@ -1531,7 +1531,7 @@ minetest.register_node("default:chest_right", {
hacky_swap_node(p, "default:chest") hacky_swap_node(p, "default:chest")
end, end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local meta2 = meta local meta2 = meta
meta:from_table(oldmetadata) meta:from_table(oldmetadata)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -1539,7 +1539,7 @@ minetest.register_node("default:chest_right", {
local stack = inv:get_stack("main", i) local stack = inv:get_stack("main", i)
if not stack:is_empty() then if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.env:add_item(p, stack) minetest.add_item(p, stack)
end end
end end
meta:from_table(meta2:to_table()) meta:from_table(meta2:to_table())
@ -1585,7 +1585,7 @@ minetest.register_node("default:furnace", {
groups = {cracky=2}, groups = {cracky=2},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.furnace_inactive_formspec) meta:set_string("formspec", default.furnace_inactive_formspec)
meta:set_string("infotext", "Furnace") meta:set_string("infotext", "Furnace")
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -1594,7 +1594,7 @@ minetest.register_node("default:furnace", {
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then if not inv:is_empty("fuel") then
return false return false
@ -1606,7 +1606,7 @@ minetest.register_node("default:furnace", {
return true return true
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if listname == "fuel" then if listname == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
@ -1624,7 +1624,7 @@ minetest.register_node("default:furnace", {
end end
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index) local stack = inv:get_stack(from_list, from_index)
if to_list == "fuel" then if to_list == "fuel" then
@ -1655,7 +1655,7 @@ minetest.register_node("default:furnace_active", {
groups = {cracky=2, not_in_creative_inventory=1}, groups = {cracky=2, not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.furnace_inactive_formspec) meta:set_string("formspec", default.furnace_inactive_formspec)
meta:set_string("infotext", "Furnace"); meta:set_string("infotext", "Furnace");
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -1664,7 +1664,7 @@ minetest.register_node("default:furnace_active", {
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then if not inv:is_empty("fuel") then
return false return false
@ -1676,7 +1676,7 @@ minetest.register_node("default:furnace_active", {
return true return true
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if listname == "fuel" then if listname == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
@ -1694,7 +1694,7 @@ minetest.register_node("default:furnace_active", {
end end
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index) local stack = inv:get_stack(from_list, from_index)
if to_list == "fuel" then if to_list == "fuel" then
@ -1715,16 +1715,16 @@ minetest.register_node("default:furnace_active", {
}) })
function hacky_swap_node(pos,name) function hacky_swap_node(pos,name)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local meta0 = meta:to_table() local meta0 = meta:to_table()
if node.name == name then if node.name == name then
return return
end end
node.name = name node.name = name
local meta0 = meta:to_table() local meta0 = meta:to_table()
minetest.env:set_node(pos,node) minetest.set_node(pos,node)
meta = minetest.env:get_meta(pos) meta = minetest.get_meta(pos)
meta:from_table(meta0) meta:from_table(meta0)
end end
@ -1733,7 +1733,7 @@ minetest.register_abm({
interval = 1.0, interval = 1.0,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
for i, name in ipairs({ for i, name in ipairs({
"fuel_totaltime", "fuel_totaltime",
"fuel_time", "fuel_time",
@ -2020,13 +2020,13 @@ minetest.register_node("default:sponge", {
local on_water = false local on_water = false
local pos = pointed_thing.above local pos = pointed_thing.above
-- verifier si il est dans l'eau ou a cotée -- verifier si il est dans l'eau ou a cotée
if string.find(minetest.env:get_node(pointed_thing.above).name, "water_source") if string.find(minetest.get_node(pointed_thing.above).name, "water_source")
or string.find(minetest.env:get_node(pointed_thing.above).name, "water_flowing") then or string.find(minetest.get_node(pointed_thing.above).name, "water_flowing") then
on_water = true on_water = true
end end
for i=-1,1 do for i=-1,1 do
local p = {x=pos.x+i, y=pos.y, z=pos.z} local p = {x=pos.x+i, y=pos.y, z=pos.z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
-- On verifie si il y a de l'eau -- On verifie si il y a de l'eau
if (n.name=="default:water_flowing") or (n.name == "default:water_source") then if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
on_water = true on_water = true
@ -2034,7 +2034,7 @@ minetest.register_node("default:sponge", {
end end
for i=-1,1 do for i=-1,1 do
local p = {x=pos.x, y=pos.y+i, z=pos.z} local p = {x=pos.x, y=pos.y+i, z=pos.z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
-- On verifie si il y a de l'eau -- On verifie si il y a de l'eau
if (n.name=="default:water_flowing") or (n.name == "default:water_source") then if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
on_water = true on_water = true
@ -2042,7 +2042,7 @@ minetest.register_node("default:sponge", {
end end
for i=-1,1 do for i=-1,1 do
local p = {x=pos.x, y=pos.y, z=pos.z+i} local p = {x=pos.x, y=pos.y, z=pos.z+i}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
-- On verifie si il y a de l'eau -- On verifie si il y a de l'eau
if (n.name=="default:water_flowing") or (n.name == "default:water_source") then if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
on_water = true on_water = true
@ -2054,10 +2054,10 @@ minetest.register_node("default:sponge", {
for j=-3,3 do for j=-3,3 do
for k=-3,3 do for k=-3,3 do
p = {x=pos.x+i, y=pos.y+j, z=pos.z+k} p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
n = minetest.env:get_node(p) n = minetest.get_node(p)
-- On Supprime l'eau -- On Supprime l'eau
if (n.name=="default:water_flowing") or (n.name == "default:water_source")then if (n.name=="default:water_flowing") or (n.name == "default:water_source")then
minetest.env:add_node(p, {name="air"}) minetest.add_node(p, {name="air"})
change = true change = true
end end
end end
@ -2065,11 +2065,11 @@ minetest.register_node("default:sponge", {
end end
end end
local p = {x=pos.x, y=pos.y, z=pos.z} local p = {x=pos.x, y=pos.y, z=pos.z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
if change == true then if change == true then
minetest.env:add_node(pointed_thing.above, {name = "default:sponge_wet"}) minetest.add_node(pointed_thing.above, {name = "default:sponge_wet"})
else else
minetest.env:add_node(pointed_thing.above, {name = "default:sponge"}) minetest.add_node(pointed_thing.above, {name = "default:sponge"})
end end
return itemstack return itemstack

View File

@ -306,7 +306,7 @@ minetest.register_tool("default:pole", {
liquids_pointable = true, liquids_pointable = true,
on_use = function (itemstack, user, pointed_thing) on_use = function (itemstack, user, pointed_thing)
if pointed_thing and pointed_thing.under then if pointed_thing and pointed_thing.under then
local node = minetest.env:get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
if string.find(node.name, "default:water") then if string.find(node.name, "default:water") then
if math.random(1, 100) > 50 then if math.random(1, 100) > 50 then
local inv = user:get_inventory() local inv = user:get_inventory()
@ -348,8 +348,8 @@ minetest.register_craftitem("default:snowball", {
on_use = snow_shoot_snowball, on_use = snow_shoot_snowball,
on_construct = function(pos) on_construct = function(pos)
pos.y = pos.y - 1 pos.y = pos.y - 1
if minetest.env:get_node(pos).name == "default:dirt_with_grass" then if minetest.get_node(pos).name == "default:dirt_with_grass" then
minetest.env:set_node(pos, {name="default:dirt_with_snow"}) minetest.set_node(pos, {name="default:dirt_with_snow"})
end end
end, end,
}) })

View File

@ -18,8 +18,8 @@ doors = {}
-- open it -- open it
local function is_right(pos, clicker) local function is_right(pos, clicker)
local r1 = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) local r1 = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
local r2 = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) local r2 = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
if string.find(r1.name, "door_") or string.find(r2.name, "door_") then if string.find(r1.name, "door_") or string.find(r2.name, "door_") then
return true return true
else else
@ -58,7 +58,7 @@ function doors:register_door(name, def)
return itemstack return itemstack
end end
local ptu = pointed_thing.under local ptu = pointed_thing.under
local nu = minetest.env:get_node(ptu) local nu = minetest.get_node(ptu)
if minetest.registered_nodes[nu.name].on_rightclick then if minetest.registered_nodes[nu.name].on_rightclick then
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack) return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
end end
@ -67,8 +67,8 @@ function doors:register_door(name, def)
local pt2 = {x=pt.x, y=pt.y, z=pt.z} local pt2 = {x=pt.x, y=pt.y, z=pt.z}
pt2.y = pt2.y+1 pt2.y = pt2.y+1
if if
not minetest.registered_nodes[minetest.env:get_node(pt).name].buildable_to or not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to or
not minetest.registered_nodes[minetest.env:get_node(pt2).name].buildable_to or not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to or
not placer or not placer or
not placer:is_player() not placer:is_player()
then then
@ -86,20 +86,20 @@ function doors:register_door(name, def)
elseif p2 == 3 then elseif p2 == 3 then
pt3.z = pt3.z-1 pt3.z = pt3.z-1
end end
if not string.find(minetest.env:get_node(pt3).name, name.."_b_") then if not string.find(minetest.get_node(pt3).name, name.."_b_") then
minetest.env:set_node(pt, {name=name.."_b_1", param2=p2}) minetest.set_node(pt, {name=name.."_b_1", param2=p2})
minetest.env:set_node(pt2, {name=name.."_t_1", param2=p2}) minetest.set_node(pt2, {name=name.."_t_1", param2=p2})
else else
minetest.env:set_node(pt, {name=name.."_b_2", param2=p2}) minetest.set_node(pt, {name=name.."_b_2", param2=p2})
minetest.env:set_node(pt2, {name=name.."_t_2", param2=p2}) minetest.set_node(pt2, {name=name.."_t_2", param2=p2})
end end
if def.only_placer_can_open then if def.only_placer_can_open then
local pn = placer:get_player_name() local pn = placer:get_player_name()
local meta = minetest.env:get_meta(pt) local meta = minetest.get_meta(pt)
meta:set_string("doors_owner", "") meta:set_string("doors_owner", "")
--meta:set_string("infotext", "Owned by "..pn) --meta:set_string("infotext", "Owned by "..pn)
meta = minetest.env:get_meta(pt2) meta = minetest.get_meta(pt2)
meta:set_string("doors_owner", "") meta:set_string("doors_owner", "")
--meta:set_string("infotext", "Owned by "..pn) --meta:set_string("infotext", "Owned by "..pn)
end end
@ -115,7 +115,7 @@ function doors:register_door(name, def)
local tb = def.tiles_bottom local tb = def.tiles_bottom
local function after_dig_node(pos, name, digger) local function after_dig_node(pos, name, digger)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if node.name == name then if node.name == name then
minetest.node_dig(pos, node, digger) minetest.node_dig(pos, node, digger)
end end
@ -123,27 +123,27 @@ function doors:register_door(name, def)
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir pos.y = pos.y+dir
if not minetest.env:get_node(pos).name == check_name then if not minetest.get_node(pos).name == check_name then
return return
end end
local p2 = minetest.env:get_node(pos).param2 local p2 = minetest.get_node(pos).param2
p2 = params[p2+1] p2 = params[p2+1]
local meta = minetest.env:get_meta(pos):to_table() local meta = minetest.get_meta(pos):to_table()
minetest.env:set_node(pos, {name=replace_dir, param2=p2}) minetest.set_node(pos, {name=replace_dir, param2=p2})
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
pos.y = pos.y-dir pos.y = pos.y-dir
meta = minetest.env:get_meta(pos):to_table() meta = minetest.get_meta(pos):to_table()
minetest.env:set_node(pos, {name=replace, param2=p2}) minetest.set_node(pos, {name=replace, param2=p2})
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
end end
local function check_player_priv(pos, player) local function check_player_priv(pos, player)
if not def.only_placer_can_open then if not def.only_placer_can_open then
return true return true
end end
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local pn = player:get_player_name() local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn return meta:get_string("doors_owner") == pn
end end
@ -473,13 +473,13 @@ local meta
local state = 0 local state = 0
local function update_door(pos, node) local function update_door(pos, node)
minetest.env:set_node(pos, node) minetest.set_node(pos, node)
end end
local function punch(pos) local function punch(pos)
meta = minetest.env:get_meta(pos) meta = minetest.get_meta(pos)
state = meta:get_int("state") state = meta:get_int("state")
me = minetest.env:get_node(pos) me = minetest.get_node(pos)
local tmp_node local tmp_node
local tmp_node2 local tmp_node2
oben = {x=pos.x, y=pos.y+1, z=pos.z} oben = {x=pos.x, y=pos.y+1, z=pos.z}
@ -598,13 +598,13 @@ local meta
local state = 0 local state = 0
local function update_door(pos, node) local function update_door(pos, node)
minetest.env:set_node(pos, node) minetest.set_node(pos, node)
end end
local function punch(pos) local function punch(pos)
meta = minetest.env:get_meta(pos) meta = minetest.get_meta(pos)
state = meta:get_int("state") state = meta:get_int("state")
me = minetest.env:get_node(pos) me = minetest.get_node(pos)
local tmp_node local tmp_node
local tmp_node2 local tmp_node2
oben = {x=pos.x, y=pos.y+1, z=pos.z} oben = {x=pos.x, y=pos.y+1, z=pos.z}

View File

@ -8,14 +8,14 @@ function farming:add_plant(full_grown, names, interval, chance)
chance = chance, chance = chance,
action = function(pos, node) action = function(pos, node)
pos.y = pos.y-1 pos.y = pos.y-1
if minetest.env:get_node(pos).name ~= "farming:soil_wet" and math.random(0, 9) > 0 then if minetest.get_node(pos).name ~= "farming:soil_wet" and math.random(0, 9) > 0 then
return return
end end
pos.y = pos.y+1 pos.y = pos.y+1
if not minetest.env:get_node_light(pos) then if not minetest.get_node_light(pos) then
return return
end end
if minetest.env:get_node_light(pos) < 10 then if minetest.get_node_light(pos) < 10 then
return return
end end
local step = nil local step = nil
@ -32,7 +32,7 @@ function farming:add_plant(full_grown, names, interval, chance)
if new_node.name == nil then if new_node.name == nil then
new_node.name = full_grown new_node.name = full_grown
end end
minetest.env:set_node(pos, new_node) minetest.set_node(pos, new_node)
end end
} ) } )
end end
@ -48,13 +48,13 @@ function farming:place_seed(itemstack, placer, pointed_thing, plantname)
end end
local pos = {x=pt.above.x, y=pt.above.y-1, z=pt.above.z} local pos = {x=pt.above.x, y=pt.above.y-1, z=pt.above.z}
local farmland = minetest.env:get_node(pos) local farmland = minetest.get_node(pos)
pos= {x=pt.above.x, y=pt.above.y, z=pt.above.z} pos= {x=pt.above.x, y=pt.above.y, z=pt.above.z}
local place_s = minetest.env:get_node(pos) local place_s = minetest.get_node(pos)
if string.find(farmland.name, "farming:soil") and string.find(place_s.name, "air") then if string.find(farmland.name, "farming:soil") and string.find(place_s.name, "air") then
minetest.env:add_node(pos, {name=plantname}) minetest.add_node(pos, {name=plantname})
else else
return return
end end

View File

@ -18,19 +18,19 @@ minetest.register_node("farming:melon", {
local have_change = 0 local have_change = 0
for x=-1,1 do for x=-1,1 do
local p = {x=pos.x+x, y=pos.y, z=pos.z} local p = {x=pos.x+x, y=pos.y, z=pos.z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
if string.find(n.name, "melontige_linked_") and have_change == 0 then if string.find(n.name, "melontige_linked_") and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(p, {name="farming:melontige_unconnect"}) minetest.add_node(p, {name="farming:melontige_unconnect"})
end end
end end
if have_change == 0 then if have_change == 0 then
for z=-1,1 do for z=-1,1 do
p = {x=pos.x, y=pos.y, z=pos.z+z} p = {x=pos.x, y=pos.y, z=pos.z+z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
if string.find(n.name, "melontige_linked_") and have_change == 0 then if string.find(n.name, "melontige_linked_") and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(p, {name="farming:melontige_unconnect"}) minetest.add_node(p, {name="farming:melontige_unconnect"})
end end
end end
end end
@ -241,17 +241,17 @@ minetest.register_abm({
for x=-1,1 do for x=-1,1 do
local p = {x=pos.x+x, y=pos.y-1, z=pos.z} local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
newpos = {x=pos.x+x, y=pos.y, z=pos.z} newpos = {x=pos.x+x, y=pos.y, z=pos.z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
local nod = minetest.env:get_node(newpos) local nod = minetest.get_node(newpos)
if n.name=="default:dirt_with_grass" and nod.name=="air" and have_change == 0 if n.name=="default:dirt_with_grass" and nod.name=="air" and have_change == 0
or n.name=="default:dirt" and nod.name=="air" and have_change == 0 or n.name=="default:dirt" and nod.name=="air" and have_change == 0
or string.find(n.name, "farming:soil") and nod.name=="air" and have_change == 0 then or string.find(n.name, "farming:soil") and nod.name=="air" and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(newpos, {name="farming:melon"}) minetest.add_node(newpos, {name="farming:melon"})
if x == 1 then if x == 1 then
minetest.env:add_node(pos, {name="farming:melontige_linked_r" }) minetest.add_node(pos, {name="farming:melontige_linked_r" })
else else
minetest.env:add_node(pos, {name="farming:melontige_linked_l"}) minetest.add_node(pos, {name="farming:melontige_linked_l"})
end end
end end
end end
@ -259,17 +259,17 @@ minetest.register_abm({
for z=-1,1 do for z=-1,1 do
p = {x=pos.x, y=pos.y-1, z=pos.z+z} p = {x=pos.x, y=pos.y-1, z=pos.z+z}
newpos = {x=pos.x, y=pos.y, z=pos.z+z} newpos = {x=pos.x, y=pos.y, z=pos.z+z}
n = minetest.env:get_node(p) n = minetest.get_node(p)
local nod2 = minetest.env:get_node(newpos) local nod2 = minetest.get_node(newpos)
if n.name=="default:dirt_with_grass" and nod2.name=="air" and have_change == 0 if n.name=="default:dirt_with_grass" and nod2.name=="air" and have_change == 0
or n.name=="default:dirt" and nod2.name=="air" and have_change == 0 or n.name=="default:dirt" and nod2.name=="air" and have_change == 0
or string.find(n.name, "farming:soil") and nod2.name=="air" and have_change == 0 then or string.find(n.name, "farming:soil") and nod2.name=="air" and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(newpos, {name="farming:melon"}) minetest.add_node(newpos, {name="farming:melon"})
if z == 1 then if z == 1 then
minetest.env:add_node(pos, {name="farming:melontige_linked_t" }) minetest.add_node(pos, {name="farming:melontige_linked_t" })
else else
minetest.env:add_node(pos, {name="farming:melontige_linked_b" }) minetest.add_node(pos, {name="farming:melontige_linked_b" })
end end
end end
end end

View File

@ -5,10 +5,10 @@ minetest.register_craftitem("farming:pumpkin_seed", {
stack_max = 64, stack_max = 64,
inventory_image = "farming_pumpkin_seed.png", inventory_image = "farming_pumpkin_seed.png",
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above) local above = minetest.get_node(pointed_thing.above)
if above.name == "air" then if above.name == "air" then
above.name = "farming:pumpkin_1" above.name = "farming:pumpkin_1"
minetest.env:set_node(pointed_thing.above, above) minetest.set_node(pointed_thing.above, above)
itemstack:take_item(1) itemstack:take_item(1)
return itemstack return itemstack
end end
@ -60,19 +60,19 @@ minetest.register_node("farming:pumpkin_face", {
local have_change = 0 local have_change = 0
for x=-1,1 do for x=-1,1 do
local p = {x=pos.x+x, y=pos.y, z=pos.z} local p = {x=pos.x+x, y=pos.y, z=pos.z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
if string.find(n.name, "pumpkintige_linked_") and have_change == 0 then if string.find(n.name, "pumpkintige_linked_") and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(p, {name="farming:pumpkintige_unconnect"}) minetest.add_node(p, {name="farming:pumpkintige_unconnect"})
end end
end end
if have_change == 0 then if have_change == 0 then
for z=-1,1 do for z=-1,1 do
p = {x=pos.x, y=pos.y, z=pos.z+z} p = {x=pos.x, y=pos.y, z=pos.z+z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
if string.find(n.name, "pumpkintige_linked_") and have_change == 0 then if string.find(n.name, "pumpkintige_linked_") and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(p, {name="farming:pumpkintige_unconnect"}) minetest.add_node(p, {name="farming:pumpkintige_unconnect"})
end end
end end
end end
@ -232,17 +232,17 @@ minetest.register_abm({
for x=-1,1 do for x=-1,1 do
local p = {x=pos.x+x, y=pos.y-1, z=pos.z} local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
newpos = {x=pos.x+x, y=pos.y, z=pos.z} newpos = {x=pos.x+x, y=pos.y, z=pos.z}
local n = minetest.env:get_node(p) local n = minetest.get_node(p)
local nod = minetest.env:get_node(newpos) local nod = minetest.get_node(newpos)
if n.name=="default:dirt_with_grass" and nod.name=="air" and have_change == 0 if n.name=="default:dirt_with_grass" and nod.name=="air" and have_change == 0
or n.name=="default:dirt" and nod.name=="air" and have_change == 0 or n.name=="default:dirt" and nod.name=="air" and have_change == 0
or string.find(n.name, "farming:soil") and nod.name=="air" and have_change == 0 then or string.find(n.name, "farming:soil") and nod.name=="air" and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(newpos, {name="farming:pumpkin_face"}) minetest.add_node(newpos, {name="farming:pumpkin_face"})
if x == 1 then if x == 1 then
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_r" }) minetest.add_node(pos, {name="farming:pumpkintige_linked_r" })
else else
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_l"}) minetest.add_node(pos, {name="farming:pumpkintige_linked_l"})
end end
end end
end end
@ -250,17 +250,17 @@ minetest.register_abm({
for z=-1,1 do for z=-1,1 do
p = {x=pos.x, y=pos.y-1, z=pos.z+z} p = {x=pos.x, y=pos.y-1, z=pos.z+z}
newpos = {x=pos.x, y=pos.y, z=pos.z+z} newpos = {x=pos.x, y=pos.y, z=pos.z+z}
n = minetest.env:get_node(p) n = minetest.get_node(p)
local nod2 = minetest.env:get_node(newpos) local nod2 = minetest.get_node(newpos)
if n.name=="default:dirt_with_grass" and nod2.name=="air" and have_change == 0 if n.name=="default:dirt_with_grass" and nod2.name=="air" and have_change == 0
or n.name=="default:dirt" and nod2.name=="air" and have_change == 0 or n.name=="default:dirt" and nod2.name=="air" and have_change == 0
or string.find(n.name, "farming:soil") and nod2.name=="air" and have_change == 0 then or string.find(n.name, "farming:soil") and nod2.name=="air" and have_change == 0 then
have_change = 1 have_change = 1
minetest.env:add_node(newpos, {name="farming:pumpkin_face"}) minetest.add_node(newpos, {name="farming:pumpkin_face"})
if z == 1 then if z == 1 then
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_t" }) minetest.add_node(pos, {name="farming:pumpkintige_linked_t" })
else else
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_b" }) minetest.add_node(pos, {name="farming:pumpkintige_linked_b" })
end end
end end
end end

View File

@ -36,9 +36,9 @@ minetest.register_abm({
interval = 15, interval = 15,
chance = 3, chance = 3,
action = function(pos, node) action = function(pos, node)
if minetest.env:find_node_near(pos, 3, {"default:water_source", "default:water_flowing"}) then if minetest.find_node_near(pos, 3, {"default:water_source", "default:water_flowing"}) then
node.name = "farming:soil_wet" node.name = "farming:soil_wet"
minetest.env:set_node(pos, node) minetest.set_node(pos, node)
end end
end, end,
}) })

View File

@ -13,47 +13,47 @@ local function find_dock(pos, second)
return false return false
end end
local h1 = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) local h1 = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
local v1 = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) local v1 = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
local r1 = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) local r1 = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
local l1 = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) local l1 = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
local code = 0 local code = 0
if dockable(l1.name) then if dockable(l1.name) then
code = code+1 code = code+1
if second < 2 then if second < 2 then
minetest.env:punch_node({x=pos.x, y=pos.y, z=pos.z-1}) minetest.punch_node({x=pos.x, y=pos.y, z=pos.z-1})
end end
end end
if dockable(r1.name) then if dockable(r1.name) then
code = code+2 code = code+2
if second < 2 then if second < 2 then
minetest.env:punch_node({x=pos.x, y=pos.y, z=pos.z+1}) minetest.punch_node({x=pos.x, y=pos.y, z=pos.z+1})
end end
end end
if dockable(v1.name) then if dockable(v1.name) then
code = code+11 code = code+11
if second < 2 then if second < 2 then
minetest.env:punch_node({x=pos.x-1, y=pos.y, z=pos.z}) minetest.punch_node({x=pos.x-1, y=pos.y, z=pos.z})
end end
end end
if dockable(h1.name) then if dockable(h1.name) then
code = code+21 code = code+21
if second < 2 then if second < 2 then
minetest.env:punch_node({x=pos.x+1, y=pos.y, z=pos.z}) minetest.punch_node({x=pos.x+1, y=pos.y, z=pos.z})
end end
end end
local me = minetest.env:get_node(pos) local me = minetest.get_node(pos)
if code > 0 then if code > 0 then
local tmp_name = "fences:fence_wood_"..code local tmp_name = "fences:fence_wood_"..code
local tmp_node = {name=tmp_name, param1=me.param1, param2=me.param2} local tmp_node = {name=tmp_name, param1=me.param1, param2=me.param2}
if second > 0 then if second > 0 then
local tmp_node = {name=tmp_name, param1=me.param1, param2=me.param2} local tmp_node = {name=tmp_name, param1=me.param1, param2=me.param2}
minetest.env:set_node(pos, tmp_node) minetest.set_node(pos, tmp_node)
end end
elseif code == 0 then elseif code == 0 then
if second == 2 then if second == 2 then
local tmp_node = {name="fences:fence_wood", param1=me.param1, param2=me.param2} local tmp_node = {name="fences:fence_wood", param1=me.param1, param2=me.param2}
minetest.env:set_node(pos, tmp_node) minetest.set_node(pos, tmp_node)
end end
end end
@ -583,11 +583,11 @@ local meta2
local state2 = 0 local state2 = 0
local function update_gate(pos, node) local function update_gate(pos, node)
minetest.env:set_node(pos, node) minetest.set_node(pos, node)
end end
local function punch_gate(pos, node) local function punch_gate(pos, node)
meta2 = minetest.env:get_meta(pos) meta2 = minetest.get_meta(pos)
state2 = meta2:get_int("state") state2 = meta2:get_int("state")
local tmp_node2 local tmp_node2
if state2 == 1 then if state2 == 1 then
@ -684,8 +684,8 @@ minetest.register_node("fences:fencegate", {
} }
}, },
on_construct = function(pos) on_construct = function(pos)
me2 = minetest.env:get_node(pos) me2 = minetest.get_node(pos)
meta2 = minetest.env:get_meta(pos) meta2 = minetest.get_meta(pos)
meta2:set_int("state", 0) meta2:set_int("state", 0)
state2 = 0 state2 = 0
find_dock(pos, -1) find_dock(pos, -1)
@ -711,8 +711,8 @@ if override_original == true then
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local tmp_node3 = {name="fences:fence_wood"} local tmp_node3 = {name="fences:fence_wood"}
minetest.env:set_node(pos, tmp_node3) minetest.set_node(pos, tmp_node3)
minetest.env:punch_node(pos) minetest.punch_node(pos)
end end
}) })
end end

View File

@ -45,7 +45,7 @@ facedir[3] = {x=-1,y=0,z=0}
local flower_pot_remove_item = function(pos, node) local flower_pot_remove_item = function(pos, node)
local objs = nil local objs = nil
if node and node.name == "flowers:pot" then if node and node.name == "flowers:pot" then
objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, .5) objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, .5)
end end
if objs then if objs then
for _, obj in ipairs(objs) do for _, obj in ipairs(objs) do
@ -58,22 +58,22 @@ end
flower_pot_update_item = function(pos, node) flower_pot_update_item = function(pos, node)
flower_pot_remove_item(pos, node) flower_pot_remove_item(pos, node)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if meta and meta:get_string("item") ~= "" then if meta and meta:get_string("item") ~= "" then
if node.name == "flowers:pot" then if node.name == "flowers:pot" then
pos.y = pos.y pos.y = pos.y
end end
flower_tmp.nodename = node.name flower_tmp.nodename = node.name
flower_tmp.texture = ItemStack(meta:get_string("item")):get_name() flower_tmp.texture = ItemStack(meta:get_string("item")):get_name()
local e = minetest.env:add_entity(pos,"flowers:item") local e = minetest.add_entity(pos,"flowers:item")
end end
end end
flower_pot_drop_item = function(pos, node) flower_pot_drop_item = function(pos, node)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_string("item") ~= "" then if meta:get_string("item") ~= "" then
if node.name == "flowers:pot" then if node.name == "flowers:pot" then
minetest.env:add_item({x=pos.x,y=pos.y+1,z=pos.z}, meta:get_string("item")) minetest.add_item({x=pos.x,y=pos.y+1,z=pos.z}, meta:get_string("item"))
end end
meta:set_string("item","") meta:set_string("item","")
end end

View File

@ -299,12 +299,12 @@ minetest.register_node("flowers:pot",{
stack_max = 16, stack_max = 16,
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer, itemstack)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner",placer:get_player_name()) meta:set_string("owner",placer:get_player_name())
end, end,
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if not itemstack then return end if not itemstack then return end
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if clicker:get_player_name() == meta:get_string("owner") then if clicker:get_player_name() == meta:get_string("owner") then
flower_pot_drop_item(pos,node) flower_pot_drop_item(pos,node)
local s = itemstack:take_item() local s = itemstack:take_item()
@ -314,20 +314,20 @@ minetest.register_node("flowers:pot",{
return itemstack return itemstack
end, end,
on_punch = function(pos,node,puncher) on_punch = function(pos,node,puncher)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if puncher:get_player_name() == meta:get_string("owner") then if puncher:get_player_name() == meta:get_string("owner") then
flower_pot_drop_item(pos,node) flower_pot_drop_item(pos,node)
end end
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner") return player:get_player_name() == meta:get_string("owner")
end, end,
on_destruct = function(pos) on_destruct = function(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
flower_pot_drop_item(pos,node) flower_pot_drop_item(pos,node)
minetest.env:add_node(pos, {name="air"}) minetest.add_node(pos, {name="air"})
minetest.env:add_item(pos, "flowers:pot") minetest.add_item(pos, "flowers:pot")
end, end,
}) })

View File

@ -62,7 +62,7 @@ minetest.register_node("gemalde:node_"..n.."", {
print("[gemalde] number is "..number.."") print("[gemalde] number is "..number.."")
node.name = "gemalde:node_"..number.."" node.name = "gemalde:node_"..number..""
minetest.env:set_node(pos, node) minetest.set_node(pos, node)
end, end,
-- TODO. -- TODO.

View File

@ -7,7 +7,7 @@ minetest.register_globalstep(function(dtime)
local ctrl = player:get_player_control() local ctrl = player:get_player_control()
if ctrl.up or ctrl.left or ctrl.right then if ctrl.up or ctrl.left or ctrl.right then
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do for _,object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
local en = object:get_luaentity() local en = object:get_luaentity()
if not object:is_player() and en and en.name == "__builtin:item" then if not object:is_player() and en and en.name == "__builtin:item" then
if inv and if inv and
@ -46,7 +46,7 @@ function minetest.handle_node_drops(pos, drops, digger)
end end
if not inv or not inv:contains_item("main", ItemStack(name)) then if not inv or not inv:contains_item("main", ItemStack(name)) then
for i=1,count do for i=1,count do
local obj = minetest.env:add_item(pos, name) local obj = minetest.add_item(pos, name)
if obj ~= nil then if obj ~= nil then
obj:get_luaentity().collect = true obj:get_luaentity().collect = true
local x = math.random(1, 5) local x = math.random(1, 5)

View File

@ -44,7 +44,7 @@ facedir[3] = {x=-1,y=0,z=0}
local remove_item = function(pos, node) local remove_item = function(pos, node)
local objs = nil local objs = nil
if node.name == "itemframes:frame" then if node.name == "itemframes:frame" then
objs = minetest.env:get_objects_inside_radius(pos, .5) objs = minetest.get_objects_inside_radius(pos, .5)
end end
if objs then if objs then
for _, obj in ipairs(objs) do for _, obj in ipairs(objs) do
@ -57,7 +57,7 @@ end
local update_item = function(pos, node) local update_item = function(pos, node)
remove_item(pos, node) remove_item(pos, node)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_string("item") ~= "" then if meta:get_string("item") ~= "" then
if node.name == "itemframes:frame" then if node.name == "itemframes:frame" then
local posad = facedir[node.param2] local posad = facedir[node.param2]
@ -67,7 +67,7 @@ local update_item = function(pos, node)
end end
tmp.nodename = node.name tmp.nodename = node.name
tmp.texture = ItemStack(meta:get_string("item")):get_name() tmp.texture = ItemStack(meta:get_string("item")):get_name()
local e = minetest.env:add_entity(pos,"itemframes:item") local e = minetest.add_entity(pos,"itemframes:item")
if node.name == "itemframes:frame" then if node.name == "itemframes:frame" then
local yaw = math.pi*2 - node.param2 * math.pi/2 local yaw = math.pi*2 - node.param2 * math.pi/2
e:setyaw(yaw) e:setyaw(yaw)
@ -76,10 +76,10 @@ local update_item = function(pos, node)
end end
local drop_item = function(pos, node) local drop_item = function(pos, node)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_string("item") ~= "" then if meta:get_string("item") ~= "" then
if node.name == "itemframes:frame" then if node.name == "itemframes:frame" then
minetest.env:add_item(pos, meta:get_string("item")) minetest.add_item(pos, meta:get_string("item"))
end end
meta:set_string("item","") meta:set_string("item","")
end end
@ -103,13 +103,13 @@ minetest.register_node("itemframes:frame",{
legacy_wallmounted = true, legacy_wallmounted = true,
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer, itemstack)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner",placer:get_player_name()) meta:set_string("owner",placer:get_player_name())
meta:set_string("infotext","Item frame (owned by "..placer:get_player_name()..")") meta:set_string("infotext","Item frame (owned by "..placer:get_player_name()..")")
end, end,
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if not itemstack then return end if not itemstack then return end
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if clicker:get_player_name() == meta:get_string("owner") then if clicker:get_player_name() == meta:get_string("owner") then
drop_item(pos,node) drop_item(pos,node)
local s = itemstack:take_item() local s = itemstack:take_item()
@ -119,14 +119,14 @@ minetest.register_node("itemframes:frame",{
return itemstack return itemstack
end, end,
on_punch = function(pos,node,puncher) on_punch = function(pos,node,puncher)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if puncher:get_player_name() == meta:get_string("owner") then if puncher:get_player_name() == meta:get_string("owner") then
drop_item(pos, node) drop_item(pos, node)
end end
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner") return player:get_player_name() == meta:get_string("owner")
end, end,
}) })

View File

@ -7,7 +7,7 @@
local z = math.random(0, 9)/3 local z = math.random(0, 9)/3
pos.x = pos.x + x pos.x = pos.x + x
pos.z = pos.z + z pos.z = pos.z + z
minetest.env:add_item(pos, stack) minetest.add_item(pos, stack)
stack:clear() stack:clear()
inv:set_stack("main", i, stack) inv:set_stack("main", i, stack)
pos.x = pos.x - x pos.x = pos.x - x

View File

@ -613,9 +613,9 @@ function mobs:register_mob(name, def)
pos.y = math.floor(pos.y+0.5) pos.y = math.floor(pos.y+0.5)
pos.z = math.floor(pos.z+0.5) pos.z = math.floor(pos.z+0.5)
do_tnt_physics(pos, 3) do_tnt_physics(pos, 3)
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,}) 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.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.is_protected(pos, "tnt") then
self.object:remove() self.object:remove()
return return
end end
@ -624,17 +624,17 @@ function mobs:register_mob(name, def)
for z=-3,3 do for z=-3,3 do
if x*x+y*y+z*z <= 3 * 3 + 3 then if x*x+y*y+z*z <= 3 * 3 + 3 then
local np={x=pos.x+x,y=pos.y+y,z=pos.z+z} 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 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) activate_if_tnt(n.name, np, pos, 3)
minetest.env:remove_node(np) minetest.remove_node(np)
nodeupdate(np) nodeupdate(np)
if n.name ~= "tnt:tnt" and math.random() > 0.9 then if n.name ~= "tnt:tnt" and math.random() > 0.9 then
local drop = minetest.get_node_drops(n.name, "") local drop = minetest.get_node_drops(n.name, "")
for _,item in ipairs(drop) do for _,item in ipairs(drop) do
if type(item) == "string" then if type(item) == "string" then
if math.random(1,100) > 40 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 end
end end
@ -970,7 +970,7 @@ function mobs:register_spawn(name, description, nodes, max_light, min_light, cha
end end
function do_tnt_physics(tnt_np,tntr) 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 for k, obj in pairs(objs) do
local oname = obj:get_entity_name() local oname = obj:get_entity_name()
local v = obj:getvelocity() local v = obj:getvelocity()

View File

@ -98,7 +98,7 @@ function mesecon:receptor_off(pos, rules)
if not mesecon:connected_to_receptor(np) then if not mesecon:connected_to_receptor(np) then
mesecon:turnoff(np, rulename) mesecon:turnoff(np, rulename)
else else
mesecon:changesignal(np, minetest.env:get_node(np), rulename, mesecon.state.off) mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off)
end end
end end
end end

View File

@ -268,7 +268,7 @@ end
-- some more general high-level stuff -- some more general high-level stuff
function mesecon:is_power_on(pos) function mesecon:is_power_on(pos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_on(node.name) or mesecon:is_receptor_on(node.name) then if mesecon:is_conductor_on(node.name) or mesecon:is_receptor_on(node.name) then
return true return true
end end
@ -276,7 +276,7 @@ function mesecon:is_power_on(pos)
end end
function mesecon:is_power_off(pos) function mesecon:is_power_off(pos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_off(node.name) or mesecon:is_receptor_off(node.name) then if mesecon:is_conductor_off(node.name) or mesecon:is_receptor_off(node.name) then
return true return true
end end
@ -284,11 +284,11 @@ function mesecon:is_power_off(pos)
end end
function mesecon:turnon(pos, rulename) function mesecon:turnon(pos, rulename)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_off(node.name) then if mesecon:is_conductor_off(node.name) then
local rules = mesecon:conductor_get_rules(node) local rules = mesecon:conductor_get_rules(node)
minetest.env:add_node(pos, {name = mesecon:get_conductor_on(node.name), param2 = node.param2}) minetest.add_node(pos, {name = mesecon:get_conductor_on(node.name), param2 = node.param2})
for _, rule in ipairs(rules) do for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule) local np = mesecon:addPosRule(pos, rule)
@ -307,11 +307,11 @@ function mesecon:turnon(pos, rulename)
end end
function mesecon:turnoff(pos, rulename) function mesecon:turnoff(pos, rulename)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_on(node.name) then if mesecon:is_conductor_on(node.name) then
local rules = mesecon:conductor_get_rules(node) local rules = mesecon:conductor_get_rules(node)
minetest.env:add_node(pos, {name = mesecon:get_conductor_off(node.name), param2 = node.param2}) minetest.add_node(pos, {name = mesecon:get_conductor_off(node.name), param2 = node.param2})
for _, rule in ipairs(rules) do for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule) local np = mesecon:addPosRule(pos, rule)
@ -332,7 +332,7 @@ end
function mesecon:connected_to_receptor(pos) function mesecon:connected_to_receptor(pos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
-- Check if conductors around are connected -- Check if conductors around are connected
local rules = mesecon:get_any_inputrules(node) local rules = mesecon:get_any_inputrules(node)
@ -360,7 +360,7 @@ function mesecon:find_receptor_on(pos, checked)
-- add current position to checked -- add current position to checked
table.insert(checked, {x=pos.x, y=pos.y, z=pos.z}) table.insert(checked, {x=pos.x, y=pos.y, z=pos.z})
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_receptor_on(node.name) then if mesecon:is_receptor_on(node.name) then
return true return true
@ -382,8 +382,8 @@ function mesecon:find_receptor_on(pos, checked)
end end
function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
local outputnode = minetest.env:get_node(output) local outputnode = minetest.get_node(output)
local inputnode = minetest.env:get_node(input) local inputnode = minetest.get_node(input)
local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode) local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode)
local inputrules = mesecon:get_any_inputrules (inputnode) local inputrules = mesecon:get_any_inputrules (inputnode)
if not outputrules or not inputrules then if not outputrules or not inputrules then
@ -409,13 +409,13 @@ function mesecon:rules_link_anydir(pos1, pos2)
end end
function mesecon:is_powered(pos) function mesecon:is_powered(pos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local rules = mesecon:get_any_inputrules(node) local rules = mesecon:get_any_inputrules(node)
if not rules then return false end if not rules then return false end
for _, rule in ipairs(rules) do for _, rule in ipairs(rules) do
local np = mesecon:addPosRule(pos, rule) local np = mesecon:addPosRule(pos, rule)
local nn = minetest.env:get_node(np) local nn = minetest.get_node(np)
if (mesecon:is_conductor_on (nn.name) or mesecon:is_receptor_on (nn.name)) if (mesecon:is_conductor_on (nn.name) or mesecon:is_receptor_on (nn.name))
and mesecon:rules_link(np, pos) then and mesecon:rules_link(np, pos) then

View File

@ -1,17 +1,17 @@
function mesecon:swap_node(pos, name) function mesecon:swap_node(pos, name)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local data = minetest.env:get_meta(pos):to_table() local data = minetest.get_meta(pos):to_table()
node.name = name node.name = name
minetest.env:add_node(pos, node) minetest.add_node(pos, node)
minetest.env:get_meta(pos):from_table(data) minetest.get_meta(pos):from_table(data)
end end
function mesecon:move_node(pos, newpos) function mesecon:move_node(pos, newpos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.env:get_meta(pos):to_table() local meta = minetest.get_meta(pos):to_table()
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.env:add_node(newpos, node) minetest.add_node(newpos, node)
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
end end

View File

@ -209,7 +209,7 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
mesecon:update_autoconnect(zmympos, true) mesecon:update_autoconnect(zmympos, true)
end end
nodename = minetest.env:get_node(pos).name nodename = minetest.get_node(pos).name
if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end
if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end
@ -237,9 +237,9 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
if string.find(nodename, "_off") ~= nil then if string.find(nodename, "_off") ~= nil then
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"}) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
else else
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" }) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
end end
end end

View File

@ -3,7 +3,7 @@
-- and then turns off again -- and then turns off again
mesecon.button_turnoff = function (pos) mesecon.button_turnoff = function (pos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if node.name=="mesecons_button:button_stone_on" then --has not been dug if node.name=="mesecons_button:button_stone_on" then --has not been dug
mesecon:swap_node(pos, "mesecons_button:button_stone_off") mesecon:swap_node(pos, "mesecons_button:button_stone_off")
minetest.sound_play("mesecons_button_pop", {pos=pos}) minetest.sound_play("mesecons_button_pop", {pos=pos})

View File

@ -38,27 +38,27 @@ function doors:register_door(name, def)
local tb = def.tiles_bottom local tb = def.tiles_bottom
local function after_dig_node(pos, name) local function after_dig_node(pos, name)
if minetest.env:get_node(pos).name == name then if minetest.get_node(pos).name == name then
minetest.env:remove_node(pos) minetest.remove_node(pos)
end end
end end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir pos.y = pos.y+dir
if not minetest.env:get_node(pos).name == check_name then if not minetest.get_node(pos).name == check_name then
return return
end end
local p2 = minetest.env:get_node(pos).param2 local p2 = minetest.get_node(pos).param2
p2 = params[p2+1] p2 = params[p2+1]
local meta = minetest.env:get_meta(pos):to_table() local meta = minetest.get_meta(pos):to_table()
minetest.env:set_node(pos, {name=replace_dir, param2=p2}) minetest.set_node(pos, {name=replace_dir, param2=p2})
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
pos.y = pos.y-dir pos.y = pos.y-dir
meta = minetest.env:get_meta(pos):to_table() meta = minetest.get_meta(pos):to_table()
minetest.env:set_node(pos, {name=replace, param2=p2}) minetest.set_node(pos, {name=replace, param2=p2})
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
end end
local function on_mesecons_signal_open (pos, node) local function on_mesecons_signal_open (pos, node)
@ -73,7 +73,7 @@ function doors:register_door(name, def)
if not def.only_placer_can_open then if not def.only_placer_can_open then
return true return true
end end
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local pn = player:get_player_name() local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn return meta:get_string("doors_owner") == pn
end end

View File

@ -21,7 +21,7 @@ function mesecon:mvps_process_stack(stack)
-- update mesecons for placed nodes ( has to be done after all nodes have been added ) -- update mesecons for placed nodes ( has to be done after all nodes have been added )
for _, n in ipairs(stack) do for _, n in ipairs(stack) do
nodeupdate(n.pos) nodeupdate(n.pos)
mesecon.on_placenode(n.pos, minetest.env:get_node(n.pos)) mesecon.on_placenode(n.pos, minetest.get_node(n.pos))
mesecon:update_autoconnect(n.pos) mesecon:update_autoconnect(n.pos)
end end
end end
@ -32,7 +32,7 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- determine the number of nodes to be pushed -- determine the number of nodes to be pushed
local nodes = {} local nodes = {}
while true do while true do
nn = minetest.env:get_node_or_nil(np) nn = minetest.get_node_or_nil(np)
if not nn or #nodes > maximum then if not nn or #nodes > maximum then
-- don't push at all, something is in the way (unloaded map or too many nodes) -- don't push at all, something is in the way (unloaded map or too many nodes)
return return
@ -57,8 +57,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- remove all nodes -- remove all nodes
for _, n in ipairs(nodes) do for _, n in ipairs(nodes) do
n.meta = minetest.env:get_meta(n.pos):to_table() n.meta = minetest.get_meta(n.pos):to_table()
minetest.env:remove_node(n.pos) minetest.remove_node(n.pos)
end end
-- update mesecons for removed nodes ( has to be done after all nodes have been removed ) -- update mesecons for removed nodes ( has to be done after all nodes have been removed )
@ -70,8 +70,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- add nodes -- add nodes
for _, n in ipairs(nodes) do for _, n in ipairs(nodes) do
np = mesecon:addPosRule(n.pos, dir) np = mesecon:addPosRule(n.pos, dir)
minetest.env:add_node(np, n.node) minetest.add_node(np, n.node)
minetest.env:get_meta(np):from_table(n.meta) minetest.get_meta(np):from_table(n.meta)
end end
for i in ipairs(nodes) do for i in ipairs(nodes) do
@ -83,14 +83,14 @@ end
function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons) function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons)
np = mesecon:addPosRule(pos, dir) np = mesecon:addPosRule(pos, dir)
nn = minetest.env:get_node(np) nn = minetest.get_node(np)
if minetest.registered_nodes[nn.name].liquidtype == "none" if minetest.registered_nodes[nn.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then
local meta = minetest.env:get_meta(np):to_table() local meta = minetest.get_meta(np):to_table()
minetest.env:remove_node(np) minetest.remove_node(np)
minetest.env:add_node(pos, nn) minetest.add_node(pos, nn)
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
nodeupdate(np) nodeupdate(np)
nodeupdate(pos) nodeupdate(pos)
@ -102,25 +102,25 @@ end
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
local lnode = minetest.env:get_node(lpos) local lnode = minetest.get_node(lpos)
local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
local lnode2 = minetest.env:get_node(lpos2) local lnode2 = minetest.get_node(lpos2)
if lnode.name ~= "ignore" and lnode.name ~= "air" and minetest.registered_nodes[lnode.name].liquidtype == "none" then return end if lnode.name ~= "ignore" and lnode.name ~= "air" and minetest.registered_nodes[lnode.name].liquidtype == "none" then return end
if lnode2.name == "ignore" or lnode2.name == "air" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") then return end if lnode2.name == "ignore" or lnode2.name == "air" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") then return end
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z} local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
repeat repeat
lnode2 = minetest.env:get_node(lpos2) lnode2 = minetest.get_node(lpos2)
minetest.env:add_node(oldpos, {name=lnode2.name}) minetest.add_node(oldpos, {name=lnode2.name})
nodeupdate(oldpos) nodeupdate(oldpos)
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z} oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
lpos2.x = lpos2.x-direction.x lpos2.x = lpos2.x-direction.x
lpos2.y = lpos2.y-direction.y lpos2.y = lpos2.y-direction.y
lpos2.z = lpos2.z-direction.z lpos2.z = lpos2.z-direction.z
lnode = minetest.env:get_node(lpos2) lnode = minetest.get_node(lpos2)
until lnode.name=="air" or lnode.name=="ignore" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") until lnode.name=="air" or lnode.name=="ignore" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none")
minetest.env:remove_node(oldpos) minetest.remove_node(oldpos)
end end
mesecon:register_mvps_stopper("default:chest") mesecon:register_mvps_stopper("default:chest")

View File

@ -7,12 +7,12 @@ minetest.register_node("mesecons_noteblock:noteblock", {
paramtype="light", paramtype="light",
is_ground_content = false, is_ground_content = false,
after_place_node = function(pos) after_place_node = function(pos)
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0}) minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
end, end,
on_punch = function (pos, node) -- change sound when punched on_punch = function (pos, node) -- change sound when punched
local param2 = node.param2+1 local param2 = node.param2+1
if param2==12 then param2=0 end if param2==12 then param2=0 end
minetest.env:add_node(pos, {name = node.name, param2 = param2}) minetest.add_node(pos, {name = node.name, param2 = param2})
mesecon.noteblock_play(pos, param2) mesecon.noteblock_play(pos, param2)
end, end,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
@ -65,7 +65,7 @@ mesecon.noteblock_play = function (pos, param2)
elseif param2==7 then elseif param2==7 then
soundname="mesecons_noteblock_gsharp" soundname="mesecons_noteblock_gsharp"
end end
local block_below_name = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
if block_below_name == "default:glass" then if block_below_name == "default:glass" then
soundname="mesecons_noteblock_hihat" soundname="mesecons_noteblock_hihat"
end end

View File

@ -59,10 +59,10 @@ local piston_remove_pusher = function (pos, node)
dir = piston_get_direction(pistonspec.dir, node) dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = mesecon:addPosRule(pos, dir) local pusherpos = mesecon:addPosRule(pos, dir)
local pushername = minetest.env:get_node(pusherpos).name local pushername = minetest.get_node(pusherpos).name
if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly) if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly)
minetest.env:remove_node(pusherpos) minetest.remove_node(pusherpos)
nodeupdate(pusherpos) nodeupdate(pusherpos)
end end
end end
@ -74,15 +74,15 @@ local piston_on = function (pos, node)
local np = mesecon:addPosRule(pos, dir) local np = mesecon:addPosRule(pos, dir)
success, stack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH) success, stack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
if success then if success then
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.onname}) minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname})
minetest.env:add_node(np, {param2 = node.param2, name = pistonspec.pusher}) minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher})
mesecon:mvps_process_stack(stack) mesecon:mvps_process_stack(stack)
end end
end end
local piston_off = function (pos, node) local piston_off = function (pos, node)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.offname}) minetest.add_node(pos, {param2 = node.param2, name = pistonspec.offname})
piston_remove_pusher (pos, node) piston_remove_pusher (pos, node)
if pistonspec.sticky then if pistonspec.sticky then
@ -100,12 +100,12 @@ local piston_orientate = function (pos, placer)
-- placer pitch in degrees -- placer pitch in degrees
local pitch = placer:get_look_pitch() * (180 / math.pi) local pitch = placer:get_look_pitch() * (180 / math.pi)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
if pitch > 55 then --looking upwards if pitch > 55 then --looking upwards
minetest.env:add_node(pos, {name=pistonspec.piston_down}) minetest.add_node(pos, {name=pistonspec.piston_down})
elseif pitch < -55 then --looking downwards elseif pitch < -55 then --looking downwards
minetest.env:add_node(pos, {name=pistonspec.piston_up}) minetest.add_node(pos, {name=pistonspec.piston_up})
end end
end end
@ -723,7 +723,7 @@ local piston_get_stopper = function (node, dir, stack, stackid)
pistonspec = minetest.registered_nodes[node.name].mesecons_piston pistonspec = minetest.registered_nodes[node.name].mesecons_piston
dir = piston_get_direction(pistonspec.dir, node) dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir) local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir)
local pushernode = minetest.env:get_node(pusherpos) local pushernode = minetest.get_node(pusherpos)
if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then
for _, s in ipairs(stack) do for _, s in ipairs(stack) do

View File

@ -9,18 +9,18 @@ local pp_box_on = {
} }
pp_on_timer = function (pos, elapsed) pp_on_timer = function (pos, elapsed)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local ppspec = minetest.registered_nodes[node.name].pressureplate local ppspec = minetest.registered_nodes[node.name].pressureplate
-- This is a workaround for a strange bug that occurs when the server is started -- This is a workaround for a strange bug that occurs when the server is started
-- For some reason the first time on_timer is called, the pos is wrong -- For some reason the first time on_timer is called, the pos is wrong
if not ppspec then return end if not ppspec then return end
local objs = minetest.env:get_objects_inside_radius(pos, 1) local objs = minetest.get_objects_inside_radius(pos, 1)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}) local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
if objs[1] == nil and node.name == ppspec.onstate then if objs[1] == nil and node.name == ppspec.onstate then
minetest.env:add_node(pos, {name = ppspec.offstate}) minetest.add_node(pos, {name = ppspec.offstate})
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
-- force deactivation of mesecon two blocks below (hacky) -- force deactivation of mesecon two blocks below (hacky)
if not mesecon:connected_to_receptor(two_below) then if not mesecon:connected_to_receptor(two_below) then
@ -30,7 +30,7 @@ pp_on_timer = function (pos, elapsed)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
local objpos = obj:getpos() local objpos = obj:getpos()
if objpos.y > pos.y-1 and objpos.y < pos.y then if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.env:add_node(pos, {name=ppspec.onstate}) minetest.add_node(pos, {name=ppspec.onstate})
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
-- force activation of mesecon two blocks below (hacky) -- force activation of mesecon two blocks below (hacky)
mesecon:turnon(two_below) mesecon:turnon(two_below)
@ -71,7 +71,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
state = mesecon.state.off state = mesecon.state.off
}}, }},
on_construct = function(pos) on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end, end,
}) })
@ -91,7 +91,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
state = mesecon.state.on state = mesecon.state.on
}}, }},
on_construct = function(pos) on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end, end,
after_dig_node = function(pos) after_dig_node = function(pos)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}) local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})

View File

@ -64,10 +64,10 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light >= 12 and minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.8 then if light >= 12 and minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.8 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end end
end, end,
@ -78,10 +78,10 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light < 12 then if light < 12 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end end
end, end,
@ -155,10 +155,10 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light < 12 then if light < 12 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_on", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_on", param2=node.param2})
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end end
end, end,
@ -169,10 +169,10 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light >= 12 and minetest.get_timeofday() > 0.8 and minetest.get_timeofday() < 0.2 then if light >= 12 and minetest.get_timeofday() > 0.8 and minetest.get_timeofday() < 0.2 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_off", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_off", param2=node.param2})
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end end
end, end,

View File

@ -35,13 +35,13 @@ local signs_yard = {
local sign_groups = {choppy=2, dig_immediate=2} local sign_groups = {choppy=2, dig_immediate=2}
local construct_sign = function(pos) local construct_sign = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[text;;${text}]") meta:set_string("formspec", "field[text;;${text}]")
meta:set_string("infotext", "") meta:set_string("infotext", "")
end end
local destruct_sign = function(pos) local destruct_sign = function(pos)
local objects = minetest.env:get_objects_inside_radius(pos, 0.5) local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do for _, v in ipairs(objects) do
if v:get_entity_name() == "signs:text" then if v:get_entity_name() == "signs:text" then
v:remove() v:remove()
@ -50,7 +50,7 @@ local destruct_sign = function(pos)
end end
local update_sign = function(pos, fields, sender) local update_sign = function(pos, fields, sender)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner") local owner = meta:get_string("owner")
meta:set_string("infotext", "") meta:set_string("infotext", "")
local text = meta:get_string("text") local text = meta:get_string("text")
@ -59,7 +59,7 @@ local update_sign = function(pos, fields, sender)
meta:set_string("owner", sender:get_player_name() or "") meta:set_string("owner", sender:get_player_name() or "")
end end
text = meta:get_string("text") text = meta:get_string("text")
local objects = minetest.env:get_objects_inside_radius(pos, 0.5) local objects = minetest.get_objects_inside_radius(pos, 0.5)
for _, v in ipairs(objects) do for _, v in ipairs(objects) do
if v:get_entity_name() == "signs:text" then if v:get_entity_name() == "signs:text" then
v:set_properties({textures={generate_texture(create_lines(text))}}) v:set_properties({textures={generate_texture(create_lines(text))}})
@ -69,15 +69,15 @@ local update_sign = function(pos, fields, sender)
-- if there is no entity -- if there is no entity
local sign_info local sign_info
if minetest.env:get_node(pos).name == "signs:sign_yard" then if minetest.get_node(pos).name == "signs:sign_yard" then
sign_info = signs_yard[minetest.env:get_node(pos).param2 + 1] sign_info = signs_yard[minetest.get_node(pos).param2 + 1]
elseif minetest.env:get_node(pos).name == "signs:sign_wall" then elseif minetest.get_node(pos).name == "signs:sign_wall" then
sign_info = signs[minetest.env:get_node(pos).param2 + 1] sign_info = signs[minetest.get_node(pos).param2 + 1]
end end
if sign_info == nil then if sign_info == nil then
return return
end end
local text = minetest.env:add_entity({x = pos.x + sign_info.delta.x, local text = minetest.add_entity({x = pos.x + sign_info.delta.x,
y = pos.y + sign_info.delta.y, y = pos.y + sign_info.delta.y,
z = pos.z + sign_info.delta.z}, "signs:text") z = pos.z + sign_info.delta.z}, "signs:text")
text:setyaw(sign_info.yaw) text:setyaw(sign_info.yaw)
@ -122,18 +122,18 @@ minetest.register_node("signs:sign_wall", {
local sign_info local sign_info
if wdir == 0 then if wdir == 0 then
--how would you add sign to ceiling? --how would you add sign to ceiling?
minetest.env:add_item(above, "signs:sign_wall") minetest.add_item(above, "signs:sign_wall")
itemstack:take_item() itemstack:take_item()
return itemstack return itemstack
elseif wdir == 1 then elseif wdir == 1 then
minetest.env:add_node(above, {name = "signs:sign_yard", param2 = fdir}) minetest.add_node(above, {name = "signs:sign_yard", param2 = fdir})
sign_info = signs_yard[fdir + 1] sign_info = signs_yard[fdir + 1]
else else
minetest.env:add_node(above, {name = "signs:sign_wall", param2 = fdir}) minetest.add_node(above, {name = "signs:sign_wall", param2 = fdir})
sign_info = signs[fdir + 1] sign_info = signs[fdir + 1]
end end
local text = minetest.env:add_entity({x = above.x + sign_info.delta.x, local text = minetest.add_entity({x = above.x + sign_info.delta.x,
y = above.y + sign_info.delta.y, y = above.y + sign_info.delta.y,
z = above.z + sign_info.delta.z}, "signs:text") z = above.z + sign_info.delta.z}, "signs:text")
text:setyaw(sign_info.yaw) text:setyaw(sign_info.yaw)
@ -191,7 +191,7 @@ minetest.register_entity("signs:text", {
textures = {}, textures = {},
on_activate = function(self) on_activate = function(self)
local meta = minetest.env:get_meta(self.object:getpos()) local meta = minetest.get_meta(self.object:getpos())
local text = meta:get_string("text") local text = meta:get_string("text")
self.object:set_properties({textures={generate_texture(create_lines(text))}}) self.object:set_properties({textures={generate_texture(create_lines(text))}})
end end

View File

@ -44,10 +44,10 @@ local THROWING_ARROW_ENTITY={
THROWING_ARROW_ENTITY.on_step = function(self, dtime) THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime self.timer=self.timer+dtime
local pos = self.object:getpos() local pos = self.object:getpos()
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if self.timer>0.2 then if self.timer>0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2) local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then if obj:get_luaentity().name ~= "throwing:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
@ -71,7 +71,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if self.lastpos.x~=nil then if self.lastpos.x~=nil then
if node.name ~= "air" then if node.name ~= "air" then
minetest.env:add_item(self.lastpos, 'throwing:arrow') minetest.add_item(self.lastpos, 'throwing:arrow')
self.object:remove() self.object:remove()
end end
end end

View File

@ -10,7 +10,7 @@ local throwing_shoot_arrow = function(itemstack, player)
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
player:get_inventory():remove_item("main", arrow[1]) player:get_inventory():remove_item("main", arrow[1])
local playerpos = player:getpos() local playerpos = player:getpos()
local obj = minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2]) local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2])
local dir = player:get_look_dir() local dir = player:get_look_dir()
obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19}) obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19})
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})

View File

@ -1,6 +1,6 @@
function spawn_tnt(pos, entname) function spawn_tnt(pos, entname)
minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,}) 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 end
function activate_if_tnt(nname, np, tnt_np, tntr) function activate_if_tnt(nname, np, tnt_np, tntr)
@ -11,7 +11,7 @@ function activate_if_tnt(nname, np, tnt_np, tntr)
end end
function do_tnt_physics(tnt_np,tntr) 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 for k, obj in pairs(objs) do
local oname = obj:get_entity_name() local oname = obj:get_entity_name()
local v = obj:getvelocity() local v = obj:getvelocity()
@ -43,7 +43,7 @@ minetest.register_node("tnt:tnt", {
description = "TNT", description = "TNT",
mesecons = {effector = { mesecons = {effector = {
action_on = (function(p, node) action_on = (function(p, node)
minetest.env:remove_node(p) minetest.remove_node(p)
spawn_tnt(p, "tnt:tnt") spawn_tnt(p, "tnt:tnt")
nodeupdate(p) nodeupdate(p)
end), end),
@ -53,7 +53,7 @@ minetest.register_node("tnt:tnt", {
minetest.register_on_punchnode(function(p, node) minetest.register_on_punchnode(function(p, node)
if node.name == "tnt:tnt" then if node.name == "tnt:tnt" then
minetest.env:remove_node(p) minetest.remove_node(p)
spawn_tnt(p, "tnt:tnt") spawn_tnt(p, "tnt:tnt")
nodeupdate(p) nodeupdate(p)
end end
@ -102,9 +102,9 @@ function TNT:on_step(dtime)
pos.y = math.floor(pos.y+0.5) pos.y = math.floor(pos.y+0.5)
pos.z = math.floor(pos.z+0.5) pos.z = math.floor(pos.z+0.5)
do_tnt_physics(pos, TNT_RANGE) 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,}) 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 -- Cancel the Explosion
self.object:remove() self.object:remove()
return return
@ -114,17 +114,17 @@ function TNT:on_step(dtime)
for z=-TNT_RANGE,TNT_RANGE do for z=-TNT_RANGE,TNT_RANGE do
if x*x+y*y+z*z <= TNT_RANGE * TNT_RANGE + TNT_RANGE then 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 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 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) activate_if_tnt(n.name, np, pos, 3)
minetest.env:remove_node(np) minetest.remove_node(np)
nodeupdate(np) nodeupdate(np)
if n.name ~= "tnt:tnt" and math.random() > 0.9 then if n.name ~= "tnt:tnt" and math.random() > 0.9 then
local drop = minetest.get_node_drops(n.name, "") local drop = minetest.get_node_drops(n.name, "")
for _,item in ipairs(drop) do for _,item in ipairs(drop) do
if type(item) == "string" then if type(item) == "string" then
if math.random(1,100) > 40 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 end
end end

View File

@ -11,7 +11,7 @@ local directions = {
} }
local function update_wall(pos) local function update_wall(pos)
local thisnode = minetest.env:get_node(pos) local thisnode = minetest.get_node(pos)
if thisnode.name:find("wallet:wall") ~= 1 and if thisnode.name:find("wallet:wall") ~= 1 and
thisnode.name:find("wallet:wallmossy") ~= 1 then thisnode.name:find("wallet:wallmossy") ~= 1 then
@ -32,14 +32,14 @@ local function update_wall(pos)
-- Neighbouring walkable nodes -- Neighbouring walkable nodes
for i = 1, 4 do for i = 1, 4 do
local dir = directions[i] local dir = directions[i]
local node = minetest.env:get_node({x = pos.x + dir.x, y = pos.y + dir.y, z = pos.z + dir.z}) local node = minetest.get_node({x = pos.x + dir.x, y = pos.y + dir.y, z = pos.z + dir.z})
if minetest.registered_nodes[node.name].walkable then if minetest.registered_nodes[node.name].walkable then
sum = sum + 2 ^ (i - 1) sum = sum + 2 ^ (i - 1)
end end
end end
-- Torches or walkable nodes above the wall -- Torches or walkable nodes above the wall
local upnode = minetest.env:get_node({x = pos.x, y = pos.y+1, z = pos.z}) local upnode = minetest.get_node({x = pos.x, y = pos.y+1, z = pos.z})
if sum == 5 or sum == 10 then if sum == 5 or sum == 10 then
if minetest.registered_nodes[upnode.name].walkable or upnode.name == "torches:floor" then if minetest.registered_nodes[upnode.name].walkable or upnode.name == "torches:floor" then
sum = sum + 11 sum = sum + 11
@ -50,7 +50,7 @@ local function update_wall(pos)
sum = 15 sum = 15
end]] end]]
minetest.env:add_node(pos, {name = basename..sum}) minetest.add_node(pos, {name = basename..sum})
end end
function update_wall_global(pos) function update_wall_global(pos)