2017-09-28 11:45:24 -07:00
|
|
|
--[[
|
|
|
|
|
|
|
|
Tube Library
|
|
|
|
============
|
|
|
|
|
|
|
|
Copyright (C) 2017 Joachim Stolberg
|
|
|
|
|
|
|
|
LGPLv2.1+
|
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
blackhole.lua:
|
|
|
|
|
|
|
|
Simple node which lets all items disappear.
|
|
|
|
The blackhole supports the following message:
|
2017-10-02 04:15:30 -07:00
|
|
|
- topic = "status", payload = nil,
|
|
|
|
response is the number of disappeared items (0..n)
|
2017-09-28 11:45:24 -07:00
|
|
|
]]--
|
|
|
|
|
|
|
|
-- +--------+
|
|
|
|
-- / /|
|
|
|
|
-- +--------+ |
|
2017-10-04 07:45:02 -07:00
|
|
|
-- IN (L) -->| BLACK | |
|
2017-09-28 11:45:24 -07:00
|
|
|
-- | HOLE | +
|
|
|
|
-- | |/
|
|
|
|
-- +--------+
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_node("tubelib:blackhole", {
|
|
|
|
description = "Tubelib Black Hole",
|
|
|
|
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)
|
2017-10-08 13:01:58 -07:00
|
|
|
local number = tubelib.add_node(pos, "tubelib:blackhole") -- <<=== tubelib
|
2017-09-28 11:45:24 -07:00
|
|
|
meta:set_string("number", number)
|
|
|
|
meta:set_int("disappeared", 0)
|
|
|
|
meta:set_string("infotext","0 items disappeared")
|
|
|
|
end,
|
|
|
|
|
|
|
|
after_dig_node = function(pos)
|
2017-10-08 13:01:58 -07:00
|
|
|
tubelib.remove_node(pos) -- <<=== tubelib
|
2017-09-28 11:45:24 -07:00
|
|
|
end,
|
|
|
|
|
2018-08-09 06:00:40 -07:00
|
|
|
on_rotate = screwdriver.disallow,
|
2017-10-29 08:03:25 -07:00
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
2017-09-28 11:45:24 -07:00
|
|
|
paramtype2 = "facedir",
|
2018-01-04 12:58:43 -08:00
|
|
|
groups = {choppy=2, cracky=2, crumbly=2},
|
2017-09-28 11:45:24 -07:00
|
|
|
is_ground_content = false,
|
2017-10-29 08:17:11 -07:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
2017-09-28 11:45:24 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "tubelib:blackhole 2",
|
|
|
|
recipe = {
|
2017-10-08 13:01:58 -07:00
|
|
|
{"group:wood", "", "group:wood"},
|
|
|
|
{"tubelib:tube1", "default:coal_lump", "default:coal_lump"},
|
|
|
|
{"group:wood", "", "group:wood"},
|
2017-09-28 11:45:24 -07:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
--------------------------------------------------------------- tubelib
|
|
|
|
tubelib.register_node("tubelib:blackhole", {}, {
|
|
|
|
on_pull_item = nil, -- not needed
|
|
|
|
on_unpull_item = nil, -- not needed
|
|
|
|
|
|
|
|
on_push_item = function(pos, side, item)
|
|
|
|
if side == "L" then
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local disappeared = meta:get_int("disappeared") + 1
|
|
|
|
meta:set_int("disappeared", disappeared)
|
|
|
|
meta:set_string("infotext", disappeared.." items disappeared")
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_recv_message = function(pos, topic, payload)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if topic == "state" then
|
|
|
|
return meta:get_int("disappeared")
|
|
|
|
else
|
|
|
|
return "not supported"
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
--------------------------------------------------------------- tubelib
|