Make powered rails act like conductors

This commit is contained in:
Wuzzy 2017-08-28 17:06:25 +02:00
parent 36319afbbe
commit c9856dbcdf
1 changed files with 4 additions and 30 deletions

View File

@ -33,22 +33,8 @@ minetest.register_craft({
} }
}) })
-- Function that get the input/output rules of the powered rails
local get_input_rules = function()
return {
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 1},
}
end
local get_output_rules = function()
return {}
end
-- Powered rail -- Powered rail
local powered_rail_template = { local powered_rail_template = {
description = "Powered Rail", description = "Powered Rail",
_doc_items_longdesc = "Rails can be used to build transport tracks for minecarts. Powered rails are able to accelerate and brake minecarts.", _doc_items_longdesc = "Rails can be used to build transport tracks for minecarts. Powered rails are able to accelerate and brake minecarts.",
@ -68,15 +54,9 @@ local powered_rail_template = {
sounds = mcl_sounds.node_sound_metal_defaults(), sounds = mcl_sounds.node_sound_metal_defaults(),
mesecons = { mesecons = {
effector = { conductor = {
action_on = function(pos, node)
minetest.swap_node(pos, {name = "mcl_minecarts:golden_rail_on", param2 = node.param2 })
mesecon:receptor_on(pos, get_input_rules())
end,
},
receptor = {
state = mesecon.state.off, state = mesecon.state.off,
rules = get_output_rules, onstate = "mcl_minecarts:golden_rail_on",
}, },
}, },
@ -99,15 +79,9 @@ powered_rail_on.wield_image = "mcl_minecarts_rail_golden_powered.png"
powered_rail_on.groups.not_in_creative_inventory = 1 powered_rail_on.groups.not_in_creative_inventory = 1
powered_rail_on.groups.transport = nil powered_rail_on.groups.transport = nil
powered_rail_on.mesecons = { powered_rail_on.mesecons = {
effector = { conductor = {
action_off = function(pos, node)
minetest.swap_node(pos, {name = "mcl_minecarts:golden_rail", param2 = node.param2 })
mesecon:receptor_off(pos, get_input_rules())
end,
},
receptor = {
state = mesecon.state.on, state = mesecon.state.on,
rules = get_output_rules, offstate = "mcl_minecarts:golden_rail",
} }
} }
powered_rail_on._rail_acceleration = 4 powered_rail_on._rail_acceleration = 4