mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-23 08:20:21 +01:00
Removed .env and minetest: calls in itemframe
This commit is contained in:
parent
a149bc8c08
commit
7b51983a97
@ -1,5 +1,4 @@
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
-- See README.txt for licensing and other information
|
||||
local tmp = {}
|
||||
itemframes = {}
|
||||
|
||||
@ -47,9 +46,9 @@ facedir[3] = {x=-1,y=0,z=0}
|
||||
local remove_item = function(pos, node)
|
||||
local objs = nil
|
||||
if node.name == "itemframes:frame" then
|
||||
objs = minetest.env:get_objects_inside_radius(pos, .5)
|
||||
objs = minetest.get_objects_inside_radius(pos, .5)
|
||||
elseif minetest.get_item_group(node.name, "group:pedestal") then
|
||||
objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y+1,z=pos.z}, .5)
|
||||
objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y+1,z=pos.z}, .5)
|
||||
end
|
||||
if objs then
|
||||
for _, obj in ipairs(objs) do
|
||||
@ -61,7 +60,7 @@ local remove_item = function(pos, node)
|
||||
end
|
||||
local update_item = function(pos, node)
|
||||
remove_item(pos, node)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("item") ~= "" then
|
||||
if node.name == "itemframes:frame" then
|
||||
local posad = facedir[node.param2]
|
||||
@ -74,7 +73,7 @@ local update_item = function(pos, node)
|
||||
end
|
||||
tmp.nodename = node.name
|
||||
tmp.texture = ItemStack(meta:get_string("item")):get_name()
|
||||
local e = minetest.env:add_entity(pos,"itemframes:item")
|
||||
local e = minetest.add_entity(pos,"itemframes:item")
|
||||
if node.name == "itemframes:frame" then
|
||||
local yaw = math.pi*2 - node.param2 * math.pi/2
|
||||
e:setyaw(yaw)
|
||||
@ -82,12 +81,12 @@ local update_item = function(pos, node)
|
||||
end
|
||||
end
|
||||
local drop_item = function(pos, node)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("item") ~= "" then
|
||||
if node.name == "itemframes:frame" then
|
||||
minetest.env:add_item(pos, meta:get_string("item"))
|
||||
minetest.add_item(pos, meta:get_string("item"))
|
||||
elseif minetest.get_item_group(node.name, "group:pedestal") then
|
||||
minetest.env:add_item({x=pos.x,y=pos.y+1,z=pos.z}, meta:get_string("item"))
|
||||
minetest.add_item({x=pos.x,y=pos.y+1,z=pos.z}, meta:get_string("item"))
|
||||
end
|
||||
meta:set_string("item","")
|
||||
end
|
||||
@ -109,13 +108,13 @@ minetest.register_node("itemframes:frame",{
|
||||
legacy_wallmounted = true,
|
||||
sounds = default.node_sound_defaults(),
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner",placer:get_player_name())
|
||||
meta:set_string("infotext","Item frame (owned by "..placer:get_player_name()..")")
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if not itemstack then return end
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if clicker:get_player_name() == meta:get_string("owner") then
|
||||
drop_item(pos,node)
|
||||
local s = itemstack:take_item()
|
||||
@ -125,13 +124,13 @@ minetest.register_node("itemframes:frame",{
|
||||
return itemstack
|
||||
end,
|
||||
on_punch = function(pos,node,puncher)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if puncher:get_player_name() == meta:get_string("owner") then
|
||||
drop_item(pos, node)
|
||||
end
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return player:get_player_name() == meta:get_string("owner")
|
||||
end,
|
||||
})
|
||||
@ -160,13 +159,13 @@ function itemframes.register_pedestal(subname, recipeitem, groups, images, descr
|
||||
sounds = sounds,
|
||||
paramtype = "light",
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("owner",placer:get_player_name())
|
||||
meta:set_string("infotext","Pedestal (owned by "..placer:get_player_name()..")")
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
if not itemstack then return end
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if clicker:get_player_name() == meta:get_string("owner") then
|
||||
drop_item(pos,node)
|
||||
local s = itemstack:take_item()
|
||||
@ -176,13 +175,13 @@ function itemframes.register_pedestal(subname, recipeitem, groups, images, descr
|
||||
return itemstack
|
||||
end,
|
||||
on_punch = function(pos,node,puncher)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if puncher:get_player_name() == meta:get_string("owner") then
|
||||
drop_item(pos,node)
|
||||
end
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return player:get_player_name() == meta:get_string("owner")
|
||||
end,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user