2018-03-10 22:14:57 +01:00
|
|
|
--[[
|
|
|
|
|
|
|
|
Tube Library
|
|
|
|
============
|
|
|
|
|
2020-11-20 14:45:28 +01:00
|
|
|
Copyright (C) 2017-2020 Joachim Stolberg
|
2018-03-10 22:14:57 +01:00
|
|
|
|
2020-11-20 14:45:28 +01:00
|
|
|
AGPL v3
|
2018-03-10 22:14:57 +01:00
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
blackhole.lua:
|
|
|
|
|
|
|
|
Simple node which lets all items disappear.
|
|
|
|
The blackhole supports the following message:
|
|
|
|
- topic = "status", payload = nil,
|
|
|
|
response is the number of disappeared items (0..n)
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- +--------+
|
|
|
|
-- / /|
|
|
|
|
-- +--------+ |
|
|
|
|
-- IN (L) -->| BLACK | |
|
|
|
|
-- | HOLE | +
|
|
|
|
-- | |/
|
|
|
|
-- +--------+
|
|
|
|
|
2020-11-03 20:19:38 +01:00
|
|
|
-- Load support for I18n
|
|
|
|
local S = tubelib.S
|
2018-03-10 22:14:57 +01:00
|
|
|
|
|
|
|
minetest.register_node("tubelib:blackhole", {
|
2020-11-03 20:19:38 +01:00
|
|
|
description = S("Tubelib Black Hole"),
|
2018-03-10 22:14:57 +01:00
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
'tubelib_front.png',
|
|
|
|
'tubelib_front.png',
|
|
|
|
'tubelib_black_hole.png',
|
|
|
|
'tubelib_black_hole_inp.png',
|
|
|
|
"tubelib_black_hole.png",
|
|
|
|
"tubelib_black_hole.png",
|
|
|
|
},
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local number = tubelib.add_node(pos, "tubelib:blackhole") -- <<=== tubelib
|
|
|
|
meta:set_string("number", number)
|
|
|
|
meta:set_int("disappeared", 0)
|
2020-11-03 20:19:38 +01:00
|
|
|
meta:set_string("infotext", "0 "..S("items disappeared"))
|
2018-03-10 22:14:57 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
after_dig_node = function(pos)
|
|
|
|
tubelib.remove_node(pos) -- <<=== tubelib
|
|
|
|
end,
|
|
|
|
|
2018-03-31 17:09:16 +02:00
|
|
|
on_rotate = screwdriver.disallow,
|
2018-03-10 22:14:57 +01:00
|
|
|
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:blackhole 2",
|
|
|
|
recipe = {
|
|
|
|
{"group:wood", "", "group:wood"},
|
2018-12-31 14:59:02 +01:00
|
|
|
{"tubelib:tubeS", "default:coal_lump", "default:coal_lump"},
|
2018-03-10 22:14:57 +01:00
|
|
|
{"group:wood", "", "group:wood"},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
--------------------------------------------------------------- tubelib
|
|
|
|
tubelib.register_node("tubelib:blackhole", {}, {
|
|
|
|
on_pull_item = nil, -- not needed
|
|
|
|
on_unpull_item = nil, -- not needed
|
|
|
|
|
2021-01-23 18:41:09 +01:00
|
|
|
valid_sides = {"L"},
|
2018-03-10 22:14:57 +01:00
|
|
|
on_push_item = function(pos, side, item)
|
2021-01-22 02:48:23 +01:00
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local disappeared = meta:get_int("disappeared") + item:get_count()
|
|
|
|
meta:set_int("disappeared", disappeared)
|
|
|
|
meta:set_string("infotext", disappeared.." "..S("items disappeared"))
|
|
|
|
return true
|
2018-03-10 22:14:57 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
on_recv_message = function(pos, topic, payload)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if topic == "state" then
|
2019-01-06 15:03:22 +01:00
|
|
|
local meta = minetest.get_meta(pos)
|
2018-03-10 22:14:57 +01:00
|
|
|
return meta:get_int("disappeared")
|
|
|
|
else
|
|
|
|
return "not supported"
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
--------------------------------------------------------------- tubelib
|