minetest.env:* is deprecated, use minetest.*

This commit is contained in:
Vanessa Ezekowitz 2014-07-05 02:01:24 -04:00
parent 9032385b61
commit 5adbd3f043
2 changed files with 9 additions and 9 deletions

View File

@ -13,8 +13,8 @@ local function spawn_apple_under(pos)
y = pos.y - 1, y = pos.y - 1,
z = pos.z, z = pos.z,
} }
if minetest.env:get_node(below).name == "air" then if minetest.get_node(below).name == "air" then
minetest.env:add_node(below, { name = "default:apple" }) minetest.add_node(below, { name = "default:apple" })
end end
end end

View File

@ -3,19 +3,19 @@ local NODE_YOUNG = "young"
nature = {} nature = {}
local function set_young_node(pos) local function set_young_node(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string(NODE_YOUNG, "true") meta:set_string(NODE_YOUNG, "true")
minetest.after(5, minetest.after(5,
function(pos) function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string(NODE_YOUNG, "false") meta:set_string(NODE_YOUNG, "false")
end, end,
pos) pos)
end end
local function is_not_young(pos) local function is_not_young(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local young = meta:get_string(NODE_YOUNG) local young = meta:get_string(NODE_YOUNG)
return young ~= "true" return young ~= "true"
@ -23,12 +23,12 @@ end
function nature:grow_node(pos, nodename) function nature:grow_node(pos, nodename)
if pos ~= nil then if pos ~= nil then
local light_enough = minetest.env:get_node_light(pos, nil) local light_enough = minetest.get_node_light(pos, nil)
>= MINIMUM_GROWTH_LIGHT >= MINIMUM_GROWTH_LIGHT
if is_not_young(pos) and light_enough then if is_not_young(pos) and light_enough then
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.env:add_node(pos, { name = nodename }) minetest.add_node(pos, { name = nodename })
set_young_node(pos) set_young_node(pos)
minetest.log("info", nodename .. " has grown at " .. pos.x .. "," minetest.log("info", nodename .. " has grown at " .. pos.x .. ","
@ -38,6 +38,6 @@ function nature:grow_node(pos, nodename)
end end
function nature:is_near_water(pos) function nature:is_near_water(pos)
return minetest.env:find_node_near(pos, DISTANCE_FROM_WATER, return minetest.find_node_near(pos, DISTANCE_FROM_WATER,
{ "default:water_source" }) ~= nil or DISTANCE_FROM_WATER == -1 { "default:water_source" }) ~= nil or DISTANCE_FROM_WATER == -1
end end