Replaced all minetest.env: with the newer minetest.

This commit is contained in:
DanDuncombe 2013-10-27 16:59:41 +00:00 committed by Vanessa Ezekowitz
parent 88d235e1b7
commit 4100ef7061
28 changed files with 255 additions and 255 deletions

View File

@ -189,7 +189,7 @@ for _, anvil in ipairs(anvils) do
groups = {oddly_breakable_by_hand=2, falling_node=1, dig_immediate=1},
sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if inv:is_empty("src1") and inv:is_empty("src2") and inv:is_empty("hammer")
and inv:is_empty("output") and inv:is_empty("flux") then
@ -198,7 +198,7 @@ for _, anvil in ipairs(anvils) do
return false
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[8,7]"..
"button[0.5,0.25;1.35,1;buttonForge;Forge]"..
"button[1.6,0.25;0.9,1;buttonForge10;x10]"..
@ -220,7 +220,7 @@ for _, anvil in ipairs(anvils) do
inv:set_size("flux", 1)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local src1, src2 = inv:get_stack("src1", 1), inv:get_stack("src2", 1)

View File

@ -42,7 +42,7 @@ minetest.register_node("bonfire:self", {
drop = "",
groups = {crumbly=3, oddly_breakable_by_hand=1, not_in_creative_inventory=1},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", bonfire.formspec)
meta:set_string("infotext", "Bonfire")
meta:set_int("active", 0)
@ -52,7 +52,7 @@ minetest.register_node("bonfire:self", {
inv:set_size("dst", 2)
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 inv:is_empty("fuel") and inv:is_empty("src") and inv:is_empty("dst") then
return true
@ -83,7 +83,7 @@ minetest.register_node("bonfire:self_active", {
drop = "",
groups = {igniter=1,crumbly=3, not_in_creative_inventory=1,fires=1},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", bonfire.formspec)
meta:set_string("infotext", "Bonfire")
meta:set_int("active", 0)
@ -93,7 +93,7 @@ minetest.register_node("bonfire:self_active", {
inv:set_size("dst", 2)
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 inv:is_empty("fuel") and inv:is_empty("src") and inv:is_empty("dst") then
return true
@ -107,7 +107,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",

View File

@ -19,7 +19,7 @@ else
local count = ItemStack(item):get_count()
local name = ItemStack(item):get_name()
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 k = 1
@ -43,7 +43,7 @@ else
drop(item)
end
end
if ALWAYS_DROP_NODES_AS_ITEMS and minetest.get_node_group(minetest.env:get_node(pos).name, "drop_on_dig") == 1 then
if ALWAYS_DROP_NODES_AS_ITEMS and minetest.get_node_group(minetest.get_node(pos).name, "drop_on_dig") == 1 then
drop_all()
elseif digger and digger:get_inventory() then
for _, dropped_item in ipairs(drops) do

View File

@ -3,7 +3,7 @@ function minetest.register_node(name, nodedef)
if not nodedef.cause_drop then
nodedef.cause_drop = function(pos, node)
local b_pos = {x=pos.x,y=pos.y-1,z=pos.z}
local b_node = minetest.env:get_node(b_pos)
local b_node = minetest.get_node(b_pos)
if minetest.registered_nodes[b_node.name].falling_node_walkable == false or
minetest.registered_nodes[b_node.name].buildable_to then
return true
@ -13,7 +13,7 @@ function minetest.register_node(name, nodedef)
if not nodedef.cause_fall then
nodedef.cause_fall = function(pos, node)
local b_pos = {x=pos.x,y=pos.y-1,z=pos.z}
local b_node = minetest.env:get_node(b_pos)
local b_node = minetest.get_node(b_pos)
if minetest.registered_nodes[b_node.name].falling_node_walkable == false or
minetest.registered_nodes[b_node.name].buildable_to then
return true
@ -34,7 +34,7 @@ minetest.register_on_updatenode = realtest.register_on_updatenode
function nodeupdate_single(pos)
for _, callback in ipairs(realtest.registered_on_updatenodes) do
local node = minetest.env:get_node(pos)
local node = minetest.get_node(pos)
callback(pos, node)
end
end
@ -53,14 +53,14 @@ end
realtest.register_on_updatenode(function(pos, node)
if minetest.get_node_group(node.name, "dropping_node") ~= 0 then
if minetest.registered_nodes[node.name].cause_drop(pos, node) then
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
if minetest.registered_nodes[node.name].on_dropping then
minetest.registered_nodes[node.name].on_dropping(pos, node)
else
local drops = minetest.registered_nodes[node.name].drop_on_dropping or
minetest.registered_nodes[node.name].drop or node.name
if type(drops) == "string" then drops = {drops} end
minetest.env:remove_node(pos)
minetest.remove_node(pos)
minetest.handle_node_drops(pos, drops)
end
if minetest.registered_nodes[node.name].after_dig_node then
@ -72,20 +72,20 @@ realtest.register_on_updatenode(function(pos, node)
end)
realtest.register_on_updatenode(function(pos, node)
local b_node = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z})
local b_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
if minetest.get_node_group(node.name, "dropping_like_stone") ~= 0 and
(minetest.registered_nodes[b_node.name].walkable == false or
minetest.registered_nodes[b_node.name].buildable_to) then
local sides = {{x=-1,y=0,z=0}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=0,y=0,z=1}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}}
local drop = true
for _, s in ipairs(sides) do
if minetest.get_node_group(minetest.env:get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name, "dropping_like_stone") ~= 0 then
if minetest.get_node_group(minetest.get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name, "dropping_like_stone") ~= 0 then
drop = false
break
end
end
if drop then
minetest.env:remove_node({x=pos.x,y=pos.y,z=pos.z})
minetest.remove_node({x=pos.x,y=pos.y,z=pos.z})
minetest.handle_node_drops(pos, {node.name})
nodeupdate(pos)
end
@ -98,7 +98,7 @@ realtest.register_on_updatenode(function(pos, node)
if minetest.registered_nodes[node.name].on_falling then
minetest.registered_nodes[node.name].on_falling(pos, node)
else
minetest.env:remove_node(pos)
minetest.remove_node(pos)
spawn_falling_node(pos, node.name)
end
nodeupdate(pos)
@ -129,7 +129,7 @@ realtest.register_on_updatenode(function(pos, node)
d.y = -1
end
local p2 = {x=p.x+d.x, y=p.y+d.y, z=p.z+d.z}
local nn = minetest.env:get_node(p2).name
local nn = minetest.get_node(p2).name
local def2 = minetest.registered_nodes[nn]
if def2 and (not def2.walkable or def2.buildable_to) then
return false
@ -137,7 +137,7 @@ realtest.register_on_updatenode(function(pos, node)
return true
end
if not check_attached_node(pos, node) then
minetest.env:remove_node(pos)
minetest.remove_node(pos)
minetest.handle_node_drops(pos, minetest.get_node_drops(node.name, nil))
nodeupdate(pos)
end
@ -193,27 +193,27 @@ minetest.register_entity(":__builtin:falling_node", {
-- Turn to actual sand when collides to ground or just move
local pos = self.object:getpos()
local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
local bcn = minetest.env:get_node(bcp)
local bcn = minetest.get_node(bcp)
-- Note: walkable is in the node definition, not in item groups
if minetest.registered_nodes[bcn.name] and
minetest.registered_nodes[bcn.name].falling_node_walkable then
if minetest.registered_nodes[bcn.name].buildable_to then
minetest.env:remove_node(bcp)
minetest.remove_node(bcp)
return
end
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
-- Check what's here
local n2 = minetest.env:get_node(np)
local n2 = minetest.get_node(np)
-- If it's not air or liquid, remove node and replace it with
-- it's drops
if n2.name ~= "air" and (not minetest.registered_nodes[n2.name] or
minetest.registered_nodes[n2.name].liquidtype == "none") then
local drops = minetest.get_node_drops(n2.name, "")
minetest.env:remove_node(np)
minetest.remove_node(np)
-- Add dropped items
local _, dropped_item
for _, dropped_item in ipairs(drops) do
minetest.env:add_item(np, dropped_item)
minetest.add_item(np, dropped_item)
end
-- Run script hook
local _, callback
@ -222,11 +222,11 @@ minetest.register_entity(":__builtin:falling_node", {
end
end
-- Create node and remove entity
minetest.env:add_node(np, {name=self.nodename})
minetest.add_node(np, {name=self.nodename})
self.object:remove()
nodeupdate(np)
else
-- Do nothing
end
end
})
})

View File

@ -28,16 +28,16 @@ function mod_pos(p, dx, dy, dz)
end
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
@ -80,4 +80,4 @@ end
function rshift(x, by)
return math.floor(x / 2 ^ by)
end
end

View File

@ -6,11 +6,11 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
end
local under = pointed_thing.under
local oldnode_under = minetest.env:get_node(under)
local oldnode_under = minetest.get_node(under)
local olddef_under = ItemStack({name=oldnode_under.name}):get_definition()
olddef_under = olddef_under or minetest.nodedef_default
local above = pointed_thing.above
local oldnode_above = minetest.env:get_node(above)
local oldnode_above = minetest.get_node(above)
local olddef_above = ItemStack({name=oldnode_above.name}):get_definition()
olddef_above = olddef_above or minetest.nodedef_default
@ -33,7 +33,7 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
minetest.log("action", placer:get_player_name() .. " places node "
.. def.name .. " at " .. minetest.pos_to_string(place_to))
local oldnode = minetest.env:get_node(place_to)
local oldnode = minetest.get_node(place_to)
local newnode = {name = def.name, param1 = 0, param2 = 0}
-- Calculate direction for wall mounted stuff like torches and signs
@ -59,7 +59,7 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
end
-- Add node and update
minetest.env:add_node(place_to, newnode)
minetest.add_node(place_to, newnode)
local take_item = true
@ -88,4 +88,4 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
itemstack:take_item()
end
return itemstack
end
end

View File

@ -174,7 +174,7 @@ local function add_day()
end
minetest.after(0, function()
seasons.timer = math.floor(minetest.env:get_timeofday() * 1200)
seasons.timer = math.floor(minetest.get_timeofday() * 1200)
local delta = 0
minetest.register_globalstep(function(dtime)
delta = delta + dtime
@ -203,7 +203,7 @@ minetest.register_chatcommand("time", {
if newtime == nil then
minetest.chat_send_player(name, "Invalid time")
else
minetest.env:set_timeofday((newtime % 24000) / 24000)
minetest.set_timeofday((newtime % 24000) / 24000)
seasons.timer = (newtime % 24000) / 20
minetest.chat_send_player(name, "Time of day changed.")
minetest.log("action", name .. " sets time " .. newtime)
@ -217,8 +217,8 @@ minetest.register_chatcommand("calendar", {
privs = {server=true},
func = function(name, param)
minetest.chat_send_player(name, "Date: "..seasons.get_day_of_week().." "..seasons.get_day_of_month().." "..seasons.get_month().." "..seasons.get_year())
local h = math.floor(minetest.env:get_timeofday() * 24)
local m = math.floor((minetest.env:get_timeofday() * 24000 - h * 1000) * 0.06)
local h = math.floor(minetest.get_timeofday() * 24)
local m = math.floor((minetest.get_timeofday() * 24000 - h * 1000) * 0.06)
if m < 10 then
m = "0"..m
end

View File

@ -154,13 +154,13 @@ function realtest.register_slab(name, recipeitem, groups, images, description, s
local p1 = pointed_thing.under
local p2 = pointed_thing.above
local dir = {x=p1.x-p2.x,y=p1.y-p2.y,z=p1.z-p2.z}
if (minetest.env:get_node(pointed_thing.under).name == name.."_slab_r"
and minetest.env:get_node(pointed_thing.under).param2 == minetest.dir_to_wallmounted(dir)) or
(minetest.env:get_node(pointed_thing.under).name == name.."_slab"
and minetest.env:get_node(pointed_thing.under).param2 == 0) then
minetest.env:set_node(pointed_thing.under, {name=name})
elseif minetest.registered_nodes[minetest.env:get_node(pointed_thing.above).name].buildable_to then
minetest.env:set_node(pointed_thing.above, {name=name.."_slab_r", param2=minetest.dir_to_wallmounted(dir)})
if (minetest.get_node(pointed_thing.under).name == name.."_slab_r"
and minetest.get_node(pointed_thing.under).param2 == minetest.dir_to_wallmounted(dir)) or
(minetest.get_node(pointed_thing.under).name == name.."_slab"
and minetest.get_node(pointed_thing.under).param2 == 0) then
minetest.set_node(pointed_thing.under, {name=name})
elseif minetest.registered_nodes[minetest.get_node(pointed_thing.above).name].buildable_to then
minetest.set_node(pointed_thing.above, {name=name.."_slab_r", param2=minetest.dir_to_wallmounted(dir)})
else
return itemstack
end
@ -184,4 +184,4 @@ end
function realtest.register_stair_and_slab(name, recipeitem, groups, images, description, sounds, drop)
realtest.register_stair(name, recipeitem, groups, images, description, sounds, drop)
realtest.register_slab(name, recipeitem, groups, images, description, sounds, drop)
end
end

View File

@ -102,7 +102,7 @@ for _, mineral in ipairs(decor_minerals) do
groups = {snappy=2,oddly_breakable_by_hand=2},
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,8]"..
"list[current_name;main;1,0.5;6,3;]"..
@ -112,7 +112,7 @@ for _, mineral in ipairs(decor_minerals) do
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,
@ -126,7 +126,7 @@ for _, mineral in ipairs(decor_minerals) do
groups = {snappy=2,oddly_breakable_by_hand=2},
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;]"..
@ -136,7 +136,7 @@ for _, mineral in ipairs(decor_minerals) do
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,
@ -157,25 +157,25 @@ for _, mineral in ipairs(decor_minerals) do
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
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", mineral[2].." 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", mineral[2].." 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 player:get_player_name() == meta:get_string("owner")
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 "..
@ -186,7 +186,7 @@ for _, mineral in ipairs(decor_minerals) do
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 "..
@ -197,7 +197,7 @@ for _, mineral in ipairs(decor_minerals) do
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 "..
@ -220,7 +220,7 @@ for _, mineral in ipairs(decor_minerals) do
" 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(),
@ -467,4 +467,4 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
{tree.name.."_plank", tree.name.."_plank", tree.name.."_plank"},
}
})
end
end

View File

@ -316,13 +316,13 @@ minetest.register_abm({
interval = 60,
chance = 30,
action = function(pos, node, active_object_count, active_object_count_wider)
if not minetest.env:get_node_light(pos) or
minetest.env:get_node_light(pos) < 8 then
if not minetest.get_node_light(pos) or
minetest.get_node_light(pos) < 8 then
return
end
local h = 1
repeat
if minetest.env:get_node({x=pos.x,y=pos.y-h,z=pos.z}).name == node.name then
if minetest.get_node({x=pos.x,y=pos.y-h,z=pos.z}).name == node.name then
h = h + 1
else
break
@ -339,9 +339,9 @@ minetest.register_abm({
"default:dirt_with_grass",
"default:dirt_with_grass_and_clay"
}
if minetest.registered_nodes[minetest.env:get_node({x=pos.x,y=pos.y+1,z=pos.z}).name].buildable_to
and table.contains(grounds, minetest.env:get_node({x=pos.x,y=pos.y-h,z=pos.z}).name) then
minetest.env:set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=node.name})
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name].buildable_to
and table.contains(grounds, minetest.get_node({x=pos.x,y=pos.y-h,z=pos.z}).name) then
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=node.name})
end
end
})
@ -351,7 +351,7 @@ minetest.register_abm({
interval = 0.5,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
players = minetest.env:get_objects_inside_radius(pos, 1)
players = minetest.get_objects_inside_radius(pos, 1)
for i, player in ipairs(players) do
player:set_hp(player:get_hp() - 1)
end
@ -372,7 +372,7 @@ minetest.register_node("default:papyrus", {
sounds = default.node_sound_leaves_defaults(),
cause_drop = function(pos, node)
local b_pos = {x=pos.x,y=pos.y-1,z=pos.z}
local b_node = minetest.env:get_node(b_pos)
local b_node = minetest.get_node(b_pos)
if b_node.name ~= node.name and minetest.registered_nodes[b_node.name].walkable == false then
return true
end
@ -384,13 +384,13 @@ minetest.register_abm({
interval = 40,
chance = 20,
action = function(pos, node, active_object_count, active_object_count_wider)
if not minetest.env:get_node_light(pos) or
minetest.env:get_node_light(pos) < 8 then
if not minetest.get_node_light(pos) or
minetest.get_node_light(pos) < 8 then
return
end
local h = 1
repeat
if minetest.env:get_node({x=pos.x,y=pos.y-h,z=pos.z}).name == node.name then
if minetest.get_node({x=pos.x,y=pos.y-h,z=pos.z}).name == node.name then
h = h + 1
else
break
@ -402,7 +402,7 @@ minetest.register_abm({
local sides = {{x=-1,y=-1,z=0},{x=1,y=-1,z=0},{x=0,y=-1,z=-1},{x=0,y=-1,z=1}}
local water = false
for _, side in ipairs(sides) do
if minetest.env:get_node({x=pos.x+side.x,y=pos.y+side.y-h+1,z=pos.z+side.z}).name == "default:water_source" then
if minetest.get_node({x=pos.x+side.x,y=pos.y+side.y-h+1,z=pos.z+side.z}).name == "default:water_source" then
water = true
break
end
@ -415,9 +415,9 @@ minetest.register_abm({
"default:dirt_with_grass",
"default:dirt_with_grass_and_clay"
}
if water and minetest.registered_nodes[minetest.env:get_node({x=pos.x,y=pos.y+1,z=pos.z}).name].buildable_to
and table.contains(grounds, minetest.env:get_node({x=pos.x,y=pos.y-h,z=pos.z}).name) then
minetest.env:set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=node.name})
if water and minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name].buildable_to
and table.contains(grounds, minetest.get_node({x=pos.x,y=pos.y-h,z=pos.z}).name) then
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=node.name})
end
end
})
@ -598,14 +598,14 @@ minetest.register_node("default:sign_wall", {
groups = {choppy=2,dig_immediate=2},
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", "hack:sign_text_input")
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))
@ -704,4 +704,4 @@ function on_punchnode(p, node)
end
minetest.register_on_punchnode(on_punchnode)
-- END
-- END

View File

@ -24,21 +24,21 @@ minetest.register_alias("mapgen_leaves", "air")
function default.make_papyrus(pos, size)
for y=0,size-1 do
local p = {x=pos.x, y=pos.y+y, z=pos.z}
minetest.env:set_node(p, {name="default:papyrus"})
minetest.set_node(p, {name="default:papyrus"})
end
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}
minetest.env:set_node(p, {name="default:cactus"})
minetest.set_node(p, {name="default:cactus"})
end
end
minetest.register_on_generated(function(minp, maxp, seed)
if maxp.y >= 2 and minp.y <= 0 then
-- 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;
@ -55,15 +55,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;
@ -83,20 +83,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 cobbles
local perlin1 = minetest.env:get_perlin(200, 3, 0.6, 100)
local perlin1 = minetest.get_perlin(200, 3, 0.6, 100)
-- Assume X and Z lengths are equal
local divlen = 16
local divs = (maxp.x-minp.x)/divlen+1;
@ -114,19 +114,19 @@ 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 ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:dirt_with_grass" then
minetest.env:add_node({x=x,y=ground_y+1,z=z}, {name = "default:cobble_node"})
if ground_y and minetest.get_node({x=x,y=ground_y,z=z}).name == "default:dirt_with_grass" then
minetest.add_node({x=x,y=ground_y+1,z=z}, {name = "default:cobble_node"})
end
end
end
end
-- Generate dry shrubs
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;
@ -146,14 +146,14 @@ 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
minetest.env:set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
if ground_y and minetest.get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
minetest.set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
end
end
end

View File

@ -46,8 +46,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
@ -65,20 +65,20 @@ function doors:register_door(name, def)
elseif p2 == 3 then
pt3.z = pt3.z-1
end
if minetest.get_item_group(minetest.env:get_node(pt3).name, "door") ~= 1 then
minetest.env:set_node(pt, {name=name.."_b_1", param2=p2})
minetest.env:set_node(pt2, {name=name.."_t_1", param2=p2})
if minetest.get_item_group(minetest.get_node(pt3).name, "door") ~= 1 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
@ -94,34 +94,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
@ -271,4 +271,4 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
burntime = 15,
})
realtest.add_bonfire_fuel("doors:door_"..tree_name:remove_modname_prefix())
end
end

View File

@ -6,18 +6,18 @@ local directions = {
}
local function update_fence(pos)
if minetest.get_node_group(minetest.env:get_node(pos).name, "fence") ~= 1 then
if minetest.get_node_group(minetest.get_node(pos).name, "fence") ~= 1 then
return
end
local sum = 0
for i = 1, 4 do
local node = minetest.env:get_node({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
local node = minetest.get_node({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
if minetest.registered_nodes[node.name].walkable ~= false then
sum = sum + 2 ^ (i - 1)
end
end
local material = realtest.registered_trees_list[minetest.get_node_group(minetest.env:get_node(pos).name, "material")]:remove_modname_prefix()
minetest.env:add_node(pos, {name = "fences:"..material.."_fence_"..sum})
local material = realtest.registered_trees_list[minetest.get_node_group(minetest.get_node(pos).name, "material")]:remove_modname_prefix()
minetest.add_node(pos, {name = "fences:"..material.."_fence_"..sum})
end
local function update_nearby(pos)

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,14 +91,14 @@ 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)
--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
@ -115,7 +115,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,
@ -133,7 +133,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
@ -141,7 +141,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
@ -156,7 +156,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
@ -165,25 +165,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

@ -4,8 +4,8 @@ function furnace.check_furnace_blocks(pos)
local furnace_blocks = {{x=1,y=0,z=-1}, {x=1,y=0,z=0}, {x=1,y=0,z=1}, {x=0,y=0,z=-1}, {x=0,y=0,z=1}, {x=-1,y=0,z=-1}, {x=-1,y=0,z=0}, {x=-1,y=0,z=1}, {x=0,y=-1,z=0}, {x=1,y=-1,z=-1}, {x=1,y=-1,z=0}, {x=1,y=-1,z=1}, {x=0,y=-1,z=-1}, {x=0,y=-1,z=1}, {x=-1,y=-1,z=-1}, {x=-1,y=-1,z=0}, {x=-1,y=-1,z=1}}
for n = 1,#furnace_blocks do
local v = furnace_blocks[n]
if minetest.env:get_node_or_nil({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}) and
minetest.get_node_group(minetest.env:get_node({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}).name, "stone") ~= 1 then
if minetest.get_node_or_nil({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}) and
minetest.get_node_group(minetest.get_node({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}).name, "stone") ~= 1 then
return false
end
end
@ -50,7 +50,7 @@ minetest.register_node("furnace:self", {
groups = {crumbly=3, oddly_breakable_by_hand=1, 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", furnace.formspec)
meta:set_string("infotext", "Furnace")
meta:set_int("active", 0)
@ -62,7 +62,7 @@ minetest.register_node("furnace:self", {
inv:set_size("fuel", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
for i = 1,5 do
if not inv:is_empty("src"..i) or not inv:is_empty("dst"..i) then
@ -99,7 +99,7 @@ minetest.register_node("furnace:self_active", {
groups = {igniter=1,crumbly=3, 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", furnace.formspec)
meta:set_string("infotext", "Furnace")
meta:set_int("active", 0)
@ -111,7 +111,7 @@ minetest.register_node("furnace:self_active", {
inv:set_size("fuel", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
for i = 1,5 do
if not inv:is_empty("src"..i) or not inv:is_empty("dst"..i) then
@ -130,7 +130,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)
local inv = meta:get_inventory()
if not furnace.check_furnace_blocks(pos) then
@ -145,7 +145,7 @@ minetest.register_abm({
local name, size = v[1], v[2]
for n = 1,size do
if not inv:is_empty(name) then
minetest.env:add_item(pos,
minetest.add_item(pos,
{name=inv:get_stack(name, 1):get_name(),
count=inv:get_stack(name, 1):get_count(),
wear=inv:get_stack(name, 1):get_wear(),
@ -153,7 +153,7 @@ minetest.register_abm({
end
end
end
minetest.env:remove_node(pos)
minetest.remove_node(pos)
return
end

View File

@ -86,7 +86,7 @@ function realtest.register_dirt(name, DirtRef)
groups = {crumbly=3,drop_on_dig=1, falling_node=1, dirt=1, farm=1},
sounds = default.node_sound_dirt_defaults(),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
minetest.set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
@ -114,7 +114,7 @@ function realtest.register_dirt(name, DirtRef)
groups = {crumbly=3,drop_on_dig=1, dirt=1, grass=1, farm=1},
sounds = default.node_sound_dirt_defaults(),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
minetest.set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
@ -129,7 +129,7 @@ function realtest.register_dirt(name, DirtRef)
drop = "grounds:clay_lump 4",
sounds = default.node_sound_dirt_defaults(),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
minetest.set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
@ -146,7 +146,7 @@ function realtest.register_dirt(name, DirtRef)
footstep = {name="default_grass_footstep", gain=0.4},
}),
on_falling = function(pos, node)
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
minetest.set_node(pos, {name = farm_nofarm[node.name]})
nodeupdate_single(pos)
end,
})
@ -158,7 +158,7 @@ function realtest.register_dirt(name, DirtRef)
chance = 30,
action = function(pos, node)
pos.y = pos.y+1
local n = minetest.registered_nodes[minetest.env:get_node(pos).name]
local n = minetest.registered_nodes[minetest.get_node(pos).name]
if not n then
return
end
@ -168,14 +168,14 @@ function realtest.register_dirt(name, DirtRef)
if n.liquidtype and n.liquidtype ~= "none" then
return
end
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
pos.y = pos.y-1
minetest.env:set_node(pos, {name=nograss_grass[node.name]})
minetest.set_node(pos, {name=nograss_grass[node.name]})
end
})
@ -185,13 +185,13 @@ function realtest.register_dirt(name, DirtRef)
chance = 30,
action = function(pos, node)
pos.y = pos.y+1
local n = minetest.registered_nodes[minetest.env:get_node(pos).name]
local n = minetest.registered_nodes[minetest.get_node(pos).name]
if not n then
return
end
if (n.liquidtype and n.liquidtype ~= "none") then
pos.y = pos.y-1
minetest.env:set_node(pos, {name=grass_nograss[node.name]})
minetest.set_node(pos, {name=grass_nograss[node.name]})
nodeupdate_single(pos)
end
end
@ -203,15 +203,15 @@ function realtest.register_dirt(name, DirtRef)
chance = 2,
action = function(pos, node)
if node then
if not minetest.registered_nodes[minetest.env:get_node({x=pos.x,y=pos.y+1,z=pos.z}).name].buildable_to then
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
if not minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name].buildable_to then
minetest.set_node(pos, {name = farm_nofarm[node.name]})
return
end
end
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y+1,z=pos.z}, 1)
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y+1,z=pos.z}, 1)
for k, obj in pairs(objs) do
if obj:is_player() then
minetest.env:set_node(pos, {name = farm_nofarm[node.name]})
minetest.set_node(pos, {name = farm_nofarm[node.name]})
return
end
end
@ -223,11 +223,11 @@ function realtest.register_dirt(name, DirtRef)
interval = 17,
chance = 5,
action = function(pos, node)
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y+1,z=pos.z}, 1)
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y+1,z=pos.z}, 1)
for k, obj in pairs(objs) do
if obj:is_player() then
if minetest.registered_nodes[minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].buildable_to then
minetest.env:set_node(pos, {name=grass_nograss[node.name]})
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].buildable_to then
minetest.set_node(pos, {name=grass_nograss[node.name]})
nodeupdate_single(pos)
return
end

View File

@ -4,18 +4,18 @@ function hatches.register_hatch(name, desc, is_wooden)
local on_hatch_clicked = function(pos, node, puncher, itemstack)
if node.name == "hatches:"..name.."_hatch_opened_top" then
minetest.env:add_node(pos, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2})
minetest.add_node(pos, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2})
elseif (node.name == "hatches:"..name.."_hatch_opened_bottom") and
(minetest.env:get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air") then
minetest.env:add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2})
minetest.env:remove_node(pos)
(minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air") then
minetest.add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2})
minetest.remove_node(pos)
elseif node.name == "hatches:"..name.."_hatch_closed" then
if (minetest.env:get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "air") and (puncher:getpos().y + 1 >= pos.y) then
minetest.env:add_node({x = pos.x, y = pos.y - 1, z = pos.z}, {name = "hatches:"..name.."_hatch_opened_bottom",
if (minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "air") and (puncher:getpos().y + 1 >= pos.y) then
minetest.add_node({x = pos.x, y = pos.y - 1, z = pos.z}, {name = "hatches:"..name.."_hatch_opened_bottom",
param2 = node.param2})
minetest.env:remove_node(pos)
minetest.remove_node(pos)
else
minetest.env:add_node(pos, {name = "hatches:"..name.."_hatch_opened_top", param2 = node.param2})
minetest.add_node(pos, {name = "hatches:"..name.."_hatch_opened_top", param2 = node.param2})
end
end
end

View File

@ -32,16 +32,16 @@ icicles = {}
function icicles.make_stalactite(pos, length)
for i = length,1,-1 do
if minetest.env:get_node({x=pos.x,y=pos.y-i+1,z=pos.z}).name == "air" then
minetest.env:set_node({x=pos.x,y=pos.y-i+1,z=pos.z}, {name = "icicles:icicle_"..5-i})
if minetest.get_node({x=pos.x,y=pos.y-i+1,z=pos.z}).name == "air" then
minetest.set_node({x=pos.x,y=pos.y-i+1,z=pos.z}, {name = "icicles:icicle_"..5-i})
else return end
end
end
function icicles.make_stalagmite(pos, length)
for i = 1,length do
if minetest.env:get_node({x=pos.x,y=pos.y+i-1,z=pos.z}).name == "air" then
minetest.env:set_node({x=pos.x,y=pos.y+i-1,z=pos.z}, {name = "icicles:icicle_"..5-i, param2 = 1})
if minetest.get_node({x=pos.x,y=pos.y+i-1,z=pos.z}).name == "air" then
minetest.set_node({x=pos.x,y=pos.y+i-1,z=pos.z}, {name = "icicles:icicle_"..5-i, param2 = 1})
else return end
end
end
@ -76,10 +76,10 @@ local function generate(minp, maxp, seed, chunks_per_volume, icicles_per_chunk,
local p2 = {x=x2, y=y2, z=z2}
local p3 = {x=x2, y=y2+1, z=z2}
local p4 = {x=x2, y=y2-1, z=z2}
if minetest.env:get_node(p2).name == "air" then
if minetest.env:get_node(p3).name == "default:stone" then
if minetest.get_node(p2).name == "air" then
if minetest.get_node(p3).name == "default:stone" then
icicles.make_stalactite(p2, pr:next(2, 4))
elseif minetest.env:get_node(p4).name == "default:stone" then
elseif minetest.get_node(p4).name == "default:stone" then
icicles.make_stalagmite(p2, pr:next(2, 4))
end
end

View File

@ -112,13 +112,13 @@ function realtest.register_liquid(name, LiquidDef)
if pointed_thing.type ~= "node" then
return
end
n = minetest.env:get_node(pointed_thing.under)
n = minetest.get_node(pointed_thing.under)
if minetest.registered_nodes[n.name].buildable_to then
minetest.env:add_node(pointed_thing.under, {name=LiquidDef.source})
minetest.add_node(pointed_thing.under, {name=LiquidDef.source})
else
n = minetest.env:get_node(pointed_thing.above)
n = minetest.get_node(pointed_thing.above)
if minetest.registered_nodes[n.name].buildable_to then
minetest.env:add_node(pointed_thing.above, {name=LiquidDef.source})
minetest.add_node(pointed_thing.above, {name=LiquidDef.source})
else
return
end
@ -147,14 +147,14 @@ for _, type in ipairs(buckets.types) do
if pointed_thing.type ~= "node" then
return
end
local n = minetest.env:get_node(pointed_thing.under)
local n = minetest.get_node(pointed_thing.under)
local liquiddef = realtest.registered_liquids[n.name]
if not liquiddef then
return
end
local full_name = empty_name.."_with_"..liquiddef.name
if liquiddef and n.name == liquiddef.source and minetest.registered_items[full_name] then
minetest.env:add_node(pointed_thing.under, {name="air"})
minetest.add_node(pointed_thing.under, {name="air"})
return {name=full_name}
end
end,

View File

@ -84,14 +84,14 @@ instruments.spear.entity = {
instruments.spear.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 and self.lastpos.x 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
obj:set_hp(obj:get_hp()-instruments.spear.damage)
if obj:get_entity_name() ~= "instruments:spear_entity" then
minetest.env:add_item(self.lastpos, "instruments:spear_"..self.object:get_luaentity().material)
minetest.add_item(self.lastpos, "instruments:spear_"..self.object:get_luaentity().material)
self.object:remove()
return
end
@ -100,7 +100,7 @@ instruments.spear.entity.on_step = function(self, dtime)
if self.lastpos.x then
if node.name ~= "air" then
minetest.env:add_item(self.lastpos, "instruments:spear_"..self.object:get_luaentity().material)
minetest.add_item(self.lastpos, "instruments:spear_"..self.object:get_luaentity().material)
self.object:remove()
end
end
@ -119,7 +119,7 @@ for i, material in ipairs(instruments.materials) do
inventory_image = "instruments_spear_"..material..".png",
on_use = function (item, player, pointed_thing)
local playerpos=player:getpos()
local obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "instruments:spear_entity")
local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "instruments:spear_entity")
local dir=player:get_look_dir()
obj:setvelocity({x=dir.x*instruments.spear.velocity, y=dir.y*instruments.spear.velocity, z=dir.z*instruments.spear.velocity})
obj:setacceleration({x=dir.x*-3, y=-instruments.spear.gravity, z=dir.z*-3})
@ -137,9 +137,9 @@ for i, material in ipairs(instruments.materials) do
if pointed_thing.type ~= "node" then
return
end
local n = minetest.env:get_node(pointed_thing.under)
local n = minetest.get_node(pointed_thing.under)
if instruments.chisel_pairs[n.name] then
minetest.env:add_node(pointed_thing.under, {name=instruments.chisel_pairs[n.name], param2=n.param2})
minetest.add_node(pointed_thing.under, {name=instruments.chisel_pairs[n.name], param2=n.param2})
nodeupdate(pointed_thing.under)
end
item:add_wear(65535/instruments.durability[i]/4)

View File

@ -43,12 +43,12 @@ for _, tree in pairs(realtest.registered_trees) do
paramtype = "light",
paramtype2 = "facedir",
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("src1") and inv:is_empty("src2") and inv:is_empty("instruments") and inv:is_empty("output")
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[8,8]"..
"button[0.5,0.25;1.35,1;buttonCraft;Craft]"..
"button[1.6,0.25;0.9,1;buttonCraft10;x10]"..
@ -66,7 +66,7 @@ for _, tree in pairs(realtest.registered_trees) do
inv:set_size("output", 1)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local src1, src2 = inv:get_stack("src1", 1), inv:get_stack("src2", 1)

View File

@ -23,15 +23,15 @@ local function generate_peat(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
if minetest.env:get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
minetest.env:get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "air" then
minetest.env:set_node(p2, {name=name})
if minetest.get_node(p2).name == wherein then
if minetest.get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
minetest.get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "air" then
minetest.set_node(p2, {name=name})
end
if minetest.env:get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
minetest.env:get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "default:water_source" and
minetest.env:get_node({x=p2.x, y=p2.y + 3, z=p2.z}).name == "air" then
minetest.env:set_node(p2, {name=name})
if minetest.get_node({x=p2.x, y=p2.y + 1, z=p2.z}).name == "default:water_source" and
minetest.get_node({x=p2.x, y=p2.y + 2, z=p2.z}).name == "default:water_source" and
minetest.get_node({x=p2.x, y=p2.y + 3, z=p2.z}).name == "air" then
minetest.set_node(p2, {name=name})
end
end
@ -46,7 +46,7 @@ end
local function is_node_beside(pos, node)
local sides = {{x=-1,y=0,z=0}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=0,y=0,z=1}, {x=0,y=-1,z=0}, {x=0,y=1,z=0},}
for i, s in ipairs(sides) do
if minetest.env:get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name == node then
if minetest.get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name == node then
return true, minetest.dir_to_wallmounted(s)
end
end
@ -77,10 +77,10 @@ local function generate_sulfur(name, minp, maxp, seed, chunks_per_volume, chunk_
local y2 = y0+y1
local z2 = z0+z1
local p2 = {x=x2, y=y2, z=z2}
if minetest.env:get_node(p2).name == "air" and minetest.env:find_node_near(p2, 3, {"default:lava_source","default:lava_flowing"}) then
if minetest.get_node(p2).name == "air" and minetest.find_node_near(p2, 3, {"default:lava_source","default:lava_flowing"}) then
local inb, side = is_node_beside(p2, "default:stone")
if inb then
minetest.env:set_node(p2, {name=name, param2 = side})
minetest.set_node(p2, {name=name, param2 = side})
end
end
end
@ -113,7 +113,7 @@ local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume,
if type(noise_max) ~= "number" then
noise_max = 2
end
ore_noise1 = minetest.env:get_perlin(seed, 3, 0.7, 100)
ore_noise1 = minetest.get_perlin(seed, 3, 0.7, 100)
end
--print("generate_ore num_chunks: "..dump(num_chunks))
@ -137,15 +137,15 @@ local function 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
if minetest.get_node(p2).name == wherein then
-- perlin
if type(noise_min) == "number" or type(noise_max) == "number" then
if ore_noise2 >= noise_min and ore_noise2 <= noise_max then
minetest.env:set_node(p2, {name=name})
minetest.set_node(p2, {name=name})
end
else
minetest.env:set_node(p2, {name=name})
minetest.set_node(p2, {name=name})
end
end
@ -171,4 +171,4 @@ minetest.after(0, function()
generate_sulfur("ores:sulfur", minp, maxp, seed+400, 1/8/8/8/8, 10, 850, -30912, 200)
generate_peat("ores:peat", "default:dirt", minp, maxp, seed+401, 1/8/16/24, 10, 1000, -100, 200)
end)
end)
end)

View File

@ -1,14 +1,14 @@
-- Event handlers
local function scaffolding_update(pos)
local node_name = minetest.env:get_node(pos).name
local node_name = minetest.get_node(pos).name
if minetest.get_node_group(node_name, "scaffolding") ~= 1 then
return
end
local material = realtest.registered_trees_list[minetest.get_node_group(node_name, "material")]:remove_modname_prefix()
if minetest.get_node_group(minetest.env:get_node(mod_pos(pos, 0, 1, 0)).name, "scaffolding") == 1 then
minetest.env:add_node(pos, {name = "scaffolding:scaffolding_sub_"..material})
if minetest.get_node_group(minetest.get_node(mod_pos(pos, 0, 1, 0)).name, "scaffolding") == 1 then
minetest.add_node(pos, {name = "scaffolding:scaffolding_sub_"..material})
else
minetest.env:add_node(pos, {name = "scaffolding:scaffolding_top_"..material})
minetest.add_node(pos, {name = "scaffolding:scaffolding_top_"..material})
end
end
@ -57,7 +57,7 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
walkable = false,
cause_drop = function(pos, node)
local b_pos = {x=pos.x,y=pos.y-1,z=pos.z}
local b_node = minetest.env:get_node(b_pos)
local b_node = minetest.get_node(b_pos)
if minetest.get_node_group(b_node.name, "scaffolding") ~= 1 and minetest.registered_nodes[b_node.name].walkable == false then
return true
end

View File

@ -127,7 +127,7 @@ realtest.register_instrument_plan("scribing_table:plan_hatch", {
})
local function check_recipe(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for _, plan in pairs(realtest.registered_instrument_plans) do
local paperstack, res_craft = inv:get_stack("paper", 1)
@ -180,7 +180,7 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
groups = {oddly_breakable_by_hand=3, dig_immediate=2},
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,10]"..
"list[current_name;paper;6.5,0.5;1,1;]"..
@ -205,7 +205,7 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
check_recipe(pos)
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 inv:is_empty("paper") and inv:is_empty("dye") and inv:is_empty("res") then
return true

View File

@ -4,8 +4,8 @@ minetest.register_tool("sticks:sticks", {
on_use = function(item, user, pointed_thing)
local pos
if pointed_thing.type == "node" then
if minetest.env:get_node(pointed_thing.under).name == "furnace:self" or minetest.env:get_node(pointed_thing.under).name == "bonfire:self" then
local meta = minetest.env:get_meta(pointed_thing.under)
if minetest.get_node(pointed_thing.under).name == "furnace:self" or minetest.get_node(pointed_thing.under).name == "bonfire:self" then
local meta = minetest.get_meta(pointed_thing.under)
meta:set_int("active", 1)
item:add_wear(65535/10)
return item
@ -16,8 +16,8 @@ minetest.register_tool("sticks:sticks", {
else
return
end
if minetest.env:get_node(pos).name == "air" then
local objects = minetest.env:get_objects_inside_radius(pos, 0.5)
if minetest.get_node(pos).name == "air" then
local objects = minetest.get_objects_inside_radius(pos, 0.5)
local bonfireb = 0
local furnaceb = 0
local coals = {}
@ -37,13 +37,13 @@ minetest.register_tool("sticks:sticks", {
end
end
end
if furnaceb >= 9 and math.random(6) == 1 and minetest.env:get_node(pos).name == "air" then
if furnaceb >= 9 and math.random(6) == 1 and minetest.get_node(pos).name == "air" then
if furnace.check_furnace_blocks(pos) then
for _, v in ipairs(coals) do
v:remove()
end
minetest.env:set_node(pos, {name = "furnace:self_active"})
local meta = minetest.env:get_meta(pos)
minetest.set_node(pos, {name = "furnace:self_active"})
local meta = minetest.get_meta(pos)
meta:set_int("active", 1)
meta:set_float("fuel_time", 0)
meta:set_float("fuel_totaltime", 30)
@ -69,12 +69,12 @@ minetest.register_tool("sticks:sticks", {
end
end
end
if bonfireb >= 10 and math.random(2) == 1 and minetest.env:get_node(pos).name == "air" then
if bonfireb >= 10 and math.random(2) == 1 and minetest.get_node(pos).name == "air" then
for _, v in ipairs(sticks_and_leaves) do
v:remove()
end
minetest.env:set_node(pos, {name = "bonfire:self"})
local meta = minetest.env:get_meta(pos)
minetest.set_node(pos, {name = "bonfire:self"})
local meta = minetest.get_meta(pos)
meta:set_int("active", 1)
meta:set_float("fuel_time", 0)
meta:set_float("fuel_totaltime", 20)

View File

@ -4,29 +4,29 @@ dofile(minetest.get_modpath("trees").."/leavesgen.lua")
function trees.make_tree(pos, tree)
local tree = realtest.registered_trees[tree]
if not table.contains(tree.grounds, minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name) then
if not table.contains(tree.grounds, minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name) then
return
end
local height = tree.height()
for i = 1,height do
if minetest.env:get_node({x=pos.x, y=pos.y+i, z=pos.z}).name ~= "air" then
if minetest.get_node({x=pos.x, y=pos.y+i, z=pos.z}).name ~= "air" then
return
end
end
for i = 0,height-1 do
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name=tree.name.."_trunk"})
minetest.add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name=tree.name.."_trunk"})
end
minetest.env:add_node({x=pos.x, y=pos.y+height, z=pos.z}, {name=tree.name.."_trunk_top"})
minetest.add_node({x=pos.x, y=pos.y+height, z=pos.z}, {name=tree.name.."_trunk_top"})
for i = 1,#tree.leaves do
local p = {x=pos.x+tree.leaves[i][1], y=pos.y+height+tree.leaves[i][2], z=pos.z+tree.leaves[i][3]}
if minetest.env:get_node(p).name == "air" or minetest.env:get_node(p).name == "ignore" then
minetest.env:add_node(p, {name=tree.name.."_leaves"})
if minetest.get_node(p).name == "air" or minetest.get_node(p).name == "ignore" then
minetest.add_node(p, {name=tree.name.."_leaves"})
end
end
end
local function generate(tree, minp, maxp, seed)
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;
@ -46,7 +46,7 @@ local function generate(tree, minp, maxp, seed)
-- Find ground level (0...30)
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

View File

@ -134,11 +134,11 @@ function realtest.register_tree(name, TreeDef)
local oldmetadata = nil
if def.after_dig_node then
oldmetadata = minetest.env:get_meta(pos):to_table()
oldmetadata = minetest.get_meta(pos):to_table()
end
-- Remove node and update
minetest.env:remove_node(pos)
minetest.remove_node(pos)
-- Run callback
if def.after_dig_node then
@ -290,8 +290,8 @@ function realtest.register_tree(name, TreeDef)
after_dig_node = function(pos, oldnode, oldmetadata, digger)
for i = 1,#tree.leaves do
local p = {x=pos.x+tree.leaves[i][1], y=pos.y+tree.leaves[i][2], z=pos.z+tree.leaves[i][3]}
if minetest.env:get_node(p).name == tree.name.."_leaves" then
minetest.env:dig_node(p)
if minetest.get_node(p).name == tree.name.."_leaves" then
minetest.dig_node(p)
end
end
end,
@ -329,7 +329,7 @@ function realtest.register_tree(name, TreeDef)
},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" and
minetest.registered_nodes[minetest.env:get_node(pointed_thing.above).name].buildable_to == true then
minetest.registered_nodes[minetest.get_node(pointed_thing.above).name].buildable_to == true then
local param2 = nil
if pointed_thing.above.x < pointed_thing.under.x then
param2 = 1
@ -341,7 +341,7 @@ function realtest.register_tree(name, TreeDef)
param2 = 2
end
if param2 then
minetest.env:set_node(pointed_thing.above,{name = tree.name.."_ladder", param2 = param2})
minetest.set_node(pointed_thing.above,{name = tree.name.."_ladder", param2 = param2})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
@ -361,7 +361,7 @@ function realtest.register_tree(name, TreeDef)
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
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;]"..
@ -371,7 +371,7 @@ function realtest.register_tree(name, TreeDef)
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,
@ -391,25 +391,25 @@ function realtest.register_tree(name, TreeDef)
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
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", tree.description.." 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", tree.description.." 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 player:get_player_name() == meta:get_string("owner")
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 "..
@ -420,7 +420,7 @@ function realtest.register_tree(name, TreeDef)
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 "..
@ -431,7 +431,7 @@ function realtest.register_tree(name, TreeDef)
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 "..
@ -454,7 +454,7 @@ function realtest.register_tree(name, TreeDef)
" 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(),
@ -622,10 +622,10 @@ function realtest.register_tree(name, TreeDef)
interval = tree.grow_interval,
chance = tree.grow_chance,
action = function(pos, node)
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) >= tree.grow_light then
if minetest.get_node_light(pos) >= tree.grow_light then
trees.make_tree(pos, tree.name)
end
end,
@ -682,4 +682,4 @@ realtest.register_tree("trees:spruce", {
height = function()
return 10 + math.random(4)
end,
})
})

View File

@ -8,12 +8,12 @@ local directions = {
}
local function update_pane(pos)
if minetest.env:get_node(pos).name:find("xpanes:pane") == nil then
if minetest.get_node(pos).name:find("xpanes:pane") == nil then
return
end
local sum = 0
for i = 1, 4 do
local node = minetest.env:get_node({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
local node = minetest.get_node({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
if minetest.registered_nodes[node.name].walkable ~= false then
sum = sum + 2 ^ (i - 1)
end
@ -21,7 +21,7 @@ local function update_pane(pos)
if sum == 0 then
sum = 15
end
minetest.env:add_node(pos, {name = "xpanes:pane_"..sum})
minetest.add_node(pos, {name = "xpanes:pane_"..sum})
end
local function update_nearby(pos)