Wireless porter fix

This commit is contained in:
Evert Prants 2020-05-25 16:18:53 +03:00
parent 875cbd7701
commit 1b9a5c63fb
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 7 additions and 12 deletions

View File

@ -58,6 +58,7 @@ ele.register_tool("elepower_wireless:wireless_porter", {
on_place = function(itemstack, placer, pointed_thing)
if not placer or placer:get_player_name() == "" then return itemstack end
local player = placer:get_player_name()
local pos = pointed_thing.under
if minetest.is_protected(pos, player) then
minetest.chat_send_player(player, "You are not allowed to teleport here!")
@ -65,21 +66,23 @@ ele.register_tool("elepower_wireless:wireless_porter", {
end
local meta = itemstack:get_meta()
local pos = pointed_thing.under
local node = minetest.get_node_or_nil(pos)
if not node or not ele.helpers.get_item_group(node.name, "matter_receiver") then return itemstack end
if not node or not ele.helpers.get_item_group(node.name, "matter_receiver") then
minetest.chat_send_player(player, "Use on a Matter Receiver to bind teleport location!")
return itemstack
end
local strpos = minetest.pos_to_string(pos)
local curpos = minetest.string_to_pos(meta:get_string("receiver"))
if (curpos and curpos ~= "") and curpos == pos then
if curpos and vector.equals(curpos, pos) then
minetest.chat_send_player(player, "Wireless Porter is already bound to this location!")
return itemstack
end
meta:set_string("receiver", strpos)
minetest.chat_send_player(player, ("Wireless Porter bound to %s!"):format(strpos))
minetest.chat_send_player(player, ("Wireless Porter bound to receiver at %s!"):format(strpos))
return itemstack
end,

View File

@ -1,11 +1,3 @@
--[[
Wireless Station:
Wireless Card -> Bind to node -> Add to station
Name the station to keep track
]]
elewi.node_handlers = {}
local desc_cache = {}