removed deprecated minetest.env calls

This commit is contained in:
Sokomine 2018-07-30 19:08:02 +02:00
parent 7846aa3894
commit 692608e1f4
5 changed files with 24 additions and 23 deletions

View File

@ -21,6 +21,7 @@
-- Version 2.00 -- Version 2.00
-- Changelog: -- Changelog:
-- 30.07.2018 * Removed deprecated minetest.env usage.
-- 30.07.2018 * Front side of chest does not get pipeworks image anymore. -- 30.07.2018 * Front side of chest does not get pipeworks image anymore.
-- Instead it always shows the locks texture as overlay. -- Instead it always shows the locks texture as overlay.
-- 30.07.2018 * Fixed bug with pipeworks. -- 30.07.2018 * Fixed bug with pipeworks.
@ -63,7 +64,7 @@ function locks:lock_init( pos, default_formspec )
return; return;
end end
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
if( meta == nil ) then if( meta == nil ) then
print( "Error: [locks] lock_init: unable to get meta data"); print( "Error: [locks] lock_init: unable to get meta data");
return; return;
@ -92,7 +93,7 @@ function locks:get_lockdata( pos )
return; return;
end end
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
if( meta == nil) then if( meta == nil) then
return; return;
end end
@ -113,7 +114,7 @@ function locks:set_lockdata( pos, data )
return; return;
end end
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
if( meta == nil) then if( meta == nil) then
return; return;
end end
@ -141,7 +142,7 @@ function locks:lock_set_owner( pos, player_or_name, description )
return false; return false;
end end
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
if( meta == nil ) then if( meta == nil ) then
print( "Error: [locks] lock_set_owner: unable to get meta data"); print( "Error: [locks] lock_set_owner: unable to get meta data");
return; return;
@ -171,7 +172,7 @@ function locks:lock_allow_dig( pos, player )
return false; return false;
end end
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local lock_owner = meta:get_string("owner"); local lock_owner = meta:get_string("owner");
-- locks who lost their owner can be opened/digged by anyone -- locks who lost their owner can be opened/digged by anyone
@ -211,7 +212,7 @@ function locks:lock_allow_use( pos, player )
end end
local name = player:get_player_name(); local name = player:get_player_name();
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
-- pipeworks sends a special username -- pipeworks sends a special username
if( player.is_fake_player) then if( player.is_fake_player) then
@ -303,7 +304,7 @@ function locks:lock_handle_input( pos, formname, fields, player )
return false; return false;
end end
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
if( meta == nil ) then if( meta == nil ) then
print( "Error: [locks] lock_handle_input: unable to get meta data"); print( "Error: [locks] lock_handle_input: unable to get meta data");
return; return;

View File

@ -21,12 +21,12 @@ if( locks.pipeworks_enabled ) then
tubedevice = 1, tubedevice_receiver = 1 }; tubedevice = 1, tubedevice_receiver = 1 };
locks.chest_add.tube = { locks.chest_add.tube = {
insert_object = function(pos, node, stack, direction) insert_object = function(pos, node, stack, direction)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:add_item("main", stack) return inv:add_item("main", stack)
end, end,
can_insert = function(pos, node, stack, direction) can_insert = function(pos, node, stack, direction)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:room_for_item("main", stack) return inv:room_for_item("main", stack)
end, end,
@ -45,7 +45,7 @@ minetest.register_node("locks:shared_locked_chest", {
legacy_facedir_simple = true, legacy_facedir_simple = true,
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
-- prepare the lock of the chest -- prepare the lock of the chest
locks:lock_init( pos, locks:lock_init( pos,
"size[8,10]".. "size[8,10]"..
@ -78,7 +78,7 @@ minetest.register_node("locks:shared_locked_chest", {
if( not(locks:lock_allow_dig( pos, player ))) then if( not(locks:lock_allow_dig( pos, player ))) then
return false; return false;
end end
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("main") return inv:is_empty("main")
end, end,

View File

@ -60,7 +60,7 @@ if( locks.pipeworks_enabled ) then
tubedevice = 1, tubedevice_receiver = 1 }; tubedevice = 1, tubedevice_receiver = 1 };
locks.furnace_add.tube = { locks.furnace_add.tube = {
insert_object = function(pos, node, stack, direction) insert_object = function(pos, node, stack, direction)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if direction.y == 1 then if direction.y == 1 then
return inv:add_item("fuel",stack) return inv:add_item("fuel",stack)
@ -69,7 +69,7 @@ if( locks.pipeworks_enabled ) then
end end
end, end,
can_insert = function(pos, node, stack, direction) can_insert = function(pos, node, stack, direction)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if direction.y == 1 then if direction.y == 1 then
return inv:room_for_item("fuel", stack) return inv:room_for_item("fuel", stack)

View File

@ -23,7 +23,7 @@ minetest.register_node("locks:shared_locked_sign_wall", {
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
-- prepare the lock of the sign -- prepare the lock of the sign
locks:lock_init( pos, locks:lock_init( pos,
"size[8,4]".. "size[8,4]"..
@ -51,7 +51,7 @@ minetest.register_node("locks:shared_locked_sign_wall", {
and locks:lock_allow_use( pos, sender )) then and locks:lock_allow_use( pos, sender )) then
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields)) --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 ""; fields.text = fields.text or "";
print((sender:get_player_name() or "").." wrote \""..fields.text.. print((sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos)); "\" to sign at "..minetest.pos_to_string(pos));

View File

@ -40,8 +40,8 @@ local xdoors2_transform = function(pos, node, puncher)
end end
local olddata = locks:get_lockdata( pos ); local olddata = locks:get_lockdata( pos );
minetest.env:add_node(pos, {name = "locks:door_bottom_"..t, param2 = p2}) minetest.add_node(pos, {name = "locks:door_bottom_"..t, param2 = p2})
minetest.env:add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "locks:door_top_"..t, param2 = p2}) minetest.add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "locks:door_top_"..t, param2 = p2})
-- remember who owns the door, what passwords are set etc. -- remember who owns the door, what passwords are set etc.
locks:set_lockdata( pos, olddata ); locks:set_lockdata( pos, olddata );
@ -53,8 +53,8 @@ local xdoors2_destruct = function(pos, oldnode)
if is_top(oldnode.name) then if is_top(oldnode.name) then
pos = {x = pos.x, y = pos.y - 1, z = pos.z} pos = {x = pos.x, y = pos.y - 1, z = pos.z}
end end
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.env:remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
end end
for i = 1, 2 do for i = 1, 2 do
@ -149,7 +149,7 @@ minetest.register_node("locks:door", {
return itemstack return itemstack
else else
-- there should be 2 empty nodes -- there should be 2 empty nodes
if minetest.env:get_node(above1).name ~= "air" then if minetest.get_node(above1).name ~= "air" then
return itemstack return itemstack
end end
@ -165,14 +165,14 @@ minetest.register_node("locks:door", {
end end
local t = 1 local t = 1
local another_door = minetest.env:get_node({x = above.x + delta[fdir + 1].x, y = above.y, z = above.z + delta[fdir + 1].z}) local another_door = minetest.get_node({x = above.x + delta[fdir + 1].x, y = above.y, z = above.z + delta[fdir + 1].z})
if (another_door.name:sub(-1) == "1" and another_door.param2 == fdir) if (another_door.name:sub(-1) == "1" and another_door.param2 == fdir)
or (another_door.name:sub(-1) == "2" and another_door.param2 == (fdir + 1) % 4) then or (another_door.name:sub(-1) == "2" and another_door.param2 == (fdir + 1) % 4) then
t = 2 t = 2
end end
minetest.env:add_node(above, {name = "locks:door_bottom_"..t, param2 = fdir}) minetest.add_node(above, {name = "locks:door_bottom_"..t, param2 = fdir})
minetest.env:add_node({x = above.x, y = above.y + 1, z = above.z}, {name = "locks:door_top_"..t, param2 = fdir}) minetest.add_node({x = above.x, y = above.y + 1, z = above.z}, {name = "locks:door_top_"..t, param2 = fdir})
-- store who owns the door; the other data can be default for now -- store who owns the door; the other data can be default for now
locks:lock_set_owner( above, placer:get_player_name() or "", "Shared locked door"); locks:lock_set_owner( above, placer:get_player_name() or "", "Shared locked door");