minetest-mm/mods/techpack/tubelib_addons3/teleporter.lua

80 lines
2.2 KiB
Lua
Raw Permalink Normal View History

2020-11-15 20:25:38 +01:00
--[[
Tubelib Addons 3
================
2020-11-20 19:20:28 +01:00
Copyright (C) 2017-2020 Joachim Stolberg
2020-11-15 20:25:38 +01:00
2020-11-20 19:20:28 +01:00
AGPL v3
2020-11-15 20:25:38 +01:00
See LICENSE.txt for more information
teleporter.lua
A node, moving items to the peer teleporter node.
]]--
2020-11-20 19:20:28 +01:00
-- Load support for I18n
local S = tubelib_addons3.S
2021-01-17 18:42:05 +01:00
local M = minetest.get_meta
2020-11-20 19:20:28 +01:00
2020-11-15 20:25:38 +01:00
local Tube = tubelib.Tube
local sFormspec = "size[7.5,3]"..
2020-11-20 19:20:28 +01:00
"field[0.5,1;7,1;channel;"..S("Enter channel string")..";]" ..
"button_exit[2,2;3,1;exit;"..S("Save").."]"
2020-11-15 20:25:38 +01:00
minetest.register_node("tubelib_addons3:teleporter", {
2020-11-20 19:20:28 +01:00
description = S("Tubelib Teleporter"),
2020-11-15 20:25:38 +01: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")
-- determine the tube side
2021-01-25 11:10:54 +01:00
local tube_dir = tubelib2.side_to_dir("R", minetest.dir_to_facedir(placer:get_look_dir()))
2020-11-15 20:25:38 +01:00
Tube:prepare_pairing(pos, tube_dir, sFormspec)
Tube:after_place_node(pos, {tube_dir})
end,
on_receive_fields = function(pos, formname, fields, player)
if fields.channel ~= nil then
Tube:pairing(pos, fields.channel)
end
end,
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})
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", ""},
{"default:mese_crystal", "default:mese_crystal", "tubelib:tubeS"},
{"default:gold_ingot", "group:wood", ""},
},
})
2021-01-25 11:10:54 +01:00
Tube:add_secondary_node_names({"tubelib_addons3:teleporter"})
Tube:set_valid_sides("tubelib_addons3:teleporter", {"R"})