-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Teleport tube listings for stored teleport tube (#50)
- Loading branch information
Showing
4 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
-- | ||
-- Register fallback node handler (wildcard node) for tubetool | ||
-- | ||
|
||
local ns = metatool.ns('tubetool') | ||
|
||
--luacheck: ignore unused argument node player | ||
return { | ||
name = '*', | ||
nodes = '*', | ||
tooldef = { | ||
group = '*', | ||
|
||
before_read = function() return false end, | ||
before_write = function() return false end, | ||
before_info = function() return true end, | ||
copy = function() end, | ||
paste = function() end, | ||
|
||
info = function(node, pos, player, itemstack) | ||
-- Display teleport tubes form if tool has teleport tube data | ||
local tooldata = metatool.read_data(itemstack) | ||
if not tooldata or tooldata.group ~= 'teleport tube' then return end | ||
if not ns.pipeworks_tptube_api_check(player) then return end | ||
|
||
local channel = tooldata.data.channel | ||
if channel == "" then | ||
minetest.chat_send_player( | ||
player:get_player_name(), | ||
'Invalid channel, impossible to list connected tubes.' | ||
) | ||
return | ||
end | ||
local db = pipeworks.tptube.get_db() | ||
local tubes = {} | ||
for hash,data in pairs(db) do | ||
if data.channel == channel then | ||
table.insert(tubes, { | ||
pos = minetest.get_position_from_hash(hash), | ||
can_receive = data.cr == 1, | ||
}) | ||
end | ||
end | ||
metatool.form.show(player, 'tubetool:teleport_tube_list', {pos = pos, channel = channel, tubes = tubes}) | ||
end, | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters