mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-23 16:30:19 +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 = {}
|
local tmp = {}
|
||||||
itemframes = {}
|
itemframes = {}
|
||||||
|
|
||||||
@ -47,9 +46,9 @@ facedir[3] = {x=-1,y=0,z=0}
|
|||||||
local remove_item = function(pos, node)
|
local remove_item = function(pos, node)
|
||||||
local objs = nil
|
local objs = nil
|
||||||
if node.name == "itemframes:frame" then
|
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
|
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
|
end
|
||||||
if objs then
|
if objs then
|
||||||
for _, obj in ipairs(objs) do
|
for _, obj in ipairs(objs) do
|
||||||
@ -61,7 +60,7 @@ local remove_item = function(pos, node)
|
|||||||
end
|
end
|
||||||
local update_item = function(pos, node)
|
local update_item = function(pos, node)
|
||||||
remove_item(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 meta:get_string("item") ~= "" then
|
||||||
if node.name == "itemframes:frame" then
|
if node.name == "itemframes:frame" then
|
||||||
local posad = facedir[node.param2]
|
local posad = facedir[node.param2]
|
||||||
@ -74,7 +73,7 @@ local update_item = function(pos, node)
|
|||||||
end
|
end
|
||||||
tmp.nodename = node.name
|
tmp.nodename = node.name
|
||||||
tmp.texture = ItemStack(meta:get_string("item")):get_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
|
if node.name == "itemframes:frame" then
|
||||||
local yaw = math.pi*2 - node.param2 * math.pi/2
|
local yaw = math.pi*2 - node.param2 * math.pi/2
|
||||||
e:setyaw(yaw)
|
e:setyaw(yaw)
|
||||||
@ -82,12 +81,12 @@ local update_item = function(pos, node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local drop_item = function(pos, node)
|
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 meta:get_string("item") ~= "" then
|
||||||
if node.name == "itemframes:frame" 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
|
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
|
end
|
||||||
meta:set_string("item","")
|
meta:set_string("item","")
|
||||||
end
|
end
|
||||||
@ -109,13 +108,13 @@ minetest.register_node("itemframes:frame",{
|
|||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
after_place_node = function(pos, placer, itemstack)
|
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("owner",placer:get_player_name())
|
||||||
meta:set_string("infotext","Item frame (owned by "..placer:get_player_name()..")")
|
meta:set_string("infotext","Item frame (owned by "..placer:get_player_name()..")")
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
if not itemstack then return end
|
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
|
if clicker:get_player_name() == meta:get_string("owner") then
|
||||||
drop_item(pos,node)
|
drop_item(pos,node)
|
||||||
local s = itemstack:take_item()
|
local s = itemstack:take_item()
|
||||||
@ -125,13 +124,13 @@ minetest.register_node("itemframes:frame",{
|
|||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_punch = function(pos,node,puncher)
|
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
|
if puncher:get_player_name() == meta:get_string("owner") then
|
||||||
drop_item(pos, node)
|
drop_item(pos, node)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
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")
|
return player:get_player_name() == meta:get_string("owner")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@ -160,13 +159,13 @@ function itemframes.register_pedestal(subname, recipeitem, groups, images, descr
|
|||||||
sounds = sounds,
|
sounds = sounds,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
after_place_node = function(pos, placer, itemstack)
|
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("owner",placer:get_player_name())
|
||||||
meta:set_string("infotext","Pedestal (owned by "..placer:get_player_name()..")")
|
meta:set_string("infotext","Pedestal (owned by "..placer:get_player_name()..")")
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
if not itemstack then return end
|
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
|
if clicker:get_player_name() == meta:get_string("owner") then
|
||||||
drop_item(pos,node)
|
drop_item(pos,node)
|
||||||
local s = itemstack:take_item()
|
local s = itemstack:take_item()
|
||||||
@ -176,13 +175,13 @@ function itemframes.register_pedestal(subname, recipeitem, groups, images, descr
|
|||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_punch = function(pos,node,puncher)
|
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
|
if puncher:get_player_name() == meta:get_string("owner") then
|
||||||
drop_item(pos,node)
|
drop_item(pos,node)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
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")
|
return player:get_player_name() == meta:get_string("owner")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user