Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 87 additions & 34 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,17 @@ minetest.register_craft({
-- Mesecon support
--

get_rail_rules = function()
rules = {}
for y = -1, 1 do
table.insert(rules,{x = -1, y = y, z = 0})
table.insert(rules,{x = 1, y = y, z = 0})
table.insert(rules,{x = 0, y = y, z = -1})
table.insert(rules,{x = 0, y = y, z = 1})
end
return rules
end

minetest.register_node(":default:rail", {
description = "Rail",
drawtype = "raillike",
Expand All @@ -456,7 +467,7 @@ minetest.register_node(":default:rail", {
-- 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 = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1},
groups = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1,connect_to_raillike=1},
})

minetest.register_node("carts:powerrail", {
Expand All @@ -473,25 +484,46 @@ minetest.register_node("carts:powerrail", {
-- 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 = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1},

after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.env:get_meta(pos):set_string("cart_acceleration", "0.5")
end
end,
groups = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1,connect_to_raillike=1},

mesecons = {
effector = {
action_on = function(pos, node)
minetest.env:get_meta(pos):set_string("cart_acceleration", "0.5")
end,

action_off = function(pos, node)
minetest.env:get_meta(pos):set_string("cart_acceleration", "0")
end,
},
conductor = {
state = mesecon.state.off,
onstate = "carts:powerrail_on",
rules = get_rail_rules()
}
},
on_construct = function(pos)
minetest.env:get_meta(pos):set_string("cart_acceleration", "0")
end
})

minetest.register_node("carts:powerrail_on", {
description = "Powered Rail (you hacker you!)",
drawtype = "raillike",
tiles = {"carts_rail_pwr_on.png", "carts_rail_curved_pwr_on.png", "carts_rail_t_junction_pwr_on.png", "carts_rail_crossing_pwr_on.png"},
inventory_image = "carts_rail_pwr_on.png",
wield_image = "carts_rail_pwr_on.png",
paramtype = "light",
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 = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1,connect_to_raillike=1,not_in_creative_inventory=1},
drop = "carts:powerrail",
mesecons = {
conductor = {
state = mesecon.state.on,
offstate = "carts:powerrail",
rules = get_rail_rules()
}
},
on_construct = function(pos)
minetest.env:get_meta(pos):set_string("cart_acceleration", "0.5")
end
})

minetest.register_node("carts:brakerail", {
Expand All @@ -508,25 +540,46 @@ minetest.register_node("carts:brakerail", {
-- 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 = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1},

after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.env:get_meta(pos):set_string("cart_acceleration", "-0.2")
end
end,

groups = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1,connect_to_raillike=1},

mesecons = {
effector = {
action_on = function(pos, node)
minetest.env:get_meta(pos):set_string("cart_acceleration", "-0.2")
end,

action_off = function(pos, node)
minetest.env:get_meta(pos):set_string("cart_acceleration", "0")
end,
},
conductor = {
state = mesecon.state.off,
onstate = "carts:brakerail_on",
rules = get_rail_rules()
}
},
on_construct = function(pos)
minetest.env:get_meta(pos):set_string("cart_acceleration", "0")
end
})

minetest.register_node("carts:brakerail_on", {
description = "Brake Rail (you hacker you!)",
drawtype = "raillike",
tiles = {"carts_rail_brk_on.png", "carts_rail_curved_brk_on.png", "carts_rail_t_junction_brk_on.png", "carts_rail_crossing_brk_on.png"},
inventory_image = "carts_rail_brk_on.png",
wield_image = "carts_rail_brk_on.png",
paramtype = "light",
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 = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1,connect_to_raillike=1,not_in_creative_inventory=1},
drop = "carts:brakerail",
mesecons = {
conductor = {
state = mesecon.state.on,
offstate = "carts:brakerail",
rules = get_rail_rules()
}
},
on_construct = function(pos)
minetest.env:get_meta(pos):set_string("cart_acceleration", "-0.2")
end
})

minetest.register_craft({
Expand Down
Binary file modified textures/carts_rail_brk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_brk_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/carts_rail_crossing_brk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_crossing_brk_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/carts_rail_crossing_pwr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_crossing_pwr_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/carts_rail_curved_brk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_curved_brk_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/carts_rail_curved_pwr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_curved_pwr_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/carts_rail_pwr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_pwr_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/carts_rail_t_junction_brk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_t_junction_brk_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/carts_rail_t_junction_pwr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/carts_rail_t_junction_pwr_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.