mirror of
https://github.com/SmallJoker/boost_cart.git
synced 2024-12-26 10:50:18 +01:00
Neated the code
This commit is contained in:
parent
dfba110eef
commit
ccbc32a52c
27
detector.lua
27
detector.lua
@ -1,13 +1,12 @@
|
|||||||
local mesecons_rules = mesecon.rules.flat
|
local mesecons_rules = mesecon.rules.flat
|
||||||
|
|
||||||
--local
|
function boost_cart:turnoff_detector_rail(pos)
|
||||||
function turnoff_detector_rail(pos)
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if minetest.get_item_group(node.name, "detector_rail") == 1 then
|
if minetest.get_item_group(node.name, "detector_rail") == 1 then
|
||||||
if node.name=="carts:detectrail_on" then --has not been dug
|
if node.name=="boost_cart:detectorrail_on" then --has not been dug
|
||||||
minetest.swap_node(pos, {name = "carts:detectrail", param2=node.param2})
|
minetest.swap_node(pos, {name = "boost_cart:detectorrail", param2=node.param2})
|
||||||
end
|
end
|
||||||
mesecon.receptor_off(pos, mesecon.rules.flat)
|
mesecon.receptor_off(pos, mesecon_rules)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -16,15 +15,15 @@ function boost_cart:signal_detector_rail(pos)
|
|||||||
if minetest.get_item_group(node.name, "detector_rail") ~= 1 then
|
if minetest.get_item_group(node.name, "detector_rail") ~= 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
print("Signaling detector at " .. vector.tostr(pos))
|
minetest.log("action", "Signaling detector at " .. vector.tostr(pos))
|
||||||
if node.name == "carts:detectrail" then
|
if node.name == "boost_cart:detectorrail" then
|
||||||
minetest.swap_node(pos, {name = "carts:detectrail_on", param2=node.param2})
|
minetest.swap_node(pos, {name = "boost_cart:detectorrail_on", param2=node.param2})
|
||||||
end
|
end
|
||||||
mesecon.receptor_on(pos, mesecon.rules.flat)
|
mesecon.receptor_on(pos, mesecon_rules)
|
||||||
minetest.after(0.5, turnoff_detector_rail, pos)
|
minetest.after(0.5, boost_cart.turnoff_detector_rail, boost_cart, pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node(":carts:detectrail", {
|
minetest.register_node("boost_cart:detectorrail", {
|
||||||
description = "Detector rail",
|
description = "Detector rail",
|
||||||
drawtype = "raillike",
|
drawtype = "raillike",
|
||||||
tiles = {"carts_rail_dtc.png", "carts_rail_curved_dtc.png", "carts_rail_t_junction_dtc.png", "carts_rail_crossing_dtc.png"},
|
tiles = {"carts_rail_dtc.png", "carts_rail_curved_dtc.png", "carts_rail_t_junction_dtc.png", "carts_rail_crossing_dtc.png"},
|
||||||
@ -43,7 +42,7 @@ minetest.register_node(":carts:detectrail", {
|
|||||||
mesecons = {receptor = {state = "off", rules = mesecons_rules }},
|
mesecons = {receptor = {state = "off", rules = mesecons_rules }},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node(":carts:detectrail_on", {
|
minetest.register_node("boost_cart:detectorrail_on", {
|
||||||
description = "Detector rail ON (you hacker you)",
|
description = "Detector rail ON (you hacker you)",
|
||||||
drawtype = "raillike",
|
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"},
|
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"},
|
||||||
@ -59,13 +58,13 @@ minetest.register_node(":carts:detectrail_on", {
|
|||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
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},
|
groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1, detector_rail = 1, not_in_creative_inventory = 1},
|
||||||
drop = "carts:detectrail",
|
drop = "boost_cart:detectorrail",
|
||||||
|
|
||||||
mesecons = {receptor = {state = "on", rules = mesecons_rules }},
|
mesecons = {receptor = {state = "on", rules = mesecons_rules }},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "carts:detectrail 6",
|
output = "boost_cart:detectorrail 6",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"default:steel_ingot", "mesecon:mesecon", "default:steel_ingot"},
|
{"default:steel_ingot", "mesecon:mesecon", "default:steel_ingot"},
|
||||||
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
|
{"default:steel_ingot", "group:stick", "default:steel_ingot"},
|
||||||
|
Loading…
Reference in New Issue
Block a user