techpack/tubelib_addons3/teleporter.lua

80 lines
2.2 KiB
Lua
Raw Normal View History

2018-08-14 21:37:40 +02:00
--[[
Tubelib Addons 3
================
Copyright (C) 2017-2020 Joachim Stolberg
2018-08-14 21:37:40 +02:00
AGPL v3
2018-08-14 21:37:40 +02:00
See LICENSE.txt for more information
teleporter.lua
A node, moving items to the peer teleporter node.
]]--
-- Load support for I18n
local S = tubelib_addons3.S
local M = minetest.get_meta
2018-12-22 16:58:11 +01:00
local Tube = tubelib.Tube
2018-08-14 21:37:40 +02:00
2018-12-22 16:58:11 +01:00
local sFormspec = "size[7.5,3]"..
"field[0.5,1;7,1;channel;"..S("Enter channel string")..";]" ..
"button_exit[2,2;3,1;exit;"..S("Save").."]"
2018-08-14 21:37:40 +02:00
minetest.register_node("tubelib_addons3:teleporter", {
description = S("Tubelib Teleporter"),
2018-08-14 21:37:40 +02:00
tiles = {
-- up, down, right, left, back, front
'tubelib_addons3_chest_bottom.png',
'tubelib_addons3_chest_bottom.png',
'tubelib_addons3_chest_bottom.png^tubelib_hole.png',
'tubelib_addons3_chest_bottom.png^tubelib_addons3_teleporter.png',
'tubelib_addons3_chest_bottom.png^tubelib_addons3_teleporter.png',
'tubelib_addons3_chest_bottom.png^tubelib_addons3_teleporter.png',
},
after_place_node = function(pos, placer)
tubelib.add_node(pos, "tubelib_addons3:teleporter")
2018-12-22 16:58:11 +01:00
-- determine the tube side
2021-01-20 21:36:34 +01:00
local tube_dir = tubelib2.side_to_dir("R", minetest.dir_to_facedir(placer:get_look_dir()))
2018-12-22 16:58:11 +01:00
Tube:prepare_pairing(pos, tube_dir, sFormspec)
Tube:after_place_node(pos, {tube_dir})
2018-08-14 21:37:40 +02:00
end,
on_receive_fields = function(pos, formname, fields, player)
if fields.channel ~= nil then
2018-12-22 16:58:11 +01:00
Tube:pairing(pos, fields.channel)
2018-08-14 21:37:40 +02:00
end
end,
2018-12-22 16:58:11 +01:00
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:stop_pairing(pos, oldmetadata, sFormspec)
local tube_dir = tonumber(oldmetadata.fields.tube_dir or 0)
Tube:after_dig_node(pos, {tube_dir})
2018-08-14 21:37:40 +02:00
end,
on_rotate = screwdriver.disallow,
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "tubelib_addons3:teleporter 2",
recipe = {
{"default:gold_ingot", "group:wood", ""},
2018-12-31 14:59:02 +01:00
{"default:mese_crystal", "default:mese_crystal", "tubelib:tubeS"},
2018-08-14 21:37:40 +02:00
{"default:gold_ingot", "group:wood", ""},
},
})
2021-01-23 18:20:59 +01:00
Tube:add_secondary_node_names({"tubelib_addons3:teleporter"})
Tube:set_valid_sides("tubelib_addons3:teleporter", {"R"})