1 -- Template rail function
2 local register_rail
= function(itemstring
, tiles
, def_extras
, creative
)
3 local groups
= {handy
=1,pickaxey
=1, attached_node
=1,rail
=1,connect_to_raillike
=1,dig_by_water
=1,destroy_by_lava_flow
=1, transport
=1}
4 if creative
== false then
5 groups
.not_in_creative_inventory
= 1
10 is_ground_content
= false,
11 inventory_image
= tiles
[1],
12 wield_image
= tiles
[1],
17 fixed
= {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
21 sounds
= mcl_sounds
.node_sound_metal_defaults(),
22 _mcl_blast_resistance
= 3.5,
24 after_destruct
= function(pos
)
25 -- Scan for minecarts in this pos and force them to execute their "floating" check.
26 -- Normally, this will make them drop.
27 local objs
= minetest
.get_objects_inside_radius(pos
, 1)
29 local le
= objs
[o
]:get_luaentity()
31 -- All entities in this mod are minecarts, so this works
32 if string.sub(le
.name
, 1, 14) == "mcl_minecarts:" then
33 le
._last_float_check
= mcl_minecarts
.check_float_time
40 for k
,v
in pairs(def_extras
) do
44 minetest
.register_node(itemstring
, ndef
)
48 local rail_rules_long
=
49 {{x
=-1, y
= 0, z
= 0, spread
=true},
50 {x
= 1, y
= 0, z
= 0, spread
=true},
51 {x
= 0, y
=-1, z
= 0, spread
=true},
52 {x
= 0, y
= 1, z
= 0, spread
=true},
53 {x
= 0, y
= 0, z
=-1, spread
=true},
54 {x
= 0, y
= 0, z
= 1, spread
=true},
65 local rail_rules_short
= mesecon
.rules
.pplate
67 local railuse
= "Place them on the ground to build your railway, the rails will automatically connect to each other and will turn into curves, T-junctions, crossings and slopes as needed."
70 register_rail("mcl_minecarts:rail",
71 {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
74 _doc_items_longdesc
= "Rails can be used to build transport tracks for minecarts. Normal rails slightly slow down minecarts due to friction.",
75 _doc_items_usagehelp
= railuse
,
79 -- Powered rail (off = brake mode)
80 register_rail("mcl_minecarts:golden_rail",
81 {"mcl_minecarts_rail_golden.png", "mcl_minecarts_rail_golden_curved.png", "mcl_minecarts_rail_golden_t_junction.png", "mcl_minecarts_rail_golden_crossing.png"},
83 description
= "Powered Rail",
84 _doc_items_longdesc
= "Rails can be used to build transport tracks for minecarts. Powered rails are able to accelerate and brake minecarts.",
85 _doc_items_usagehelp
= railuse
.. "\n" .. "Without redstone power, the rail will brake minecarts. To make this rail accelerate minecarts, power it with redstone power.",
86 _rail_acceleration
= -3,
89 state
= mesecon
.state
.off
,
90 offstate
= "mcl_minecarts:golden_rail",
91 onstate
= "mcl_minecarts:golden_rail_on",
92 rules
= rail_rules_long
,
98 -- Powered rail (on = acceleration mode)
99 register_rail("mcl_minecarts:golden_rail_on",
100 {"mcl_minecarts_rail_golden_powered.png", "mcl_minecarts_rail_golden_curved_powered.png", "mcl_minecarts_rail_golden_t_junction_powered.png", "mcl_minecarts_rail_golden_crossing_powered.png"},
102 _doc_items_create_entry
= false,
103 _rail_acceleration
= 4,
106 state
= mesecon
.state
.on
,
107 offstate
= "mcl_minecarts:golden_rail",
108 onstate
= "mcl_minecarts:golden_rail_on",
109 rules
= rail_rules_long
,
112 drop
= "mcl_minecarts:golden_rail",
117 -- Activator rail (off)
118 register_rail("mcl_minecarts:activator_rail",
119 {"mcl_minecarts_rail_activator.png", "mcl_minecarts_rail_activator_curved.png", "mcl_minecarts_rail_activator_t_junction.png", "mcl_minecarts_rail_activator_crossing.png"},
121 description
= "Activator Rail",
122 _doc_items_longdesc
= "Rails can be used to build transport tracks for minecarts. Activator rails are used to activate special minecarts.",
123 _doc_items_usagehelp
= railuse
.. "\n" .. "To make this rail activate minecarts, power it with redstone power and send a minecart over this piece of rail.",
126 state
= mesecon
.state
.off
,
127 offstate
= "mcl_minecarts:activator_rail",
128 onstate
= "mcl_minecarts:activator_rail_on",
129 rules
= rail_rules_long
,
133 -- Hidden from creative because no cart is using this rail so far.
134 -- TODO: Remove this when the activator rail has become useful.
138 -- Activator rail (on)
139 register_rail("mcl_minecarts:activator_rail_on",
140 {"mcl_minecarts_rail_activator_powered.png", "mcl_minecarts_rail_activator_curved_powered.png", "mcl_minecarts_rail_activator_t_junction_powered.png", "mcl_minecarts_rail_activator_crossing_powered.png"},
142 _doc_items_create_entry
= false,
145 state
= mesecon
.state
.on
,
146 offstate
= "mcl_minecarts:activator_rail",
147 onstate
= "mcl_minecarts:activator_rail_on",
148 rules
= rail_rules_long
,
151 drop
= "mcl_minecarts:activator_rail",
156 -- Detector rail (off)
157 register_rail("mcl_minecarts:detector_rail",
158 {"mcl_minecarts_rail_detector.png", "mcl_minecarts_rail_detector_curved.png", "mcl_minecarts_rail_detector_t_junction.png", "mcl_minecarts_rail_detector_crossing.png"},
160 description
= "Detector Rail",
161 _doc_items_longdesc
= "Rails can be used to build transport tracks for minecarts. A detector rail is able to detect a minecart above it and powers redstone mechanisms.",
162 _doc_items_usagehelp
= railuse
.. "\n" .. "To detect a minecart and provide redstone power, connect it to redstone trails or redstone mechanisms and send any minecart over the rail.",
165 state
= mesecon
.state
.off
,
166 rules
= rail_rules_short
,
172 -- Detector rail (on)
173 register_rail("mcl_minecarts:detector_rail_on",
174 {"mcl_minecarts_rail_detector_powered.png", "mcl_minecarts_rail_detector_curved_powered.png", "mcl_minecarts_rail_detector_t_junction_powered.png", "mcl_minecarts_rail_detector_crossing_powered.png"},
176 _doc_items_create_entry
= false,
179 state
= mesecon
.state
.on
,
180 rules
= rail_rules_short
,
183 drop
= "mcl_minecarts:detector_rail",
190 minetest
.register_craft({
191 output
= 'mcl_minecarts:rail 16',
193 {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'},
194 {'mcl_core:iron_ingot', 'mcl_core:stick', 'mcl_core:iron_ingot'},
195 {'mcl_core:iron_ingot', '', 'mcl_core:iron_ingot'},
199 minetest
.register_craft({
200 output
= "mcl_minecarts:golden_rail 6",
202 {"mcl_core:gold_ingot", "", "mcl_core:gold_ingot"},
203 {"mcl_core:gold_ingot", "mcl_core:stick", "mcl_core:gold_ingot"},
204 {"mcl_core:gold_ingot", "mesecons:redstone", "mcl_core:gold_ingot"},
208 -- Activator rail crafting is disabled until it becomes useful.
209 -- TODO: Enable crafting as needed.
211 minetest
.register_craft({
212 output
= "mcl_minecarts:activator_rail 6",
214 {"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"},
215 {"mcl_core:iron_ingot", "mesecons_torch:mesecon_torch_on", "mcl_core:iron_ingot"},
216 {"mcl_core:iron_ingot", "mcl_core:stick", "mcl_core:iron_ingot"},
221 minetest
.register_craft({
222 output
= "mcl_minecarts:detector_rail 6",
224 {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"},
225 {"mcl_core:iron_ingot", "mesecons_pressureplates:pressure_plate_stone_off", "mcl_core:iron_ingot"},
226 {"mcl_core:iron_ingot", "mesecons:redstone", "mcl_core:iron_ingot"},
232 if minetest
.get_modpath("doc") then
233 doc
.add_entry_alias("nodes", "mcl_minecarts:golden_rail", "nodes", "mcl_minecarts:golden_rail_on")