Replace the horribly outdated minetest.env stuff
This commit is contained in:
parent
c13823bcfc
commit
bc0879911f
|
@ -5,13 +5,13 @@ local old_yaw = 0
|
|||
|
||||
local function get_dir(pos)
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
|
@ -28,15 +28,15 @@ function plock(start, max, tick, player, yaw)
|
|||
end
|
||||
|
||||
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 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}
|
||||
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}
|
||||
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}
|
||||
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}
|
||||
else
|
||||
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)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local param2 = node.param2
|
||||
local npos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
if param2 == 0 then
|
||||
|
@ -79,17 +79,17 @@ minetest.register_node("beds:bed_bottom", {
|
|||
elseif param2 == 3 then
|
||||
npos.x = npos.x-1
|
||||
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
|
||||
minetest.env:set_node(npos, {name="beds:bed_top", param2 = param2})
|
||||
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.set_node(npos, {name="beds:bed_top", param2 = param2})
|
||||
else
|
||||
minetest.env:dig_node(pos)
|
||||
minetest.dig_node(pos)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
pos = minetest.env:find_node_near(pos, 1, "beds:bed_top")
|
||||
if pos ~= nil then minetest.env:remove_node(pos) end
|
||||
pos = minetest.find_node_near(pos, 1, "beds:bed_top")
|
||||
if pos ~= nil then minetest.remove_node(pos) end
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
|
@ -97,7 +97,7 @@ minetest.register_node("beds:bed_bottom", {
|
|||
return
|
||||
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")
|
||||
return
|
||||
else
|
||||
|
@ -110,7 +110,7 @@ minetest.register_node("beds:bed_bottom", {
|
|||
end
|
||||
|
||||
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
|
||||
if param2 == 0 then
|
||||
pos.z = pos.z+1
|
||||
|
@ -191,10 +191,10 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
local players = #minetest.get_connected_players()
|
||||
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
|
||||
minetest.after(2, function()
|
||||
minetest.env:set_timeofday(0.23)
|
||||
minetest.set_timeofday(0.23)
|
||||
wait = false
|
||||
guy:set_physics_override(1,1,1)
|
||||
guy:setpos(exit(guy:getpos()))
|
||||
|
@ -227,7 +227,7 @@ minetest.register_abm({
|
|||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("player") ~= "" then
|
||||
local param2 = node.param2
|
||||
if param2 == 0 then
|
||||
|
@ -239,7 +239,7 @@ minetest.register_abm({
|
|||
elseif param2 == 3 then
|
||||
pos.x = pos.x-1
|
||||
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
|
||||
meta:set_string("player", "")
|
||||
player_in_bed = player_in_bed-1
|
||||
|
|
|
@ -43,7 +43,7 @@ minetest.register_node("cake:cake", {
|
|||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if clicker:get_hp() < 20 then
|
||||
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,
|
||||
})
|
||||
|
@ -67,7 +67,7 @@ minetest.register_node("cake:cake_5", {
|
|||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if clicker:get_hp() < 20 then
|
||||
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,
|
||||
})
|
||||
|
@ -91,7 +91,7 @@ minetest.register_node("cake:cake_4", {
|
|||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if clicker:get_hp() < 20 then
|
||||
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,
|
||||
})
|
||||
|
@ -115,7 +115,7 @@ minetest.register_node("cake:cake_3", {
|
|||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if clicker:get_hp() < 20 then
|
||||
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,
|
||||
})
|
||||
|
@ -139,7 +139,7 @@ minetest.register_node("cake:cake_2", {
|
|||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if clicker:get_hp() < 20 then
|
||||
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,
|
||||
})
|
||||
|
@ -163,7 +163,7 @@ minetest.register_node("cake:cake_1", {
|
|||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if clicker:get_hp() < 20 then
|
||||
clicker:set_hp(clicker:get_hp()+2)
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -7,7 +7,7 @@ local function item_drop(itemstack, dropper, pos)
|
|||
local p = {x=pos.x, y=pos.y+1.2, z=pos.z}
|
||||
p.x = p.x+(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
|
||||
v.x = v.x*4
|
||||
v.y = v.y*4 + 2
|
||||
|
|
|
@ -292,8 +292,8 @@ function default.generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume
|
|||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.env:get_node(p2).name == wherein then
|
||||
minetest.env:set_node(p2, {name=name})
|
||||
if minetest.get_node(p2).name == wherein then
|
||||
minetest.set_node(p2, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -307,10 +307,10 @@ end
|
|||
function default.make_reeds(pos, size)
|
||||
for y=0,size-1 do
|
||||
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
|
||||
minetest.registered_nodes[nn].buildable_to then
|
||||
minetest.env:set_node(p, {name="default:reeds"})
|
||||
minetest.set_node(p, {name="default:reeds"})
|
||||
else
|
||||
return
|
||||
end
|
||||
|
@ -320,10 +320,10 @@ end
|
|||
function default.make_cactus(pos, size)
|
||||
for y=0,size-1 do
|
||||
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
|
||||
minetest.registered_nodes[nn].buildable_to then
|
||||
minetest.env:set_node(p, {name="default:cactus"})
|
||||
minetest.set_node(p, {name="default:cactus"})
|
||||
else
|
||||
return
|
||||
end
|
||||
|
@ -341,17 +341,17 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
for divz=0+1,divs-1-1 do
|
||||
local cx = minp.x + math.floor((divx+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
|
||||
minetest.env:get_node({x=cx,y=0,z=cz}).name == "default:sand" then
|
||||
if minetest.get_node({x=cx,y=1,z=cz}).name == "default:water_source" and
|
||||
minetest.get_node({x=cx,y=0,z=cz}).name == "default:sand" then
|
||||
local is_shallow = true
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
if num_water_around >= 2 then
|
||||
is_shallow = false
|
||||
|
@ -359,8 +359,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
if is_shallow then
|
||||
for x1=-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
|
||||
minetest.env:set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
|
||||
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.set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -369,7 +369,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end
|
||||
end
|
||||
-- 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
|
||||
local divlen = 8
|
||||
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
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
if minetest.env: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
|
||||
if minetest.get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||
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))
|
||||
end
|
||||
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
|
||||
random_struct.call_struct(p,2)
|
||||
end
|
||||
|
@ -401,7 +401,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end
|
||||
end
|
||||
-- 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
|
||||
local divlen = 16
|
||||
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)
|
||||
local ground_y = nil
|
||||
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
|
||||
break
|
||||
end
|
||||
end
|
||||
-- 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))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 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
|
||||
local divlen = 5
|
||||
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)
|
||||
local ground_y = nil
|
||||
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
|
||||
break
|
||||
end
|
||||
|
@ -462,18 +462,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
|
||||
if ground_y then
|
||||
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
|
||||
if minetest.registered_nodes[nn] and
|
||||
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 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
|
||||
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
|
||||
random_struct.call_struct(p,1)
|
||||
end
|
||||
|
|
|
@ -1118,7 +1118,7 @@ minetest.register_node("default:vine", {
|
|||
local ptr = 1
|
||||
while next_find == true do
|
||||
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
|
||||
drop_attached_node(pos2)
|
||||
nodeupdate(pos2)
|
||||
|
@ -1318,16 +1318,16 @@ local function get_chest_neighborpos(pos, param2, side)
|
|||
end
|
||||
|
||||
local function hacky_swap_node(pos,name, param2)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
node.param2 = param2 or node.param2
|
||||
local meta0 = meta:to_table()
|
||||
minetest.env:set_node(pos,node)
|
||||
meta = minetest.env:get_meta(pos)
|
||||
minetest.set_node(pos,node)
|
||||
meta = minetest.get_meta(pos)
|
||||
meta:from_table(meta0)
|
||||
end
|
||||
|
||||
|
@ -1341,10 +1341,10 @@ minetest.register_node("default:chest", {
|
|||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local param2 = minetest.env:get_node(pos).param2
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if minetest.env:get_node(get_chest_neighborpos(pos, param2, "right")).name == "default:chest" then
|
||||
minetest.env:set_node(pos, {name="default:chest_right",param2=param2})
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local meta = minetest.get_meta(pos)
|
||||
if minetest.get_node(get_chest_neighborpos(pos, param2, "right")).name == "default:chest" then
|
||||
minetest.set_node(pos, {name="default:chest_right",param2=param2})
|
||||
local p = get_chest_neighborpos(pos, param2, "right")
|
||||
meta:set_string("formspec",
|
||||
"size[9,11.5]"..
|
||||
|
@ -1358,7 +1358,7 @@ minetest.register_node("default:chest", {
|
|||
"listring[current_name;main]")
|
||||
meta:set_string("infotext", "Large Chest")
|
||||
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",
|
||||
"size[9,11.5]"..
|
||||
"list[current_name;main;0,0;9,3;]"..
|
||||
|
@ -1370,8 +1370,8 @@ minetest.register_node("default:chest", {
|
|||
"listring[current_player;main]"..
|
||||
"listring[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main]")
|
||||
m:set_string("infotext", "Large Chest")
|
||||
elseif minetest.env:get_node(get_chest_neighborpos(pos, param2, "left")).name == "default:chest" then
|
||||
minetest.env:set_node(pos, {name="default:chest_left",param2=param2})
|
||||
elseif minetest.get_node(get_chest_neighborpos(pos, param2, "left")).name == "default:chest" then
|
||||
minetest.set_node(pos, {name="default:chest_left",param2=param2})
|
||||
local p = get_chest_neighborpos(pos, param2, "left")
|
||||
meta:set_string("formspec",
|
||||
"size[9,11.5]"..
|
||||
|
@ -1385,7 +1385,7 @@ minetest.register_node("default:chest", {
|
|||
"listring[nodemeta:"..p.x..","..p.y..","..p.z..";main]")
|
||||
meta:set_string("infotext", "Large Chest")
|
||||
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",
|
||||
"size[9,11.5]"..
|
||||
"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)
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
|
@ -1421,7 +1421,7 @@ minetest.register_node("default:chest", {
|
|||
local stack = inv:get_stack("main", i)
|
||||
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}
|
||||
minetest.env:add_item(p, stack)
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
meta:from_table(meta2:to_table())
|
||||
|
@ -1449,16 +1449,16 @@ minetest.register_node("default:chest_left", {
|
|||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_destruct = function(pos)
|
||||
local m = minetest.env:get_meta(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
if m:get_string("infotext") == "Chest" then
|
||||
return
|
||||
end
|
||||
local param2 = minetest.env:get_node(pos).param2
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
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
|
||||
end
|
||||
local meta = minetest.env:get_meta(p)
|
||||
local meta = minetest.get_meta(p)
|
||||
meta:set_string("formspec",
|
||||
"size[9,8.75]"..
|
||||
"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")
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
|
@ -1480,7 +1480,7 @@ minetest.register_node("default:chest_left", {
|
|||
local stack = inv:get_stack("main", i)
|
||||
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}
|
||||
minetest.env:add_item(p, stack)
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
meta:from_table(meta2:to_table())
|
||||
|
@ -1508,16 +1508,16 @@ minetest.register_node("default:chest_right", {
|
|||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_destruct = function(pos)
|
||||
local m = minetest.env:get_meta(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
if m:get_string("infotext") == "Chest" then
|
||||
return
|
||||
end
|
||||
local param2 = minetest.env:get_node(pos).param2
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
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
|
||||
end
|
||||
local meta = minetest.env:get_meta(p)
|
||||
local meta = minetest.get_meta(p)
|
||||
meta:set_string("formspec",
|
||||
"size[9,8.75]"..
|
||||
"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")
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta2 = meta
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
|
@ -1539,7 +1539,7 @@ minetest.register_node("default:chest_right", {
|
|||
local stack = inv:get_stack("main", i)
|
||||
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}
|
||||
minetest.env:add_item(p, stack)
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
meta:from_table(meta2:to_table())
|
||||
|
@ -1585,7 +1585,7 @@ minetest.register_node("default:furnace", {
|
|||
groups = {cracky=2},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
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("infotext", "Furnace")
|
||||
local inv = meta:get_inventory()
|
||||
|
@ -1594,7 +1594,7 @@ minetest.register_node("default:furnace", {
|
|||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("fuel") then
|
||||
return false
|
||||
|
@ -1606,7 +1606,7 @@ minetest.register_node("default:furnace", {
|
|||
return true
|
||||
end,
|
||||
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()
|
||||
if listname == "fuel" 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,
|
||||
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 stack = inv:get_stack(from_list, from_index)
|
||||
if to_list == "fuel" then
|
||||
|
@ -1655,7 +1655,7 @@ minetest.register_node("default:furnace_active", {
|
|||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
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("infotext", "Furnace");
|
||||
local inv = meta:get_inventory()
|
||||
|
@ -1664,7 +1664,7 @@ minetest.register_node("default:furnace_active", {
|
|||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("fuel") then
|
||||
return false
|
||||
|
@ -1676,7 +1676,7 @@ minetest.register_node("default:furnace_active", {
|
|||
return true
|
||||
end,
|
||||
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()
|
||||
if listname == "fuel" 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,
|
||||
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 stack = inv:get_stack(from_list, from_index)
|
||||
if to_list == "fuel" then
|
||||
|
@ -1715,16 +1715,16 @@ minetest.register_node("default:furnace_active", {
|
|||
})
|
||||
|
||||
function hacky_swap_node(pos,name)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local meta0 = meta:to_table()
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
local meta0 = meta:to_table()
|
||||
minetest.env:set_node(pos,node)
|
||||
meta = minetest.env:get_meta(pos)
|
||||
minetest.set_node(pos,node)
|
||||
meta = minetest.get_meta(pos)
|
||||
meta:from_table(meta0)
|
||||
end
|
||||
|
||||
|
@ -1733,7 +1733,7 @@ minetest.register_abm({
|
|||
interval = 1.0,
|
||||
chance = 1,
|
||||
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({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
|
@ -2020,13 +2020,13 @@ minetest.register_node("default:sponge", {
|
|||
local on_water = false
|
||||
local pos = pointed_thing.above
|
||||
-- verifier si il est dans l'eau ou a cotée
|
||||
if string.find(minetest.env:get_node(pointed_thing.above).name, "water_source")
|
||||
or string.find(minetest.env:get_node(pointed_thing.above).name, "water_flowing") then
|
||||
if string.find(minetest.get_node(pointed_thing.above).name, "water_source")
|
||||
or string.find(minetest.get_node(pointed_thing.above).name, "water_flowing") then
|
||||
on_water = true
|
||||
end
|
||||
for i=-1,1 do
|
||||
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
|
||||
if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
|
||||
on_water = true
|
||||
|
@ -2034,7 +2034,7 @@ minetest.register_node("default:sponge", {
|
|||
end
|
||||
for i=-1,1 do
|
||||
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
|
||||
if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
|
||||
on_water = true
|
||||
|
@ -2042,7 +2042,7 @@ minetest.register_node("default:sponge", {
|
|||
end
|
||||
for i=-1,1 do
|
||||
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
|
||||
if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
|
||||
on_water = true
|
||||
|
@ -2054,10 +2054,10 @@ minetest.register_node("default:sponge", {
|
|||
for j=-3,3 do
|
||||
for k=-3,3 do
|
||||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
|
@ -2065,11 +2065,11 @@ minetest.register_node("default:sponge", {
|
|||
end
|
||||
end
|
||||
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
|
||||
minetest.env:add_node(pointed_thing.above, {name = "default:sponge_wet"})
|
||||
minetest.add_node(pointed_thing.above, {name = "default:sponge_wet"})
|
||||
else
|
||||
minetest.env:add_node(pointed_thing.above, {name = "default:sponge"})
|
||||
minetest.add_node(pointed_thing.above, {name = "default:sponge"})
|
||||
end
|
||||
return itemstack
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ minetest.register_tool("default:pole", {
|
|||
liquids_pointable = true,
|
||||
on_use = function (itemstack, user, pointed_thing)
|
||||
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 math.random(1, 100) > 50 then
|
||||
local inv = user:get_inventory()
|
||||
|
@ -348,8 +348,8 @@ minetest.register_craftitem("default:snowball", {
|
|||
on_use = snow_shoot_snowball,
|
||||
on_construct = function(pos)
|
||||
pos.y = pos.y - 1
|
||||
if minetest.env:get_node(pos).name == "default:dirt_with_grass" then
|
||||
minetest.env:set_node(pos, {name="default:dirt_with_snow"})
|
||||
if minetest.get_node(pos).name == "default:dirt_with_grass" then
|
||||
minetest.set_node(pos, {name="default:dirt_with_snow"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -18,8 +18,8 @@ doors = {}
|
|||
-- open it
|
||||
|
||||
local function is_right(pos, clicker)
|
||||
local r1 = minetest.env: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 r1 = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
|
||||
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
|
||||
return true
|
||||
else
|
||||
|
@ -58,7 +58,7 @@ function doors:register_door(name, def)
|
|||
return itemstack
|
||||
end
|
||||
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
|
||||
return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
|
||||
end
|
||||
|
@ -67,8 +67,8 @@ function doors:register_door(name, def)
|
|||
local pt2 = {x=pt.x, y=pt.y, z=pt.z}
|
||||
pt2.y = pt2.y+1
|
||||
if
|
||||
not minetest.registered_nodes[minetest.env: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(pt).name].buildable_to or
|
||||
not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to or
|
||||
not placer or
|
||||
not placer:is_player()
|
||||
then
|
||||
|
@ -86,20 +86,20 @@ function doors:register_door(name, def)
|
|||
elseif p2 == 3 then
|
||||
pt3.z = pt3.z-1
|
||||
end
|
||||
if not string.find(minetest.env:get_node(pt3).name, name.."_b_") then
|
||||
minetest.env:set_node(pt, {name=name.."_b_1", param2=p2})
|
||||
minetest.env:set_node(pt2, {name=name.."_t_1", param2=p2})
|
||||
if not string.find(minetest.get_node(pt3).name, name.."_b_") then
|
||||
minetest.set_node(pt, {name=name.."_b_1", param2=p2})
|
||||
minetest.set_node(pt2, {name=name.."_t_1", param2=p2})
|
||||
else
|
||||
minetest.env:set_node(pt, {name=name.."_b_2", param2=p2})
|
||||
minetest.env:set_node(pt2, {name=name.."_t_2", param2=p2})
|
||||
minetest.set_node(pt, {name=name.."_b_2", param2=p2})
|
||||
minetest.set_node(pt2, {name=name.."_t_2", param2=p2})
|
||||
end
|
||||
|
||||
if def.only_placer_can_open then
|
||||
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("infotext", "Owned by "..pn)
|
||||
meta = minetest.env:get_meta(pt2)
|
||||
meta = minetest.get_meta(pt2)
|
||||
meta:set_string("doors_owner", "")
|
||||
--meta:set_string("infotext", "Owned by "..pn)
|
||||
end
|
||||
|
@ -115,7 +115,7 @@ function doors:register_door(name, def)
|
|||
local tb = def.tiles_bottom
|
||||
|
||||
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
|
||||
minetest.node_dig(pos, node, digger)
|
||||
end
|
||||
|
@ -123,27 +123,27 @@ function doors:register_door(name, def)
|
|||
|
||||
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
||||
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
|
||||
end
|
||||
local p2 = minetest.env:get_node(pos).param2
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
p2 = params[p2+1]
|
||||
|
||||
local meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:set_node(pos, {name=replace_dir, param2=p2})
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
local meta = minetest.get_meta(pos):to_table()
|
||||
minetest.set_node(pos, {name=replace_dir, param2=p2})
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
|
||||
pos.y = pos.y-dir
|
||||
meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:set_node(pos, {name=replace, param2=p2})
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
meta = minetest.get_meta(pos):to_table()
|
||||
minetest.set_node(pos, {name=replace, param2=p2})
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
end
|
||||
|
||||
local function check_player_priv(pos, player)
|
||||
if not def.only_placer_can_open then
|
||||
return true
|
||||
end
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local pn = player:get_player_name()
|
||||
return meta:get_string("doors_owner") == pn
|
||||
end
|
||||
|
@ -473,13 +473,13 @@ local meta
|
|||
local state = 0
|
||||
|
||||
local function update_door(pos, node)
|
||||
minetest.env:set_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
|
||||
local function punch(pos)
|
||||
meta = minetest.env:get_meta(pos)
|
||||
meta = minetest.get_meta(pos)
|
||||
state = meta:get_int("state")
|
||||
me = minetest.env:get_node(pos)
|
||||
me = minetest.get_node(pos)
|
||||
local tmp_node
|
||||
local tmp_node2
|
||||
oben = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
|
@ -598,13 +598,13 @@ local meta
|
|||
local state = 0
|
||||
|
||||
local function update_door(pos, node)
|
||||
minetest.env:set_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
|
||||
local function punch(pos)
|
||||
meta = minetest.env:get_meta(pos)
|
||||
meta = minetest.get_meta(pos)
|
||||
state = meta:get_int("state")
|
||||
me = minetest.env:get_node(pos)
|
||||
me = minetest.get_node(pos)
|
||||
local tmp_node
|
||||
local tmp_node2
|
||||
oben = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
|
|
|
@ -8,14 +8,14 @@ function farming:add_plant(full_grown, names, interval, chance)
|
|||
chance = chance,
|
||||
action = function(pos, node)
|
||||
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
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if not minetest.env:get_node_light(pos) then
|
||||
if not minetest.get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
if minetest.env:get_node_light(pos) < 10 then
|
||||
if minetest.get_node_light(pos) < 10 then
|
||||
return
|
||||
end
|
||||
local step = nil
|
||||
|
@ -32,7 +32,7 @@ function farming:add_plant(full_grown, names, interval, chance)
|
|||
if new_node.name == nil then
|
||||
new_node.name = full_grown
|
||||
end
|
||||
minetest.env:set_node(pos, new_node)
|
||||
minetest.set_node(pos, new_node)
|
||||
end
|
||||
} )
|
||||
end
|
||||
|
@ -48,13 +48,13 @@ function farming:place_seed(itemstack, placer, pointed_thing, plantname)
|
|||
end
|
||||
|
||||
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}
|
||||
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
|
||||
minetest.env:add_node(pos, {name=plantname})
|
||||
minetest.add_node(pos, {name=plantname})
|
||||
else
|
||||
return
|
||||
end
|
||||
|
|
|
@ -18,19 +18,19 @@ minetest.register_node("farming:melon", {
|
|||
local have_change = 0
|
||||
for x=-1,1 do
|
||||
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
|
||||
have_change = 1
|
||||
minetest.env:add_node(p, {name="farming:melontige_unconnect"})
|
||||
minetest.add_node(p, {name="farming:melontige_unconnect"})
|
||||
end
|
||||
end
|
||||
if have_change == 0 then
|
||||
for z=-1,1 do
|
||||
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
|
||||
have_change = 1
|
||||
minetest.env:add_node(p, {name="farming:melontige_unconnect"})
|
||||
minetest.add_node(p, {name="farming:melontige_unconnect"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -241,17 +241,17 @@ minetest.register_abm({
|
|||
for x=-1,1 do
|
||||
local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
|
||||
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
|
||||
local n = minetest.env:get_node(p)
|
||||
local nod = minetest.env:get_node(newpos)
|
||||
local n = minetest.get_node(p)
|
||||
local nod = minetest.get_node(newpos)
|
||||
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 string.find(n.name, "farming:soil") and nod.name=="air" and have_change == 0 then
|
||||
have_change = 1
|
||||
minetest.env:add_node(newpos, {name="farming:melon"})
|
||||
minetest.add_node(newpos, {name="farming:melon"})
|
||||
if x == 1 then
|
||||
minetest.env:add_node(pos, {name="farming:melontige_linked_r" })
|
||||
minetest.add_node(pos, {name="farming:melontige_linked_r" })
|
||||
else
|
||||
minetest.env:add_node(pos, {name="farming:melontige_linked_l"})
|
||||
minetest.add_node(pos, {name="farming:melontige_linked_l"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -259,17 +259,17 @@ minetest.register_abm({
|
|||
for z=-1,1 do
|
||||
p = {x=pos.x, y=pos.y-1, z=pos.z+z}
|
||||
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
|
||||
n = minetest.env:get_node(p)
|
||||
local nod2 = minetest.env:get_node(newpos)
|
||||
n = minetest.get_node(p)
|
||||
local nod2 = minetest.get_node(newpos)
|
||||
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 string.find(n.name, "farming:soil") and nod2.name=="air" and have_change == 0 then
|
||||
have_change = 1
|
||||
minetest.env:add_node(newpos, {name="farming:melon"})
|
||||
minetest.add_node(newpos, {name="farming:melon"})
|
||||
if z == 1 then
|
||||
minetest.env:add_node(pos, {name="farming:melontige_linked_t" })
|
||||
minetest.add_node(pos, {name="farming:melontige_linked_t" })
|
||||
else
|
||||
minetest.env:add_node(pos, {name="farming:melontige_linked_b" })
|
||||
minetest.add_node(pos, {name="farming:melontige_linked_b" })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,10 +5,10 @@ minetest.register_craftitem("farming:pumpkin_seed", {
|
|||
stack_max = 64,
|
||||
inventory_image = "farming_pumpkin_seed.png",
|
||||
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
|
||||
above.name = "farming:pumpkin_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
minetest.set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
|
@ -60,19 +60,19 @@ minetest.register_node("farming:pumpkin_face", {
|
|||
local have_change = 0
|
||||
for x=-1,1 do
|
||||
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
|
||||
have_change = 1
|
||||
minetest.env:add_node(p, {name="farming:pumpkintige_unconnect"})
|
||||
minetest.add_node(p, {name="farming:pumpkintige_unconnect"})
|
||||
end
|
||||
end
|
||||
if have_change == 0 then
|
||||
for z=-1,1 do
|
||||
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
|
||||
have_change = 1
|
||||
minetest.env:add_node(p, {name="farming:pumpkintige_unconnect"})
|
||||
minetest.add_node(p, {name="farming:pumpkintige_unconnect"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -232,17 +232,17 @@ minetest.register_abm({
|
|||
for x=-1,1 do
|
||||
local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
|
||||
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
|
||||
local n = minetest.env:get_node(p)
|
||||
local nod = minetest.env:get_node(newpos)
|
||||
local n = minetest.get_node(p)
|
||||
local nod = minetest.get_node(newpos)
|
||||
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 string.find(n.name, "farming:soil") and nod.name=="air" and have_change == 0 then
|
||||
have_change = 1
|
||||
minetest.env:add_node(newpos, {name="farming:pumpkin_face"})
|
||||
minetest.add_node(newpos, {name="farming:pumpkin_face"})
|
||||
if x == 1 then
|
||||
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_r" })
|
||||
minetest.add_node(pos, {name="farming:pumpkintige_linked_r" })
|
||||
else
|
||||
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_l"})
|
||||
minetest.add_node(pos, {name="farming:pumpkintige_linked_l"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -250,17 +250,17 @@ minetest.register_abm({
|
|||
for z=-1,1 do
|
||||
p = {x=pos.x, y=pos.y-1, z=pos.z+z}
|
||||
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
|
||||
n = minetest.env:get_node(p)
|
||||
local nod2 = minetest.env:get_node(newpos)
|
||||
n = minetest.get_node(p)
|
||||
local nod2 = minetest.get_node(newpos)
|
||||
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 string.find(n.name, "farming:soil") and nod2.name=="air" and have_change == 0 then
|
||||
have_change = 1
|
||||
minetest.env:add_node(newpos, {name="farming:pumpkin_face"})
|
||||
minetest.add_node(newpos, {name="farming:pumpkin_face"})
|
||||
if z == 1 then
|
||||
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_t" })
|
||||
minetest.add_node(pos, {name="farming:pumpkintige_linked_t" })
|
||||
else
|
||||
minetest.env:add_node(pos, {name="farming:pumpkintige_linked_b" })
|
||||
minetest.add_node(pos, {name="farming:pumpkintige_linked_b" })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,9 +36,9 @@ minetest.register_abm({
|
|||
interval = 15,
|
||||
chance = 3,
|
||||
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"
|
||||
minetest.env:set_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -13,47 +13,47 @@ local function find_dock(pos, second)
|
|||
return false
|
||||
end
|
||||
|
||||
local h1 = minetest.env: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 r1 = minetest.env: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 h1 = minetest.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.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
|
||||
if dockable(l1.name) then
|
||||
code = code+1
|
||||
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
|
||||
if dockable(r1.name) then
|
||||
code = code+2
|
||||
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
|
||||
if dockable(v1.name) then
|
||||
code = code+11
|
||||
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
|
||||
if dockable(h1.name) then
|
||||
code = code+21
|
||||
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
|
||||
local me = minetest.env:get_node(pos)
|
||||
local me = minetest.get_node(pos)
|
||||
if code > 0 then
|
||||
local tmp_name = "fences:fence_wood_"..code
|
||||
local tmp_node = {name=tmp_name, param1=me.param1, param2=me.param2}
|
||||
if second > 0 then
|
||||
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
|
||||
elseif code == 0 then
|
||||
if second == 2 then
|
||||
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
|
||||
|
||||
|
@ -583,11 +583,11 @@ local meta2
|
|||
local state2 = 0
|
||||
|
||||
local function update_gate(pos, node)
|
||||
minetest.env:set_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
|
||||
local function punch_gate(pos, node)
|
||||
meta2 = minetest.env:get_meta(pos)
|
||||
meta2 = minetest.get_meta(pos)
|
||||
state2 = meta2:get_int("state")
|
||||
local tmp_node2
|
||||
if state2 == 1 then
|
||||
|
@ -684,8 +684,8 @@ minetest.register_node("fences:fencegate", {
|
|||
}
|
||||
},
|
||||
on_construct = function(pos)
|
||||
me2 = minetest.env:get_node(pos)
|
||||
meta2 = minetest.env:get_meta(pos)
|
||||
me2 = minetest.get_node(pos)
|
||||
meta2 = minetest.get_meta(pos)
|
||||
meta2:set_int("state", 0)
|
||||
state2 = 0
|
||||
find_dock(pos, -1)
|
||||
|
@ -711,8 +711,8 @@ if override_original == true then
|
|||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local tmp_node3 = {name="fences:fence_wood"}
|
||||
minetest.env:set_node(pos, tmp_node3)
|
||||
minetest.env:punch_node(pos)
|
||||
minetest.set_node(pos, tmp_node3)
|
||||
minetest.punch_node(pos)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ facedir[3] = {x=-1,y=0,z=0}
|
|||
local flower_pot_remove_item = function(pos, node)
|
||||
local objs = nil
|
||||
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
|
||||
if objs then
|
||||
for _, obj in ipairs(objs) do
|
||||
|
@ -58,24 +58,24 @@ end
|
|||
|
||||
flower_pot_update_item = function(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 node.name == "flowers:pot" then
|
||||
pos.y = pos.y
|
||||
end
|
||||
flower_tmp.nodename = node.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
|
||||
|
||||
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 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
|
||||
meta:set_string("item","")
|
||||
end
|
||||
flower_pot_remove_item(pos, node)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -299,12 +299,12 @@ minetest.register_node("flowers:pot",{
|
|||
stack_max = 16,
|
||||
sounds = default.node_sound_defaults(),
|
||||
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())
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
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
|
||||
flower_pot_drop_item(pos,node)
|
||||
local s = itemstack:take_item()
|
||||
|
@ -314,20 +314,20 @@ minetest.register_node("flowers:pot",{
|
|||
return itemstack
|
||||
end,
|
||||
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
|
||||
flower_pot_drop_item(pos,node)
|
||||
end
|
||||
end,
|
||||
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")
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
flower_pot_drop_item(pos,node)
|
||||
minetest.env:add_node(pos, {name="air"})
|
||||
minetest.env:add_item(pos, "flowers:pot")
|
||||
minetest.add_node(pos, {name="air"})
|
||||
minetest.add_item(pos, "flowers:pot")
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ minetest.register_node("gemalde:node_"..n.."", {
|
|||
|
||||
print("[gemalde] number is "..number.."")
|
||||
node.name = "gemalde:node_"..number..""
|
||||
minetest.env:set_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
end,
|
||||
|
||||
-- TODO.
|
||||
|
|
|
@ -7,7 +7,7 @@ minetest.register_globalstep(function(dtime)
|
|||
local ctrl = player:get_player_control()
|
||||
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()
|
||||
if not object:is_player() and en and en.name == "__builtin:item" then
|
||||
if inv and
|
||||
|
@ -46,7 +46,7 @@ function minetest.handle_node_drops(pos, drops, digger)
|
|||
end
|
||||
if not inv or not inv:contains_item("main", ItemStack(name)) then
|
||||
for i=1,count do
|
||||
local obj = minetest.env:add_item(pos, name)
|
||||
local obj = minetest.add_item(pos, name)
|
||||
if obj ~= nil then
|
||||
obj:get_luaentity().collect = true
|
||||
local x = math.random(1, 5)
|
||||
|
|
|
@ -44,7 +44,7 @@ facedir[3] = {x=-1,y=0,z=0}
|
|||
local remove_item = function(pos, node)
|
||||
local objs = nil
|
||||
if node.name == "itemframes:frame" then
|
||||
objs = minetest.env:get_objects_inside_radius(pos, .5)
|
||||
objs = minetest.get_objects_inside_radius(pos, .5)
|
||||
end
|
||||
if objs then
|
||||
for _, obj in ipairs(objs) do
|
||||
|
@ -57,7 +57,7 @@ end
|
|||
|
||||
local update_item = function(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 node.name == "itemframes:frame" then
|
||||
local posad = facedir[node.param2]
|
||||
|
@ -67,7 +67,7 @@ local update_item = function(pos, node)
|
|||
end
|
||||
tmp.nodename = node.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
|
||||
local yaw = math.pi*2 - node.param2 * math.pi/2
|
||||
e:setyaw(yaw)
|
||||
|
@ -76,10 +76,10 @@ local update_item = function(pos, node)
|
|||
end
|
||||
|
||||
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 node.name == "itemframes:frame" then
|
||||
minetest.env:add_item(pos, meta:get_string("item"))
|
||||
minetest.add_item(pos, meta:get_string("item"))
|
||||
end
|
||||
meta:set_string("item","")
|
||||
end
|
||||
|
@ -103,13 +103,13 @@ minetest.register_node("itemframes:frame",{
|
|||
legacy_wallmounted = true,
|
||||
sounds = default.node_sound_defaults(),
|
||||
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("infotext","Item frame (owned by "..placer:get_player_name()..")")
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
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
|
||||
drop_item(pos,node)
|
||||
local s = itemstack:take_item()
|
||||
|
@ -119,14 +119,14 @@ minetest.register_node("itemframes:frame",{
|
|||
return itemstack
|
||||
end,
|
||||
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
|
||||
drop_item(pos, node)
|
||||
end
|
||||
end,
|
||||
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")
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
local z = math.random(0, 9)/3
|
||||
pos.x = pos.x + x
|
||||
pos.z = pos.z + z
|
||||
minetest.env:add_item(pos, stack)
|
||||
minetest.add_item(pos, stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
pos.x = pos.x - x
|
||||
pos.z = pos.z - z
|
||||
end
|
||||
end)
|
||||
--end
|
||||
--end
|
||||
|
|
|
@ -613,9 +613,9 @@ function mobs:register_mob(name, def)
|
|||
pos.y = math.floor(pos.y+0.5)
|
||||
pos.z = math.floor(pos.z+0.5)
|
||||
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,})
|
||||
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()
|
||||
return
|
||||
end
|
||||
|
@ -624,17 +624,17 @@ function mobs:register_mob(name, def)
|
|||
for z=-3,3 do
|
||||
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 n = minetest.env:get_node(np)
|
||||
local n = minetest.get_node(np)
|
||||
if n.name ~= "air" and n.name ~= "default:obsidian" and n.name ~= "default:bedrock" and n.name ~= "protector:protect" then
|
||||
activate_if_tnt(n.name, np, pos, 3)
|
||||
minetest.env:remove_node(np)
|
||||
minetest.remove_node(np)
|
||||
nodeupdate(np)
|
||||
if n.name ~= "tnt:tnt" and math.random() > 0.9 then
|
||||
local drop = minetest.get_node_drops(n.name, "")
|
||||
for _,item in ipairs(drop) do
|
||||
if type(item) == "string" then
|
||||
if math.random(1,100) > 40 then
|
||||
local obj = minetest.env:add_item(np, item)
|
||||
local obj = minetest.add_item(np, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -970,7 +970,7 @@ function mobs:register_spawn(name, description, nodes, max_light, min_light, cha
|
|||
end
|
||||
|
||||
function do_tnt_physics(tnt_np,tntr)
|
||||
local objs = minetest.env:get_objects_inside_radius(tnt_np, tntr)
|
||||
local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
|
||||
for k, obj in pairs(objs) do
|
||||
local oname = obj:get_entity_name()
|
||||
local v = obj:getvelocity()
|
||||
|
|
|
@ -98,7 +98,7 @@ function mesecon:receptor_off(pos, rules)
|
|||
if not mesecon:connected_to_receptor(np) then
|
||||
mesecon:turnoff(np, rulename)
|
||||
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
|
||||
|
|
|
@ -268,7 +268,7 @@ end
|
|||
-- some more general high-level stuff
|
||||
|
||||
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
|
||||
return true
|
||||
end
|
||||
|
@ -276,7 +276,7 @@ function mesecon:is_power_on(pos)
|
|||
end
|
||||
|
||||
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
|
||||
return true
|
||||
end
|
||||
|
@ -284,11 +284,11 @@ function mesecon:is_power_off(pos)
|
|||
end
|
||||
|
||||
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
|
||||
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
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
|
@ -307,11 +307,11 @@ function mesecon:turnon(pos, rulename)
|
|||
end
|
||||
|
||||
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
|
||||
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
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
|
@ -332,7 +332,7 @@ end
|
|||
|
||||
|
||||
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
|
||||
local rules = mesecon:get_any_inputrules(node)
|
||||
|
@ -360,7 +360,7 @@ function mesecon:find_receptor_on(pos, checked)
|
|||
|
||||
-- add current position to checked
|
||||
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
|
||||
return true
|
||||
|
@ -382,8 +382,8 @@ function mesecon:find_receptor_on(pos, checked)
|
|||
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
|
||||
local outputnode = minetest.env:get_node(output)
|
||||
local inputnode = minetest.env:get_node(input)
|
||||
local outputnode = minetest.get_node(output)
|
||||
local inputnode = minetest.get_node(input)
|
||||
local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode)
|
||||
local inputrules = mesecon:get_any_inputrules (inputnode)
|
||||
if not outputrules or not inputrules then
|
||||
|
@ -409,13 +409,13 @@ function mesecon:rules_link_anydir(pos1, pos2)
|
|||
end
|
||||
|
||||
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)
|
||||
if not rules then return false end
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
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))
|
||||
and mesecon:rules_link(np, pos) then
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
function mesecon:swap_node(pos, name)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local data = minetest.env:get_meta(pos):to_table()
|
||||
local node = minetest.get_node(pos)
|
||||
local data = minetest.get_meta(pos):to_table()
|
||||
node.name = name
|
||||
minetest.env:add_node(pos, node)
|
||||
minetest.env:get_meta(pos):from_table(data)
|
||||
minetest.add_node(pos, node)
|
||||
minetest.get_meta(pos):from_table(data)
|
||||
end
|
||||
|
||||
function mesecon:move_node(pos, newpos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:add_node(newpos, node)
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos):to_table()
|
||||
minetest.remove_node(pos)
|
||||
minetest.add_node(newpos, node)
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
|
|||
mesecon:update_autoconnect(zmympos, true)
|
||||
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 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
|
||||
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
|
||||
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
|
||||
else
|
||||
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
|
||||
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
-- and then turns off again
|
||||
|
||||
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
|
||||
mesecon:swap_node(pos, "mesecons_button:button_stone_off")
|
||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||
|
|
|
@ -38,27 +38,27 @@ function doors:register_door(name, def)
|
|||
local tb = def.tiles_bottom
|
||||
|
||||
local function after_dig_node(pos, name)
|
||||
if minetest.env:get_node(pos).name == name then
|
||||
minetest.env:remove_node(pos)
|
||||
if minetest.get_node(pos).name == name then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
||||
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
|
||||
end
|
||||
local p2 = minetest.env:get_node(pos).param2
|
||||
local p2 = minetest.get_node(pos).param2
|
||||
p2 = params[p2+1]
|
||||
|
||||
local meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:set_node(pos, {name=replace_dir, param2=p2})
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
local meta = minetest.get_meta(pos):to_table()
|
||||
minetest.set_node(pos, {name=replace_dir, param2=p2})
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
|
||||
pos.y = pos.y-dir
|
||||
meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:set_node(pos, {name=replace, param2=p2})
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
meta = minetest.get_meta(pos):to_table()
|
||||
minetest.set_node(pos, {name=replace, param2=p2})
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
end
|
||||
|
||||
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
|
||||
return true
|
||||
end
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local pn = player:get_player_name()
|
||||
return meta:get_string("doors_owner") == pn
|
||||
end
|
||||
|
|
|
@ -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 )
|
||||
for _, n in ipairs(stack) do
|
||||
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)
|
||||
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
|
||||
local nodes = {}
|
||||
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
|
||||
-- don't push at all, something is in the way (unloaded map or too many nodes)
|
||||
return
|
||||
|
@ -57,8 +57,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
|
|||
|
||||
-- remove all nodes
|
||||
for _, n in ipairs(nodes) do
|
||||
n.meta = minetest.env:get_meta(n.pos):to_table()
|
||||
minetest.env:remove_node(n.pos)
|
||||
n.meta = minetest.get_meta(n.pos):to_table()
|
||||
minetest.remove_node(n.pos)
|
||||
end
|
||||
|
||||
-- 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
|
||||
for _, n in ipairs(nodes) do
|
||||
np = mesecon:addPosRule(n.pos, dir)
|
||||
minetest.env:add_node(np, n.node)
|
||||
minetest.env:get_meta(np):from_table(n.meta)
|
||||
minetest.add_node(np, n.node)
|
||||
minetest.get_meta(np):from_table(n.meta)
|
||||
end
|
||||
|
||||
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)
|
||||
np = mesecon:addPosRule(pos, dir)
|
||||
nn = minetest.env:get_node(np)
|
||||
nn = minetest.get_node(np)
|
||||
|
||||
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
|
||||
local meta = minetest.env:get_meta(np):to_table()
|
||||
minetest.env:remove_node(np)
|
||||
minetest.env:add_node(pos, nn)
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
local meta = minetest.get_meta(np):to_table()
|
||||
minetest.remove_node(np)
|
||||
minetest.add_node(pos, nn)
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
|
||||
nodeupdate(np)
|
||||
nodeupdate(pos)
|
||||
|
@ -102,25 +102,25 @@ end
|
|||
|
||||
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 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 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 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}
|
||||
repeat
|
||||
lnode2 = minetest.env:get_node(lpos2)
|
||||
minetest.env:add_node(oldpos, {name=lnode2.name})
|
||||
lnode2 = minetest.get_node(lpos2)
|
||||
minetest.add_node(oldpos, {name=lnode2.name})
|
||||
nodeupdate(oldpos)
|
||||
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
|
||||
lpos2.x = lpos2.x-direction.x
|
||||
lpos2.y = lpos2.y-direction.y
|
||||
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")
|
||||
minetest.env:remove_node(oldpos)
|
||||
minetest.remove_node(oldpos)
|
||||
end
|
||||
|
||||
mesecon:register_mvps_stopper("default:chest")
|
||||
|
|
|
@ -7,12 +7,12 @@ minetest.register_node("mesecons_noteblock:noteblock", {
|
|||
paramtype="light",
|
||||
is_ground_content = false,
|
||||
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,
|
||||
on_punch = function (pos, node) -- change sound when punched
|
||||
local param2 = node.param2+1
|
||||
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)
|
||||
end,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
@ -65,7 +65,7 @@ mesecon.noteblock_play = function (pos, param2)
|
|||
elseif param2==7 then
|
||||
soundname="mesecons_noteblock_gsharp"
|
||||
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
|
||||
soundname="mesecons_noteblock_hihat"
|
||||
end
|
||||
|
|
|
@ -59,10 +59,10 @@ local piston_remove_pusher = function (pos, node)
|
|||
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
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)
|
||||
minetest.env:remove_node(pusherpos)
|
||||
minetest.remove_node(pusherpos)
|
||||
nodeupdate(pusherpos)
|
||||
end
|
||||
end
|
||||
|
@ -74,15 +74,15 @@ local piston_on = function (pos, node)
|
|||
local np = mesecon:addPosRule(pos, dir)
|
||||
success, stack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
|
||||
if success then
|
||||
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.env:add_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
mesecon:mvps_process_stack(stack)
|
||||
end
|
||||
end
|
||||
|
||||
local piston_off = function (pos, node)
|
||||
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)
|
||||
|
||||
if pistonspec.sticky then
|
||||
|
@ -100,12 +100,12 @@ local piston_orientate = function (pos, placer)
|
|||
-- placer pitch in degrees
|
||||
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
|
||||
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
|
||||
minetest.env:add_node(pos, {name=pistonspec.piston_up})
|
||||
minetest.add_node(pos, {name=pistonspec.piston_up})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -723,7 +723,7 @@ local piston_get_stopper = function (node, dir, stack, stackid)
|
|||
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
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
|
||||
for _, s in ipairs(stack) do
|
||||
|
|
|
@ -9,18 +9,18 @@ local pp_box_on = {
|
|||
}
|
||||
|
||||
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
|
||||
|
||||
-- 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
|
||||
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})
|
||||
|
||||
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)
|
||||
-- force deactivation of mesecon two blocks below (hacky)
|
||||
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
|
||||
local objpos = obj:getpos()
|
||||
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)
|
||||
-- force activation of mesecon two blocks below (hacky)
|
||||
mesecon:turnon(two_below)
|
||||
|
@ -71,7 +71,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
|
|||
state = mesecon.state.off
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -91,7 +91,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
|
|||
state = mesecon.state.on
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
|
||||
|
|
|
@ -64,10 +64,10 @@ minetest.register_abm(
|
|||
interval = 1,
|
||||
chance = 1,
|
||||
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
|
||||
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)
|
||||
end
|
||||
end,
|
||||
|
@ -78,10 +78,10 @@ minetest.register_abm(
|
|||
interval = 1,
|
||||
chance = 1,
|
||||
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
|
||||
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)
|
||||
end
|
||||
end,
|
||||
|
@ -155,10 +155,10 @@ minetest.register_abm(
|
|||
interval = 1,
|
||||
chance = 1,
|
||||
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
|
||||
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)
|
||||
end
|
||||
end,
|
||||
|
@ -169,10 +169,10 @@ minetest.register_abm(
|
|||
interval = 1,
|
||||
chance = 1,
|
||||
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
|
||||
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)
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -35,13 +35,13 @@ local signs_yard = {
|
|||
local sign_groups = {choppy=2, dig_immediate=2}
|
||||
|
||||
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("infotext", "")
|
||||
end
|
||||
|
||||
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
|
||||
if v:get_entity_name() == "signs:text" then
|
||||
v:remove()
|
||||
|
@ -50,7 +50,7 @@ local destruct_sign = function(pos)
|
|||
end
|
||||
|
||||
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")
|
||||
meta:set_string("infotext", "")
|
||||
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 "")
|
||||
end
|
||||
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
|
||||
if v:get_entity_name() == "signs:text" then
|
||||
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
|
||||
local sign_info
|
||||
if minetest.env:get_node(pos).name == "signs:sign_yard" then
|
||||
sign_info = signs_yard[minetest.env:get_node(pos).param2 + 1]
|
||||
elseif minetest.env:get_node(pos).name == "signs:sign_wall" then
|
||||
sign_info = signs[minetest.env:get_node(pos).param2 + 1]
|
||||
if minetest.get_node(pos).name == "signs:sign_yard" then
|
||||
sign_info = signs_yard[minetest.get_node(pos).param2 + 1]
|
||||
elseif minetest.get_node(pos).name == "signs:sign_wall" then
|
||||
sign_info = signs[minetest.get_node(pos).param2 + 1]
|
||||
end
|
||||
if sign_info == nil then
|
||||
return
|
||||
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,
|
||||
z = pos.z + sign_info.delta.z}, "signs:text")
|
||||
text:setyaw(sign_info.yaw)
|
||||
|
@ -122,18 +122,18 @@ minetest.register_node("signs:sign_wall", {
|
|||
local sign_info
|
||||
if wdir == 0 then
|
||||
--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()
|
||||
return itemstack
|
||||
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]
|
||||
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]
|
||||
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,
|
||||
z = above.z + sign_info.delta.z}, "signs:text")
|
||||
text:setyaw(sign_info.yaw)
|
||||
|
@ -191,7 +191,7 @@ minetest.register_entity("signs:text", {
|
|||
textures = {},
|
||||
|
||||
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")
|
||||
self.object:set_properties({textures={generate_texture(create_lines(text))}})
|
||||
end
|
||||
|
|
|
@ -44,10 +44,10 @@ local THROWING_ARROW_ENTITY={
|
|||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.env:get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
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
|
||||
if obj:get_luaentity() ~= nil 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 node.name ~= "air" then
|
||||
minetest.env:add_item(self.lastpos, 'throwing:arrow')
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow')
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
player:get_inventory():remove_item("main", arrow[1])
|
||||
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()
|
||||
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})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function spawn_tnt(pos, entname)
|
||||
minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,})
|
||||
return minetest.env:add_entity(pos, entname)
|
||||
return minetest.add_entity(pos, entname)
|
||||
end
|
||||
|
||||
function activate_if_tnt(nname, np, tnt_np, tntr)
|
||||
|
@ -11,7 +11,7 @@ function activate_if_tnt(nname, np, tnt_np, tntr)
|
|||
end
|
||||
|
||||
function do_tnt_physics(tnt_np,tntr)
|
||||
local objs = minetest.env:get_objects_inside_radius(tnt_np, tntr)
|
||||
local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
|
||||
for k, obj in pairs(objs) do
|
||||
local oname = obj:get_entity_name()
|
||||
local v = obj:getvelocity()
|
||||
|
@ -43,7 +43,7 @@ minetest.register_node("tnt:tnt", {
|
|||
description = "TNT",
|
||||
mesecons = {effector = {
|
||||
action_on = (function(p, node)
|
||||
minetest.env:remove_node(p)
|
||||
minetest.remove_node(p)
|
||||
spawn_tnt(p, "tnt:tnt")
|
||||
nodeupdate(p)
|
||||
end),
|
||||
|
@ -53,7 +53,7 @@ minetest.register_node("tnt:tnt", {
|
|||
|
||||
minetest.register_on_punchnode(function(p, node)
|
||||
if node.name == "tnt:tnt" then
|
||||
minetest.env:remove_node(p)
|
||||
minetest.remove_node(p)
|
||||
spawn_tnt(p, "tnt:tnt")
|
||||
nodeupdate(p)
|
||||
end
|
||||
|
@ -102,9 +102,9 @@ function TNT:on_step(dtime)
|
|||
pos.y = math.floor(pos.y+0.5)
|
||||
pos.z = math.floor(pos.z+0.5)
|
||||
do_tnt_physics(pos, TNT_RANGE)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.sound_play("tnt_explode", {pos = pos,gain = 1.0,max_hear_distance = 16,})
|
||||
if minetest.env:get_node(pos).name == "default:water_source" or minetest.env:get_node(pos).name == "default:water_flowing" or minetest.env:get_node(pos).name == "default:bedrock" or minetest.env:get_node(pos).name == "protector:display" or minetest.is_protected(pos, "tnt") then
|
||||
if minetest.get_node(pos).name == "default:water_source" or minetest.get_node(pos).name == "default:water_flowing" or minetest.get_node(pos).name == "default:bedrock" or minetest.get_node(pos).name == "protector:display" or minetest.is_protected(pos, "tnt") then
|
||||
-- Cancel the Explosion
|
||||
self.object:remove()
|
||||
return
|
||||
|
@ -114,17 +114,17 @@ function TNT:on_step(dtime)
|
|||
for z=-TNT_RANGE,TNT_RANGE do
|
||||
if x*x+y*y+z*z <= TNT_RANGE * TNT_RANGE + TNT_RANGE then
|
||||
local np={x=pos.x+x,y=pos.y+y,z=pos.z+z}
|
||||
local n = minetest.env:get_node(np)
|
||||
local n = minetest.get_node(np)
|
||||
if n.name ~= "air" and n.name ~= "default:obsidian" and n.name ~= "default:bedrock" and n.name ~= "protector:protect" then
|
||||
activate_if_tnt(n.name, np, pos, 3)
|
||||
minetest.env:remove_node(np)
|
||||
minetest.remove_node(np)
|
||||
nodeupdate(np)
|
||||
if n.name ~= "tnt:tnt" and math.random() > 0.9 then
|
||||
local drop = minetest.get_node_drops(n.name, "")
|
||||
for _,item in ipairs(drop) do
|
||||
if type(item) == "string" then
|
||||
if math.random(1,100) > 40 then
|
||||
local obj = minetest.env:add_item(np, item)
|
||||
local obj = minetest.add_item(np, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ local directions = {
|
|||
}
|
||||
|
||||
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
|
||||
thisnode.name:find("wallet:wallmossy") ~= 1 then
|
||||
|
@ -32,14 +32,14 @@ local function update_wall(pos)
|
|||
-- Neighbouring walkable nodes
|
||||
for i = 1, 4 do
|
||||
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
|
||||
sum = sum + 2 ^ (i - 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- 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 minetest.registered_nodes[upnode.name].walkable or upnode.name == "torches:floor" then
|
||||
sum = sum + 11
|
||||
|
@ -50,7 +50,7 @@ local function update_wall(pos)
|
|||
sum = 15
|
||||
end]]
|
||||
|
||||
minetest.env:add_node(pos, {name = basename..sum})
|
||||
minetest.add_node(pos, {name = basename..sum})
|
||||
end
|
||||
|
||||
function update_wall_global(pos)
|
||||
|
|
Loading…
Reference in New Issue
Block a user