1
0
mirror of https://github.com/SmallJoker/boost_cart.git synced 2025-06-30 15:30:21 +02:00

Add boost_cart:register_rail(name, def)

This commit is contained in:
SmallJoker
2015-06-05 20:00:53 +02:00
parent adfcfe0841
commit a7fd733819
4 changed files with 46 additions and 85 deletions

View File

@ -3,7 +3,7 @@ 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
if node.name == "boost_cart:detectorrail_on" then --has not been dug
minetest.swap_node(pos, {name = "boost_cart:detectorrail", param2=node.param2})
end
mesecon.receptor_off(pos, mesecon_rules)
@ -15,7 +15,7 @@ function boost_cart:signal_detector_rail(pos)
if minetest.get_item_group(node.name, "detector_rail") ~= 1 then
return
end
minetest.log("action", "Signaling detector at " .. vector.tostr(pos))
--minetest.log("action", "Signaling detector at " .. minetest.pos_to_string(pos))
if node.name == "boost_cart:detectorrail" then
minetest.swap_node(pos, {name = "boost_cart:detectorrail_on", param2=node.param2})
end
@ -23,43 +23,20 @@ function boost_cart:signal_detector_rail(pos)
minetest.after(0.5, boost_cart.turnoff_detector_rail, boost_cart, pos)
end
minetest.register_node("boost_cart:detectorrail", {
boost_cart:register_rail("boost_cart:detectorrail", {
description = "Detector rail",
drawtype = "raillike",
tiles = {"carts_rail_dtc.png", "carts_rail_curved_dtc.png", "carts_rail_t_junction_dtc.png", "carts_rail_crossing_dtc.png"},
inventory_image = "carts_rail_dtc.png",
wield_image = "carts_rail_dtc.png",
paramtype = "light",
sunlight_propagates = true,
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1, detector_rail = 1},
mesecons = {receptor = {state = "off", rules = mesecons_rules }},
})
minetest.register_node("boost_cart:detectorrail_on", {
boost_cart:register_rail("boost_cart:detectorrail_on", {
description = "Detector rail ON (you hacker you)",
drawtype = "raillike",
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"},
inventory_image = "carts_rail_dtc_on.png",
wield_image = "carts_rail_dtc_on.png",
paramtype = "light",
sunlight_propagates = true,
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
-- but how to specify the dimensions for curved and sideways rails?
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
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",
mesecons = {receptor = {state = "on", rules = mesecons_rules }},
})