Replace minetest.env: with minetest.

This commit is contained in:
PilzAdam 2013-05-25 00:40:03 +02:00
parent dfad095884
commit 31a74ede18
13 changed files with 169 additions and 169 deletions

View File

@ -2,7 +2,7 @@
-- See README.txt for licensing and other information.
local function is_owner(pos, name)
local owner = minetest.env:get_meta(pos):get_string("owner")
local owner = minetest.get_meta(pos):get_string("owner")
if owner == "" or owner == name then
return true
end
@ -26,7 +26,7 @@ minetest.register_node("bones:bones", {
}),
can_dig = function(pos, player)
local inv = minetest.env:get_meta(pos):get_inventory()
local inv = minetest.get_meta(pos):get_inventory()
return is_owner(pos, player:get_player_name()) and inv:is_empty("main")
end,
@ -49,7 +49,7 @@ minetest.register_node("bones:bones", {
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
if meta:get_string("owner") ~= "" and meta:get_inventory():is_empty("main") then
meta:set_string("infotext", meta:get_string("owner").."'s old bones")
meta:set_string("formspec", "")
@ -58,7 +58,7 @@ minetest.register_node("bones:bones", {
end,
on_timer = function(pos, elapsed)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local time = meta:get_int("time")+elapsed
local publish = 1200
if tonumber(minetest.setting_get("share_bones_time")) then
@ -87,7 +87,7 @@ minetest.register_on_dieplayer(function(player)
pos.z = math.floor(pos.z+0.5)
local param2 = minetest.dir_to_facedir(player:get_look_dir())
local nn = minetest.env:get_node(pos).name
local nn = minetest.get_node(pos).name
if minetest.registered_nodes[nn].can_dig and
not minetest.registered_nodes[nn].can_dig(pos, player) then
local player_inv = player:get_inventory()
@ -101,10 +101,10 @@ minetest.register_on_dieplayer(function(player)
return
end
minetest.env:dig_node(pos)
minetest.env:add_node(pos, {name="bones:bones", param2=param2})
minetest.dig_node(pos)
minetest.add_node(pos, {name="bones:bones", param2=param2})
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local player_inv = player:get_inventory()
inv:set_size("main", 8*4)
@ -125,6 +125,6 @@ minetest.register_on_dieplayer(function(player)
meta:set_string("owner", player:get_player_name())
meta:set_int("time", 0)
local timer = minetest.env:get_node_timer(pos)
local timer = minetest.get_node_timer(pos)
timer:start(10)
end)

View File

@ -47,7 +47,7 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
local place_liquid = function(pos, node, source, flowing, fullness)
if math.floor(fullness/128) == 1 or (not minetest.setting_getbool("liquid_finite")) then
minetest.env:add_node(pos, {name=source, param2=fullness})
minetest.add_node(pos, {name=source, param2=fullness})
return
elseif node.name == flowing then
fullness = fullness + node.param2
@ -56,14 +56,14 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
end
if fullness >= LIQUID_MAX then
minetest.env:add_node(pos, {name=source, param2=LIQUID_MAX})
minetest.add_node(pos, {name=source, param2=LIQUID_MAX})
else
minetest.env:add_node(pos, {name=flowing, param2=fullness})
minetest.add_node(pos, {name=flowing, param2=fullness})
end
end
-- Check if pointing to a buildable node
local node = minetest.env:get_node(pointed_thing.under)
local node = minetest.get_node(pointed_thing.under)
local fullness = tonumber(itemstack:get_metadata())
if not fullness then fullness = LIQUID_MAX end
@ -73,7 +73,7 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
else
-- not buildable to; place the liquid above
-- check if the node above can be replaced
local node = minetest.env:get_node(pointed_thing.above)
local node = minetest.get_node(pointed_thing.above)
if minetest.registered_nodes[node.name].buildable_to then
place_liquid(pointed_thing.above, node, source, flowing, fullness)
else
@ -98,12 +98,12 @@ minetest.register_craftitem("bucket:bucket_empty", {
return
end
-- Check if pointing to a liquid source
node = minetest.env:get_node(pointed_thing.under)
node = minetest.get_node(pointed_thing.under)
liquiddef = bucket.liquids[node.name]
if liquiddef ~= nil and liquiddef.itemname ~= nil and (node.name == liquiddef.source or
(node.name == liquiddef.flowing and minetest.setting_getbool("liquid_finite"))) then
minetest.env:add_node(pointed_thing.under, {name="air"})
minetest.add_node(pointed_thing.under, {name="air"})
if node.name == liquiddef.source then node.param2 = LIQUID_MAX end
return ItemStack({name = liquiddef.itemname, metadata = tostring(node.param2)})

View File

@ -123,11 +123,11 @@ minetest.register_on_punchnode(on_punchnode)
--
default.cool_lava_source = function(pos)
minetest.env:set_node(pos, {name="default:obsidian"})
minetest.set_node(pos, {name="default:obsidian"})
end
default.cool_lava_flowing = function(pos)
minetest.env:set_node(pos, {name="default:stone"})
minetest.set_node(pos, {name="default:stone"})
end
minetest.register_abm({
@ -161,17 +161,17 @@ minetest.register_abm({
chance = 20,
action = function(pos, node)
pos.y = pos.y-1
local name = minetest.env:get_node(pos).name
local name = minetest.get_node(pos).name
if minetest.get_item_group(name, "sand") ~= 0 then
pos.y = pos.y+1
local height = 0
while minetest.env:get_node(pos).name == "default:cactus" and height < 4 do
while minetest.get_node(pos).name == "default:cactus" and height < 4 do
height = height+1
pos.y = pos.y+1
end
if height < 4 then
if minetest.env:get_node(pos).name == "air" then
minetest.env:set_node(pos, {name="default:cactus"})
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:cactus"})
end
end
end
@ -185,20 +185,20 @@ minetest.register_abm({
chance = 20,
action = function(pos, node)
pos.y = pos.y-1
local name = minetest.env:get_node(pos).name
local name = minetest.get_node(pos).name
if name == "default:dirt" or name == "default:dirt_with_grass" then
if minetest.env:find_node_near(pos, 3, {"group:water"}) == nil then
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return
end
pos.y = pos.y+1
local height = 0
while minetest.env:get_node(pos).name == "default:papyrus" and height < 4 do
while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
height = height+1
pos.y = pos.y+1
end
if height < 4 then
if minetest.env:get_node(pos).name == "air" then
minetest.env:set_node(pos, {name="default:papyrus"})
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:papyrus"})
end
end
end
@ -246,7 +246,7 @@ minetest.register_abm({
--print("not groups.leafdecay")
return
end
local n0 = minetest.env:get_node(p0)
local n0 = minetest.get_node(p0)
if n0.param2 ~= 0 then
--print("param2 ~= 0")
return
@ -256,7 +256,7 @@ minetest.register_abm({
p0_hash = minetest.hash_node_position(p0)
local trunkp = default.leafdecay_trunk_cache[p0_hash]
if trunkp then
local n = minetest.env:get_node(trunkp)
local n = minetest.get_node(trunkp)
local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing work at the border of the active area
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
@ -274,7 +274,7 @@ minetest.register_abm({
default.leafdecay_trunk_find_allow_accumulator =
default.leafdecay_trunk_find_allow_accumulator - 1
-- Assume ignore is a trunk, to make the thing work at the border of the active area
local p1 = minetest.env:find_node_near(p0, d, {"ignore", "group:tree"})
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
if p1 then
do_preserve = true
if default.leafdecay_enable_cache then
@ -294,11 +294,11 @@ minetest.register_abm({
y = p0.y - 0.5 + math.random(),
z = p0.z - 0.5 + math.random(),
}
minetest.env:add_item(p_drop, itemname)
minetest.add_item(p_drop, itemname)
end
end
-- Remove node
minetest.env:remove_node(p0)
minetest.remove_node(p0)
nodeupdate(p0)
end
end

View File

@ -300,8 +300,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
@ -315,10 +315,10 @@ end
function default.make_papyrus(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:papyrus"})
minetest.set_node(p, {name="default:papyrus"})
else
return
end
@ -328,10 +328,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
@ -356,11 +356,11 @@ function default.make_nyancat(pos, facedir, length)
tailvec.z = 1
end
local p = {x=pos.x, y=pos.y, z=pos.z}
minetest.env:set_node(p, {name="default:nyancat", param2=facedir})
minetest.set_node(p, {name="default:nyancat", param2=facedir})
for i=1,length do
p.x = p.x + tailvec.x
p.z = p.z + tailvec.z
minetest.env:set_node(p, {name="default:nyancat_rainbow"})
minetest.set_node(p, {name="default:nyancat_rainbow"})
end
end
@ -396,17 +396,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
@ -414,8 +414,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" 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" then
minetest.set_node({x=cx+x1,y=0,z=cz+z1}, {name="default:clay"})
end
end
end
@ -424,7 +424,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
-- Generate papyrus
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;
@ -441,15 +441,15 @@ minetest.register_on_generated(function(minp, maxp, seed)
for i=0,papyrus_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_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
end
end
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;
@ -469,20 +469,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 = 16
local divs = (maxp.x-minp.x)/divlen+1;
@ -502,7 +502,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
@ -510,18 +510,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_"..pr:next(1, 5)})
minetest.set_node(p,{name="default:grass_"..pr:next(1, 5)})
end
end
end

View File

@ -584,14 +584,14 @@ minetest.register_node("default:sign_wall", {
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
on_construct = function(pos)
--local n = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
--local n = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[text;;${text}]")
meta:set_string("infotext", "\"\"")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
fields.text = fields.text or ""
print((sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos))
@ -609,7 +609,7 @@ minetest.register_node("default:chest", {
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
"list[current_name;main;0,0;8,4;]"..
@ -619,7 +619,7 @@ minetest.register_node("default:chest", {
inv:set_size("main", 8*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()
return inv:is_empty("main")
end,
@ -653,25 +653,25 @@ minetest.register_node("default:chest_locked", {
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Locked Chest (owned by "..
meta:get_string("owner")..")")
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Locked Chest")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 8*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()
return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
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)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
@ -682,7 +682,7 @@ minetest.register_node("default:chest_locked", {
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
@ -693,7 +693,7 @@ minetest.register_node("default:chest_locked", {
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
minetest.log("action", player:get_player_name()..
" tried to access a locked chest belonging to "..
@ -716,7 +716,7 @@ minetest.register_node("default:chest_locked", {
" takes stuff from locked chest at "..minetest.pos_to_string(pos))
end,
on_rightclick = function(pos, node, clicker)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
if has_locked_chest_privilege(meta, clicker) then
local pos = pos.x .. "," .. pos.y .. "," ..pos.z
minetest.show_formspec(clicker:get_player_name(), "default:chest_locked",
@ -744,7 +744,7 @@ minetest.register_node("default:furnace", {
legacy_facedir_simple = true,
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()
@ -753,7 +753,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
@ -765,7 +765,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
@ -783,7 +783,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
@ -814,7 +814,7 @@ minetest.register_node("default:furnace_active", {
legacy_facedir_simple = true,
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()
@ -823,7 +823,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
@ -835,7 +835,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
@ -853,7 +853,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
@ -874,16 +874,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
@ -892,7 +892,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",
@ -1129,7 +1129,7 @@ minetest.register_node("default:apple", {
sounds = default.node_sound_defaults(),
after_place_node = function(pos, placer, itemstack)
if placer:is_player() then
minetest.env:set_node(pos, {name="default:apple", param2=1})
minetest.set_node(pos, {name="default:apple", param2=1})
end
end,
})
@ -1280,8 +1280,8 @@ minetest.register_node("default:snow", {
}),
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,
})

View File

@ -43,7 +43,7 @@ function doors:register_door(name, def)
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
@ -52,8 +52,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
@ -71,20 +71,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", pn)
meta:set_string("infotext", "Owned by "..pn)
meta = minetest.env:get_meta(pt2)
meta = minetest.get_meta(pt2)
meta:set_string("doors_owner", pn)
meta:set_string("infotext", "Owned by "..pn)
end
@ -100,34 +100,34 @@ 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 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

View File

@ -28,28 +28,28 @@ minetest.register_abm({
chance = 4,
action = function(pos, node)
pos.y = pos.y+1
local nn = minetest.env:get_node(pos).name
local nn = minetest.get_node(pos).name
pos.y = pos.y-1
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
minetest.env:set_node(pos, {name="default:dirt"})
minetest.set_node(pos, {name="default:dirt"})
end
-- check if there is water nearby
if minetest.env:find_node_near(pos, 3, {"group:water"}) then
if minetest.find_node_near(pos, 3, {"group:water"}) then
-- if it is dry soil turn it into wet soil
if node.name == "farming:soil" then
minetest.env:set_node(pos, {name="farming:soil_wet"})
minetest.set_node(pos, {name="farming:soil_wet"})
end
else
-- turn it back into dirt if it is already dry
if node.name == "farming:soil" then
-- only turn it back if there is no plant on top of it
if minetest.get_item_group(nn, "plant") == 0 then
minetest.env:set_node(pos, {name="default:dirt"})
minetest.set_node(pos, {name="default:dirt"})
end
-- if its wet turn it back into dry soil
elseif node.name == "farming:soil_wet" then
minetest.env:set_node(pos, {name="farming:soil"})
minetest.set_node(pos, {name="farming:soil"})
end
end
end,
@ -69,9 +69,9 @@ local function hoe_on_use(itemstack, user, pointed_thing, uses)
return
end
local under = minetest.env:get_node(pt.under)
local under = minetest.get_node(pt.under)
local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z}
local above = minetest.env:get_node(p)
local above = minetest.get_node(p)
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
@ -92,7 +92,7 @@ local function hoe_on_use(itemstack, user, pointed_thing, uses)
end
-- turn the node into soil, wear out item and play sound
minetest.env:set_node(pt.under, {name="farming:soil"})
minetest.set_node(pt.under, {name="farming:soil"})
minetest.sound_play("default_dig_crumbly", {
pos = pt.under,
gain = 0.5,
@ -273,8 +273,8 @@ local function place_seed(itemstack, placer, pointed_thing, plantname)
return
end
local under = minetest.env:get_node(pt.under)
local above = minetest.env:get_node(pt.above)
local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
@ -300,7 +300,7 @@ local function place_seed(itemstack, placer, pointed_thing, plantname)
end
-- add the node and remove 1 item from the itemstack
minetest.env:add_node(pt.above, {name=plantname})
minetest.add_node(pt.above, {name=plantname})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
@ -386,23 +386,23 @@ minetest.register_abm({
-- check if on wet soil
pos.y = pos.y-1
local n = minetest.env:get_node(pos)
local n = minetest.get_node(pos)
if minetest.get_item_group(n.name, "soil") < 3 then
return
end
pos.y = pos.y+1
-- check light
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) < 13 then
if minetest.get_node_light(pos) < 13 then
return
end
-- grow
local height = minetest.get_item_group(node.name, "wheat") + 1
minetest.env:set_node(pos, {name="farming:wheat_"..height})
minetest.set_node(pos, {name="farming:wheat_"..height})
end
})
@ -471,22 +471,22 @@ minetest.register_abm({
-- check if on wet soil
pos.y = pos.y-1
local n = minetest.env:get_node(pos)
local n = minetest.get_node(pos)
if minetest.get_item_group(n.name, "soil") < 3 then
return
end
pos.y = pos.y+1
-- check light
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) < 13 then
if minetest.get_node_light(pos) < 13 then
return
end
-- grow
local height = minetest.get_item_group(node.name, "cotton") + 1
minetest.env:set_node(pos, {name="farming:cotton_"..height})
minetest.set_node(pos, {name="farming:cotton_"..height})
end
})

View File

@ -47,7 +47,7 @@ end
function fire.update_sounds_around(pos)
local p0, p1 = fire.get_area_p0p1(pos)
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
local flames_p = minetest.env:find_nodes_in_area(p0, p1, {"fire:basic_flame"})
local flames_p = minetest.find_nodes_in_area(p0, p1, {"fire:basic_flame"})
--print("number of flames at "..minetest.pos_to_string(p0).."/"
-- ..minetest.pos_to_string(p1)..": "..#flames_p)
local should_have_sound = (#flames_p > 0)
@ -91,15 +91,15 @@ function fire.on_flame_remove_at(pos)
end
function fire.find_pos_for_flame_around(pos)
return minetest.env:find_node_near(pos, 1, {"air"})
return minetest.find_node_near(pos, 1, {"air"})
end
function fire.flame_should_extinguish(pos)
if minetest.setting_getbool("disable_fire") then return true end
--return minetest.env:find_node_near(pos, 1, {"group:puts_out_fire"})
--return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
local ps = minetest.env:find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
local ps = minetest.find_nodes_in_area(p0, p1, {"group:puts_out_fire"})
return (#ps ~= 0)
end
@ -116,7 +116,7 @@ minetest.register_abm({
end
local p = fire.find_pos_for_flame_around(p0)
if p then
minetest.env:set_node(p, {name="fire:basic_flame"})
minetest.set_node(p, {name="fire:basic_flame"})
fire.on_flame_add_at(p)
end
end,
@ -134,7 +134,7 @@ minetest.register_abm({
return
end
local d = reg.groups.igniter
local p = minetest.env:find_node_near(p0, d, {"group:flammable"})
local p = minetest.find_node_near(p0, d, {"group:flammable"})
if p then
-- If there is water or stuff like that around flame, don't ignite
if fire.flame_should_extinguish(p) then
@ -142,7 +142,7 @@ minetest.register_abm({
end
local p2 = fire.find_pos_for_flame_around(p)
if p2 then
minetest.env:set_node(p2, {name="fire:basic_flame"})
minetest.set_node(p2, {name="fire:basic_flame"})
fire.on_flame_add_at(p2)
end
end
@ -157,7 +157,7 @@ minetest.register_abm({
action = function(p0, node, _, _)
-- If there is water or stuff like that around flame, remove flame
if fire.flame_should_extinguish(p0) then
minetest.env:remove_node(p0)
minetest.remove_node(p0)
fire.on_flame_remove_at(p0)
return
end
@ -166,25 +166,25 @@ minetest.register_abm({
return
end
-- If there are no flammable nodes around flame, remove flame
if not minetest.env:find_node_near(p0, 1, {"group:flammable"}) then
minetest.env:remove_node(p0)
if not minetest.find_node_near(p0, 1, {"group:flammable"}) then
minetest.remove_node(p0)
fire.on_flame_remove_at(p0)
return
end
if math.random(1,4) == 1 then
-- remove a flammable node around flame
local p = minetest.env:find_node_near(p0, 1, {"group:flammable"})
local p = minetest.find_node_near(p0, 1, {"group:flammable"})
if p then
-- If there is water or stuff like that around flame, don't remove
if fire.flame_should_extinguish(p0) then
return
end
minetest.env:remove_node(p)
minetest.remove_node(p)
nodeupdate(p)
end
else
-- remove flame
minetest.env:remove_node(p0)
minetest.remove_node(p0)
fire.on_flame_remove_at(p0)
end
end,

View File

@ -127,40 +127,40 @@ minetest.register_abm({
chance = 25,
action = function(pos, node)
pos.y = pos.y - 1
local under = minetest.env:get_node(pos)
local under = minetest.get_node(pos)
pos.y = pos.y + 1
if under.name == "default:desert_sand" then
minetest.env:set_node(pos, {name="default:dry_shrub"})
minetest.set_node(pos, {name="default:dry_shrub"})
elseif under.name ~= "default:dirt_with_grass" then
return
end
local light = minetest.env:get_node_light(pos)
local light = minetest.get_node_light(pos)
if not light or light < 13 then
return
end
local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4}
local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4}
if #minetest.env:find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
if #minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
return
end
local flowers = minetest.env:find_nodes_in_area(pos0, pos1, "group:flora")
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
if #flowers > 3 then
return
end
local seedling = minetest.env:find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
local seedling = minetest.find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
if #seedling > 0 then
seedling = seedling[math.random(#seedling)]
seedling.y = seedling.y + 1
light = minetest.env:get_node_light(seedling)
light = minetest.get_node_light(seedling)
if not light or light < 13 then
return
end
if minetest.env:get_node(seedling).name == "air" then
minetest.env:set_node(seedling, {name=node.name})
if minetest.get_node(seedling).name == "air" then
minetest.set_node(seedling, {name=node.name})
end
end
end,

View File

@ -1,7 +1,7 @@
minetest.register_on_generated(function(minp, maxp, seed)
if maxp.y >= 2 and minp.y <= 0 then
-- Generate flowers
local perlin1 = minetest.env:get_perlin(436, 3, 0.6, 100)
local perlin1 = minetest.get_perlin(436, 3, 0.6, 100)
-- Assume X and Z lengths are equal
local divlen = 16
local divs = (maxp.x-minp.x)/divlen+1;
@ -21,7 +21,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
@ -29,11 +29,11 @@ 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 nn == "default:dirt_with_grass" then
local flower_choice = pr:next(1, 6)
local flower
@ -50,7 +50,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
elseif flower_choice == 6 then
flower = "flowers:viola"
end
minetest.env:set_node(p, {name=flower})
minetest.set_node(p, {name=flower})
end
end
end

View File

@ -79,14 +79,14 @@ minetest.register_craftitem(":rat", {
description = "Rat",
inventory_image = "rat.png",
on_drop = function(item, dropper, pos)
minetest.env:add_rat(pos)
minetest.add_rat(pos)
item:take_item()
return item
end,
on_place = function(item, dropped, pointed)
pos = minetest.get_pointed_thing_position(pointed, true)
if pos ~= nil then
minetest.env:add_rat(pos)
minetest.add_rat(pos)
item:take_item()
return item
end
@ -104,14 +104,14 @@ minetest.register_craftitem(":firefly", {
inventory_image = "firefly.png",
groups = {not_in_creative_inventory=1},
on_drop = function(item, dropper, pos)
minetest.env:add_firefly(pos)
minetest.add_firefly(pos)
item:take_item()
return item
end,
on_place = function(item, dropped, pointed)
pos = minetest.get_pointed_thing_position(pointed, true)
if pos ~= nil then
minetest.env:add_firefly(pos)
minetest.add_firefly(pos)
item:take_item()
return item
end

View File

@ -61,7 +61,7 @@ function screwdriver_handler (itemstack,user,pointed_thing)
local mode=tonumber((item["metadata"]))
if pointed_thing.type~="node" then return end
local pos=minetest.get_pointed_thing_position(pointed_thing,above)
local node=minetest.env:get_node(pos)
local node=minetest.get_node(pos)
local node_name=node.name
if minetest.registered_nodes[node_name].paramtype2 == "facedir" then
if minetest.registered_nodes[node_name].drawtype == "nodebox" then
@ -113,11 +113,11 @@ function screwdriver_handler (itemstack,user,pointed_thing)
end
end
--print (dump(axisdir..", "..rotation))
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local meta0 = meta:to_table()
node.param2 = n
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)
local item=itemstack:to_table()
local item_wear=tonumber((item["wear"]))

View File

@ -105,7 +105,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
local slabnode = nil
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local n0 = minetest.env:get_node(p0)
local n0 = minetest.get_node(p0)
if n0.name == "stairs:slab_" .. subname and
p0.y+1 == p1.y then
slabpos = p0
@ -113,7 +113,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
end
if slabpos then
-- Remove the slab at slabpos
minetest.env:remove_node(slabpos)
minetest.remove_node(slabpos)
-- Make a fake stack of a single item and try to place it
local fakestack = ItemStack(recipeitem)
pointed_thing.above = slabpos
@ -123,7 +123,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
itemstack:take_item(1)
-- Else put old node back
else
minetest.env:set_node(slabpos, slabnode)
minetest.set_node(slabpos, slabnode)
end
return itemstack
end
@ -133,7 +133,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
-- Turn into full block if pointing at a existing slab
if n0.name == "stairs:slab_" .. subname.."upside_down" then
-- Remove the slab at the position of the slab
minetest.env:remove_node(p0)
minetest.remove_node(p0)
-- Make a fake stack of a single item and try to place it
local fakestack = ItemStack(recipeitem)
pointed_thing.above = p0
@ -143,7 +143,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
itemstack:take_item(1)
-- Else put old node back
else
minetest.env:set_node(p0, n0)
minetest.set_node(p0, n0)
end
return itemstack
end