48 lines
1.4 KiB
Lua
48 lines
1.4 KiB
Lua
|
|
local dbg
|
|
if moddebug then dbg=moddebug.dbg("railcarts") else dbg={v1=function() end,v2=function() end,v3=function() end} end
|
|
|
|
minetest.register_craft({
|
|
output = "railcarts:cart_detector",
|
|
recipe = {
|
|
{"", "", ""},
|
|
{"default:mese_crystal", "", "default:mese_crystal"},
|
|
{"default:mese_crystal", "default:mese_crystal", "default:mese_crystal"},
|
|
},
|
|
}
|
|
)
|
|
minetest.register_node("railcarts:cart_detector", {
|
|
description = "Cart Detector",
|
|
tiles = {"railcarts_cart_detector.png"},
|
|
is_ground_content = true,
|
|
groups = {cracky=3, mesecon=2},
|
|
drop = 'railcarts:cart_detector 1',
|
|
mesecons = { receptor = {
|
|
state = "off"
|
|
} }
|
|
})
|
|
|
|
minetest.register_node("railcarts:cart_detector_on", {
|
|
description = "Cart Detector",
|
|
tiles = {"railcarts_cart_detector.png"},
|
|
is_ground_content = true,
|
|
groups = {cracky=3, mesecon=2},
|
|
drop = 'railcarts:cart_detector 1',
|
|
mesecons = { receptor = {
|
|
state = "on"
|
|
} }
|
|
})
|
|
|
|
minetest.register_abm({
|
|
nodenames = {"railcarts:cart_detector_on"},
|
|
interval = 2,
|
|
chance = 1,
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
minetest.add_node(pos,{name="railcarts:cart_detector"})
|
|
mesecon:receptor_off(pos, mesecon.rules.default)
|
|
dbg.v2("Cart detector off at: "..minetest.pos_to_string(pos))
|
|
end
|
|
})
|
|
|
|
|