Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace minetest.env: with minetest.
  • Loading branch information
PilzAdam committed May 24, 2013
1 parent dfad095 commit 31a74ed
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 169 deletions.
18 changes: 9 additions & 9 deletions mods/bones/init.lua
Expand Up @@ -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
Expand All @@ -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,

Expand All @@ -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", "")
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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)
14 changes: 7 additions & 7 deletions mods/bucket/init.lua
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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)})
Expand Down
32 changes: 16 additions & 16 deletions mods/default/functions.lua
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
56 changes: 28 additions & 28 deletions mods/default/mapgen.lua
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -396,26 +396,26 @@ 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
end
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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -502,26 +502,26 @@ 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 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
Expand Down

0 comments on commit 31a74ed

Please sign in to comment.