1
0
mirror of https://github.com/SmallJoker/boost_cart.git synced 2024-11-15 07:10:20 +01:00
boost_cart/detector.lua

51 lines
2.0 KiB
Lua
Raw Normal View History

2015-06-01 20:21:42 +02:00
local mesecons_rules = mesecon.rules.flat
function boost_cart:turnoff_detector_rail(pos)
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "detector_rail") == 1 then
if node.name == "boost_cart:detectorrail_on" then --has not been dug
2015-06-01 20:21:42 +02:00
minetest.swap_node(pos, {name = "boost_cart:detectorrail", param2=node.param2})
end
2015-11-01 20:12:16 +01:00
mesecon.receptor_off(pos, mesecons_rules)
2015-06-01 20:21:42 +02:00
end
end
function boost_cart:signal_detector_rail(pos)
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "detector_rail") ~= 1 then
return
end
--minetest.log("action", "Signaling detector at " .. minetest.pos_to_string(pos))
2015-06-01 20:21:42 +02:00
if node.name == "boost_cart:detectorrail" then
minetest.swap_node(pos, {name = "boost_cart:detectorrail_on", param2=node.param2})
end
2015-11-01 20:12:16 +01:00
mesecon.receptor_on(pos, mesecons_rules)
2015-06-01 20:21:42 +02:00
minetest.after(0.5, boost_cart.turnoff_detector_rail, boost_cart, pos)
end
boost_cart:register_rail("boost_cart:detectorrail", {
2015-06-01 20:21:42 +02:00
description = "Detector rail",
tiles = {"carts_rail_dtc.png", "carts_rail_curved_dtc.png", "carts_rail_t_junction_dtc.png", "carts_rail_crossing_dtc.png"},
groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1, detector_rail = 1},
2015-06-01 20:21:42 +02:00
mesecons = {receptor = {state = "off", rules = mesecons_rules }},
})
boost_cart:register_rail("boost_cart:detectorrail_on", {
2015-06-01 20:21:42 +02:00
description = "Detector rail ON (you hacker you)",
tiles = {"carts_rail_dtc_on.png", "carts_rail_curved_dtc_on.png", "carts_rail_t_junction_dtc_on.png", "carts_rail_crossing_dtc_on.png"},
groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1, detector_rail = 1, not_in_creative_inventory = 1},
drop = "boost_cart:detectorrail",
2015-06-01 20:21:42 +02:00
mesecons = {receptor = {state = "on", rules = mesecons_rules }},
})
minetest.register_craft({
output = "boost_cart:detectorrail 6",
recipe = {
2015-09-29 18:20:46 +02:00
{"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"},
2015-06-01 20:21:42 +02:00
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
2015-09-29 18:20:46 +02:00
{"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"},
2015-06-01 20:21:42 +02:00
},
})