99 lines
3.3 KiB
Lua
99 lines
3.3 KiB
Lua
|
|
local dbg
|
|
if moddebug then dbg=moddebug.dbg("railcarts") else dbg={v1=function() end,v2=function() end,v3=function() end} end
|
|
|
|
minetest.register_craft({
|
|
output = "railcarts:controlrail 12",
|
|
recipe = {
|
|
{"default:steel_ingot", "", "default:steel_ingot"},
|
|
{"default:steel_ingot", "default:stick", "default:steel_ingot"},
|
|
{"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
|
|
}
|
|
})
|
|
|
|
minetest.register_node("railcarts:controlrail", {
|
|
description = "Control Rail",
|
|
drawtype = "raillike",
|
|
tiles = {"railcarts_pa_carts_rail_pwr.png",
|
|
"railcarts_pa_carts_rail_curved_pwr.png",
|
|
"railcarts_pa_carts_rail_t_junction_pwr.png",
|
|
"railcarts_pa_carts_rail_crossing_pwr.png"},
|
|
inventory_image = "railcarts_pa_carts_rail_pwr.png",
|
|
wield_image = "railcarts_pa_carts_rail_pwr.png",
|
|
paramtype = "light",
|
|
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 = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1,connect_to_raillike=1},
|
|
|
|
mesecons = {
|
|
effector = {
|
|
action_on = function(pos, node)
|
|
node.name = "railcarts:controlrail_off"
|
|
minetest.swap_node(pos, node)
|
|
end
|
|
}
|
|
},
|
|
on_construct = function(pos)
|
|
local meta = minetest.get_meta(pos)
|
|
meta:set_string("formspec",
|
|
"field[fn;Control;${infotext}]")
|
|
meta:set_string("infotext", "speedup")
|
|
end,
|
|
on_receive_fields = function(pos, formname, fields, sender)
|
|
if fields and fields.fn then
|
|
dbg.v2("Control rail at "..postostr(pos).." set to "..fields.fn.." by "..(sender:get_player_name() or ""))
|
|
local meta = minetest.get_meta(pos)
|
|
meta:set_string("infotext", fields.fn)
|
|
end
|
|
end
|
|
})
|
|
|
|
minetest.register_node("railcarts:controlrail_off", {
|
|
description = "Control Rail",
|
|
drawtype = "raillike",
|
|
tiles = {"railcarts_pa_carts_rail_brk.png",
|
|
"railcarts_pa_carts_rail_curved_brk.png",
|
|
"railcarts_pa_carts_rail_t_junction_brk.png",
|
|
"railcarts_pa_carts_rail_crossing_brk.png"},
|
|
drop = 'railcarts:controlrail 1',
|
|
paramtype = "light",
|
|
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 = {bendy=2,snappy=1,dig_immediate=2,attached_node=1,rail=1,connect_to_raillike=1},
|
|
|
|
mesecons = {
|
|
effector = {
|
|
action_off = function(pos, node)
|
|
node.name = "railcarts:controlrail"
|
|
minetest.swap_node(pos, node)
|
|
end
|
|
}
|
|
},
|
|
on_construct = controlrail_construct,
|
|
on_receive_fields = controlrail_receive
|
|
})
|
|
|
|
function controlrail_construct(pos)
|
|
local meta = minetest.get_meta(pos)
|
|
meta:set_string("formspec",
|
|
"field[fn;Control;${infotext}]")
|
|
meta:set_string("infotext", "speedup")
|
|
end
|
|
|
|
function controlrail_receive(pos, formname, fields, sender)
|
|
if fields and fields.fn then
|
|
dbg.v2("Control rail at "..postostr(pos).." set to "..fields.fn.." by "..(sender:get_player_name() or ""))
|
|
local meta = minetest.get_meta(pos)
|
|
meta:set_string("infotext", fields.fn)
|
|
end
|
|
end
|
|
|