2017-12-18 12:21:54 +01:00
|
|
|
-- Default tracks for advtrains
|
|
|
|
-- (c) orwell96 and contributors
|
2017-08-20 14:32:38 +02:00
|
|
|
|
2021-11-16 11:33:51 +01:00
|
|
|
local default_boxen = {
|
|
|
|
["st"] = {
|
|
|
|
[""] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2-1/16, -1/2, -1/2, 1/2+1/16, -1/2+2/16, 1/2},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_30"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.000, 0.5000, -0.3750, 1.000},
|
|
|
|
{-0.8750, -0.5000, -1.000, -0.5000, -0.3750, 0.2500},
|
|
|
|
{0.5000, -0.5000, -0.2500, 0.8750, -0.3750, 1.000},
|
|
|
|
{-0.1250, -0.5000, -1.375, 0.1875, -0.3750, -1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_45"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.8750, 0.5000, -0.3750, 0.8750},
|
|
|
|
{0.5000, -0.5000, -0.5000, 0.8750, -0.3750, 0.5000},
|
|
|
|
{-0.8750, -0.5000, -0.5000, -0.5000, -0.3750, 0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_60"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -0.5000, 1.000, -0.3750, 0.5000},
|
|
|
|
{-1.000, -0.5000, -0.8750, 0.2500, -0.3750, -0.5000},
|
|
|
|
{-0.2500, -0.5000, 0.5000, 1.000, -0.3750, 0.8750},
|
|
|
|
{-1.375, -0.5000, -0.1250, -1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
["cr"] = {
|
|
|
|
[""] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.5000, 0.6875, -0.3750, 0.5000},
|
|
|
|
{-0.3750, -0.5000, -1.000, 1.000, -0.3750, 0.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_30"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.5000, 0.7500, -0.3750, 0.8750},
|
|
|
|
{-0.3750, -0.5000, 0.8750, 0.2500, -0.3750, 1.188},
|
|
|
|
{0.7500, -0.5000, 0.2500, 1.063, -0.3750, 0.8750}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_45"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.125, 0.5000, -0.3750, 0.6875},
|
|
|
|
{-0.8750, -0.5000, -0.9375, -0.5000, -0.3750, 0.06250},
|
|
|
|
{0.5000, -0.5000, -0.5000, 0.8750, -0.3750, 0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_60"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.8125, -0.5000, -0.5000, 1.188, -0.3750, 0.5000},
|
|
|
|
{-0.1875, -0.5000, 0.5000, 0.8750, -0.3125, 0.8750},
|
|
|
|
{-0.2500, -0.5000, -0.9375, 0.3125, -0.3125, -0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
["swlst"] = {
|
|
|
|
[""] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.5000, 0.6250, -0.3750, 0.5000},
|
|
|
|
{-0.3125, -0.5000, -1.000, 0.9375, -0.3125, -0.06250}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_30"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.000, 0.5000, -0.3750, 1.000},
|
|
|
|
{-0.8750, -0.5000, -1.000, -0.5000, -0.3750, 0.2500},
|
|
|
|
{0.5000, -0.5000, -0.2500, 0.8750, -0.3750, 1.000},
|
|
|
|
{-0.1250, -0.5000, -1.375, 0.1875, -0.3750, -1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_45"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.1875, 0.5000, -0.3750, 0.8750},
|
|
|
|
{0.5000, -0.5000, -0.5000, 0.8750, -0.3750, 0.5000},
|
|
|
|
{-0.8750, -0.5000, -0.8125, -0.5000, -0.3750, 0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_60"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -0.5000, 1.000, -0.3750, 0.5000},
|
|
|
|
{-1.000, -0.5000, -0.8750, 0.2500, -0.3750, -0.5000},
|
|
|
|
{-0.2500, -0.5000, 0.5000, 1.000, -0.3750, 0.8750},
|
|
|
|
{-1.375, -0.5000, -0.1250, -1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
["swrst"] = {
|
|
|
|
[""] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.5000, 0.6250, -0.3750, 0.5000},
|
|
|
|
{-0.8125, -0.5000, -1.000, 0.4375, -0.3125, -0.06250}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_30"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.000, 0.5000, -0.3750, 1.000},
|
|
|
|
{-0.8750, -0.5000, -1.000, -0.5000, -0.3750, 0.2500},
|
|
|
|
{0.5000, -0.5000, -0.2500, 0.8750, -0.3750, 1.000},
|
|
|
|
{-0.1250, -0.5000, -1.375, 0.1875, -0.3750, -1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_45"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.1875, -0.5000, -0.5000, 0.8750, -0.3750, 0.5000},
|
|
|
|
{-0.5000, -0.5000, 0.5000, 0.5000, -0.3750, 0.8750},
|
|
|
|
{-0.8125, -0.5000, -0.8750, 0.5000, -0.3750, -0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_60"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -0.5000, 1.000, -0.3750, 0.5000},
|
|
|
|
{-1.000, -0.5000, -0.8750, 0.2500, -0.3750, -0.5000},
|
|
|
|
{-0.2500, -0.5000, 0.5000, 1.000, -0.3750, 0.8750},
|
|
|
|
{-1.375, -0.5000, -0.1250, -1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
default_boxen["swlcr"] = default_boxen["swlst"]
|
|
|
|
default_boxen["swrcr"] = default_boxen["swrst"]
|
|
|
|
|
2017-08-20 14:32:38 +02:00
|
|
|
--flat
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack",
|
|
|
|
texture_prefix="advtrains_dtrack",
|
|
|
|
models_prefix="advtrains_dtrack",
|
|
|
|
models_suffix=".b3d",
|
|
|
|
shared_texture="advtrains_dtrack_shared.png",
|
|
|
|
description=attrans("Track"),
|
|
|
|
formats={},
|
2021-11-16 11:33:51 +01:00
|
|
|
|
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
if default_boxen[suffix] ~= nil and default_boxen[suffix][rotation] ~= nil then
|
|
|
|
return default_boxen[suffix][rotation]
|
|
|
|
else
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
end,
|
2017-08-20 14:32:38 +02:00
|
|
|
}, advtrains.ap.t_30deg_flat)
|
2020-07-06 08:57:48 +02:00
|
|
|
|
2020-07-07 18:03:09 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = 'advtrains:dtrack_placer 50',
|
|
|
|
recipe = {
|
|
|
|
{'default:steel_ingot', 'group:stick', 'default:steel_ingot'},
|
|
|
|
{'default:steel_ingot', 'group:stick', 'default:steel_ingot'},
|
|
|
|
{'default:steel_ingot', 'group:stick', 'default:steel_ingot'},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2021-11-16 11:33:51 +01:00
|
|
|
local y3_boxen = {
|
|
|
|
[""] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.8750, -0.5000, -1.125, 0.8750, -0.3750, 0.4375}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
["_30"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.875, 0.5000, -0.3750, 1.000},
|
|
|
|
{-0.8750, -0.5000, -0.4375, -0.5000, -0.3750, 0.5625},
|
|
|
|
{0.5000, -0.5000, -0.2500, 0.8125, -0.3750, 1.000},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
--UX FIXME: - 3way - have to place straight route before l and r or the
|
|
|
|
--nodebox overlaps too much and can't place the straight track node.
|
|
|
|
["_45"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.1250, 0.5000, -0.3750, 0.8750},
|
|
|
|
{0.5000, -0.5000, -0.5000, 0.8750, -0.3750, 0.5000},
|
|
|
|
{-1.1250, -0.5000, -0.9375, -0.5000, -0.3750, 0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
["_60"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
--{-0.5000, -0.5000, -0.875, 0.5000, -0.3750, 1.000},
|
|
|
|
{-0.875, -0.5000, -0.5, 1.0, -0.3750, 0.5},
|
|
|
|
--{-0.8750, -0.5000, -0.4375, -0.5000, -0.3750, 0.5625},
|
|
|
|
{-0.4375, -0.5000, -0.8750, 0.5625, -0.3750, -0.5000},
|
|
|
|
--{0.5000, -0.5000, -0.2500, 0.8125, -0.3750, 1.000},
|
|
|
|
{-0.2500, -0.5000, -0.2500, 1.0000, -0.3750, 0.8125},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local function y3_turnouts_addef(def, preset, suffix, rotation)
|
|
|
|
return y3_boxen[rotation] or {}
|
|
|
|
end
|
2020-09-10 18:40:02 +02:00
|
|
|
-- y-turnout
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_sy",
|
|
|
|
texture_prefix="advtrains_dtrack_sy",
|
|
|
|
models_prefix="advtrains_dtrack_sy",
|
|
|
|
models_suffix=".obj",
|
|
|
|
shared_texture="advtrains_dtrack_shared.png",
|
|
|
|
description=attrans("Y-turnout"),
|
|
|
|
formats = {},
|
2021-11-16 11:33:51 +01:00
|
|
|
get_additional_definiton = y3_turnouts_addef,
|
2020-09-10 18:40:02 +02:00
|
|
|
}, advtrains.ap.t_yturnout)
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'advtrains:dtrack_sy_placer 2',
|
|
|
|
recipe = {
|
|
|
|
{'advtrains:dtrack_placer', '', 'advtrains:dtrack_placer'},
|
|
|
|
{'', 'advtrains:dtrack_placer', ''},
|
|
|
|
{'', 'advtrains:dtrack_placer', ''},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
--3-way turnout
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_s3",
|
|
|
|
texture_prefix="advtrains_dtrack_s3",
|
|
|
|
models_prefix="advtrains_dtrack_s3",
|
|
|
|
models_suffix=".obj",
|
|
|
|
shared_texture="advtrains_dtrack_shared.png",
|
|
|
|
description=attrans("3-way turnout"),
|
|
|
|
formats = {},
|
2021-11-16 11:33:51 +01:00
|
|
|
get_additional_definiton = y3_turnouts_addef,
|
2020-09-10 18:40:02 +02:00
|
|
|
}, advtrains.ap.t_s3way)
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'advtrains:dtrack_s3_placer 1',
|
|
|
|
recipe = {
|
|
|
|
{'advtrains:dtrack_placer', 'advtrains:dtrack_placer', 'advtrains:dtrack_placer'},
|
|
|
|
{'', 'advtrains:dtrack_placer', ''},
|
|
|
|
{'', '', ''},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2020-07-06 08:57:48 +02:00
|
|
|
-- Diamond Crossings
|
2021-11-16 11:33:51 +01:00
|
|
|
|
|
|
|
local perp_boxen = {
|
|
|
|
[""] = {}, --default size
|
|
|
|
["_30"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -1.000, 1.000, -0.3750, 1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_45"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.8125, -0.5000, -0.8125, 0.8125, -0.3750, 0.8125}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["_60"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -1.000, 1.000, -0.3750, 1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-07-06 08:57:48 +02:00
|
|
|
-- perpendicular
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_xing",
|
|
|
|
texture_prefix="advtrains_dtrack_xing",
|
|
|
|
models_prefix="advtrains_dtrack_xing",
|
|
|
|
models_suffix=".obj",
|
|
|
|
shared_texture="advtrains_dtrack_shared.png",
|
|
|
|
description=attrans("Perpendicular Diamond Crossing Track"),
|
2021-11-16 11:33:51 +01:00
|
|
|
formats = {},
|
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
return perp_boxen[rotation] or {}
|
|
|
|
end
|
2020-07-06 08:57:48 +02:00
|
|
|
}, advtrains.ap.t_perpcrossing)
|
2020-07-07 18:03:09 +02:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'advtrains:dtrack_xing_placer 3',
|
|
|
|
recipe = {
|
|
|
|
{'', 'advtrains:dtrack_placer', ''},
|
|
|
|
{'advtrains:dtrack_placer', 'advtrains:dtrack_placer', 'advtrains:dtrack_placer'},
|
|
|
|
{'', 'advtrains:dtrack_placer', ''}
|
|
|
|
}
|
|
|
|
})
|
2020-08-15 18:39:58 +02:00
|
|
|
|
2021-11-16 11:33:51 +01:00
|
|
|
local ninety_plus_boxen = {
|
|
|
|
["30l"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.000, 0.5000, -0.3750, 1.000},
|
|
|
|
{-0.8750, -0.5000, -1.000, -0.5000, -0.3750, 0.2500},
|
|
|
|
{0.5000, -0.5000, -0.2500, 0.8750, -0.3750, 1.000},
|
|
|
|
{-0.1250, -0.5000, -1.375, 0.1875, -0.3750, -1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["30r"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{0.5000, -0.5000, -1.000, -0.5000, -0.3750, 1.000},
|
|
|
|
{0.8750, -0.5000, -1.000, 0.5000, -0.3750, 0.2500},
|
|
|
|
{-0.5000, -0.5000, -0.2500, -0.8750, -0.3750, 1.000},
|
|
|
|
{0.1250, -0.5000, -1.375, -0.1875, -0.3750, -1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["45l"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.8750, 0.5000, -0.3750, 0.8750},
|
|
|
|
{0.5000, -0.5000, -0.5000, 0.8750, -0.3750, 0.5000},
|
|
|
|
{-0.8750, -0.5000, -0.5000, -0.5000, -0.3750, 0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["45r"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -0.8750, 0.5000, -0.3750, 0.8750},
|
|
|
|
{0.5000, -0.5000, -0.5000, 0.8750, -0.3750, 0.5000},
|
|
|
|
{-0.8750, -0.5000, -0.5000, -0.5000, -0.3750, 0.5000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["60l"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -0.5000, 1.000, -0.3750, 0.5000},
|
|
|
|
{-1.000, -0.5000, -0.8750, 0.2500, -0.3750, -0.5000},
|
|
|
|
{-0.2500, -0.5000, 0.5000, 1.000, -0.3750, 0.8750},
|
|
|
|
{-1.375, -0.5000, -0.1250, -1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["60r"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{1.000, -0.5000, -0.5000, -1.000, -0.3750, 0.5000},
|
|
|
|
{1.000, -0.5000, -0.8750, -0.2500, -0.3750, -0.5000},
|
|
|
|
{0.2500, -0.5000, 0.5000, -1.000, -0.3750, 0.8750},
|
|
|
|
{1.375, -0.5000, -0.1250, 1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-08-15 18:39:58 +02:00
|
|
|
-- 90plusx
|
|
|
|
-- When you face east and param2=0, then this set of rails has a rail at 90
|
|
|
|
-- degrees to the viewer, plus another rail crossing at 30, 45 or 60 degrees.
|
2020-07-06 08:57:48 +02:00
|
|
|
advtrains.register_tracks("default", {
|
2020-08-15 18:39:58 +02:00
|
|
|
nodename_prefix="advtrains:dtrack_xing90plusx",
|
2020-07-06 08:57:48 +02:00
|
|
|
texture_prefix="advtrains_dtrack_xing4590",
|
2020-08-15 18:39:58 +02:00
|
|
|
models_prefix="advtrains_dtrack_xing90plusx",
|
2020-07-06 08:57:48 +02:00
|
|
|
models_suffix=".obj",
|
|
|
|
shared_texture="advtrains_dtrack_shared.png",
|
2020-08-15 18:39:58 +02:00
|
|
|
description=attrans("90+Angle Diamond Crossing Track"),
|
2021-11-16 11:33:51 +01:00
|
|
|
formats = {},
|
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
return ninety_plus_boxen[suffix] or {}
|
|
|
|
end,
|
2020-08-15 18:39:58 +02:00
|
|
|
}, advtrains.ap.t_90plusx_crossing)
|
2020-07-07 18:03:09 +02:00
|
|
|
minetest.register_craft({
|
2020-08-15 18:39:58 +02:00
|
|
|
output = 'advtrains:dtrack_xing90plusx_placer 2',
|
2020-07-07 18:03:09 +02:00
|
|
|
recipe = {
|
|
|
|
{'advtrains:dtrack_placer', '', ''},
|
|
|
|
{'advtrains:dtrack_placer', 'advtrains:dtrack_placer', 'advtrains:dtrack_placer'},
|
|
|
|
{'', '', 'advtrains:dtrack_placer'}
|
|
|
|
}
|
|
|
|
})
|
2021-11-16 11:33:51 +01:00
|
|
|
|
2020-08-15 22:05:11 +02:00
|
|
|
-- Deprecate any rails using the old name scheme
|
|
|
|
minetest.register_lbm({
|
|
|
|
label = "Upgrade legacy 4590 rails",
|
|
|
|
name = "advtrains_train_track:replace_legacy_4590",
|
|
|
|
nodenames = {"advtrains:dtrack_xing4590_st"},
|
|
|
|
run_at_every_load = true,
|
|
|
|
action = function(pos, node)
|
|
|
|
minetest.log("actionPos!: " .. pos.x .. "," .. pos.y .. "," .. pos.z)
|
|
|
|
minetest.log("node!: " .. node.name .. "," .. node.param1 .. "," .. node.param2)
|
|
|
|
advtrains.ndb.swap_node(pos,
|
|
|
|
{
|
|
|
|
name="advtrains:dtrack_xing90plusx_45l",
|
|
|
|
param1=node.param1,
|
|
|
|
param2=node.param2,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
})
|
|
|
|
-- This will replace any items left in the inventory
|
|
|
|
minetest.register_alias("advtrains:dtrack_xing4590_placer", "advtrains:dtrack_xing90plusx_placer")
|
2020-07-06 08:57:48 +02:00
|
|
|
|
2021-11-16 11:33:51 +01:00
|
|
|
local diagonal_boxen = {
|
|
|
|
["30r45l"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{0.5000, -0.5000, -1.000, -0.5000, -0.3750, 1.000},
|
|
|
|
{0.8750, -0.5000, -1.000, 0.5000, -0.3750, 0.2500},
|
|
|
|
{-0.5000, -0.5000, -0.2500, -0.8750, -0.3750, 1.000},
|
|
|
|
{0.1250, -0.5000, -1.375, -0.1875, -0.3750, -1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["60l30l"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -0.5000, 1.000, -0.3750, 0.5000},
|
|
|
|
{-1.000, -0.5000, -0.8750, 0.2500, -0.3750, -0.5000},
|
|
|
|
{-0.2500, -0.5000, 0.5000, 1.000, -0.3750, 0.8750},
|
|
|
|
{-1.375, -0.5000, -0.1250, -1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["60l60r"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -1.000, 1.000, -0.3750, 1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["60r30r"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{1.000, -0.5000, -0.5000, -1.000, -0.3750, 0.5000},
|
|
|
|
{1.000, -0.5000, -0.8750, -0.2500, -0.3750, -0.5000},
|
|
|
|
{0.2500, -0.5000, 0.5000, -1.000, -0.3750, 0.8750},
|
|
|
|
{1.375, -0.5000, -0.1250, 1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["30l45r"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5000, -0.5000, -1.000, 0.5000, -0.3750, 1.000},
|
|
|
|
{-0.8750, -0.5000, -1.000, -0.5000, -0.3750, 0.2500},
|
|
|
|
{0.5000, -0.5000, -0.2500, 0.8750, -0.3750, 1.000},
|
|
|
|
{-0.1250, -0.5000, -1.375, 0.1875, -0.3750, -1.000}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["60l45r"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-1.000, -0.5000, -0.5000, 1.000, -0.3750, 0.5000},
|
|
|
|
{-1.000, -0.5000, -0.8750, 0.2500, -0.3750, -0.5000},
|
|
|
|
{-0.2500, -0.5000, 0.5000, 1.000, -0.3750, 0.8750},
|
|
|
|
{-1.375, -0.5000, -0.1250, -1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
["60r45l"] = {
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{1.000, -0.5000, -0.5000, -1.000, -0.3750, 0.5000},
|
|
|
|
{1.000, -0.5000, -0.8750, -0.2500, -0.3750, -0.5000},
|
|
|
|
{0.2500, -0.5000, 0.5000, -1.000, -0.3750, 0.8750},
|
|
|
|
{1.375, -0.5000, -0.1250, 1.000, -0.3750, 0.1875}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-08-15 18:39:58 +02:00
|
|
|
-- Diagonal
|
|
|
|
-- This set of rail crossings is named based on the angle of each intersecting
|
|
|
|
-- direction when facing east and param2=0. Rails with l/r swapped are mirror
|
|
|
|
-- images. For example, 30r45l is the mirror image of 30l45r.
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_xingdiag",
|
|
|
|
texture_prefix="advtrains_dtrack_xingdiag",
|
|
|
|
models_prefix="advtrains_dtrack_xingdiag",
|
|
|
|
models_suffix=".obj",
|
|
|
|
shared_texture="advtrains_dtrack_shared.png",
|
|
|
|
description=attrans("Diagonal Diamond Crossing Track"),
|
|
|
|
formats = {},
|
2021-11-16 11:33:51 +01:00
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
return diagonal_boxen[suffix] or {}
|
|
|
|
end,
|
2020-08-15 18:39:58 +02:00
|
|
|
}, advtrains.ap.t_diagonalcrossing)
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'advtrains:dtrack_xingdiag_placer 2',
|
|
|
|
recipe = {
|
|
|
|
{'advtrains:dtrack_placer', '', 'advtrains:dtrack_placer'},
|
|
|
|
{'', 'advtrains:dtrack_placer', ''},
|
|
|
|
{'advtrains:dtrack_placer', '', 'advtrains:dtrack_placer'}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
---- Not included: very shallow crossings like (30/60)+45.
|
|
|
|
---- At an angle of only 18.4 degrees, the models would not
|
|
|
|
---- translate well to a block game.
|
|
|
|
-- END crossings
|
|
|
|
|
2017-08-20 14:32:38 +02:00
|
|
|
--slopes
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack",
|
|
|
|
texture_prefix="advtrains_dtrack",
|
|
|
|
models_prefix="advtrains_dtrack",
|
|
|
|
models_suffix=".obj",
|
|
|
|
shared_texture="advtrains_dtrack_shared.png",
|
|
|
|
second_texture="default_gravel.png",
|
|
|
|
description=attrans("Track"),
|
|
|
|
formats={vst1={true, false, true}, vst2={true, false, true}, vst31={true}, vst32={true}, vst33={true}},
|
|
|
|
}, advtrains.ap.t_30deg_slope)
|
|
|
|
|
2020-07-07 18:03:09 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = 'advtrains:dtrack_slopeplacer 2',
|
|
|
|
recipe = {
|
|
|
|
"advtrains:dtrack_placer",
|
|
|
|
"advtrains:dtrack_placer",
|
|
|
|
"default:gravel",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2017-08-20 14:32:38 +02:00
|
|
|
--bumpers
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_bumper",
|
|
|
|
texture_prefix="advtrains_dtrack_bumper",
|
|
|
|
models_prefix="advtrains_dtrack_bumper",
|
|
|
|
models_suffix=".b3d",
|
|
|
|
shared_texture="advtrains_dtrack_rail.png",
|
|
|
|
--bumpers still use the old texture until the models are redone.
|
|
|
|
description=attrans("Bumper"),
|
|
|
|
formats={},
|
|
|
|
}, advtrains.ap.t_30deg_straightonly)
|
2020-07-07 18:03:09 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = 'advtrains:dtrack_bumper_placer 2',
|
|
|
|
recipe = {
|
|
|
|
{'group:wood', 'dye:red'},
|
|
|
|
{'default:steel_ingot', 'default:steel_ingot'},
|
|
|
|
{'advtrains:dtrack_placer', 'advtrains:dtrack_placer'},
|
|
|
|
},
|
|
|
|
})
|
2017-08-20 14:32:38 +02:00
|
|
|
--legacy bumpers
|
|
|
|
for _,rot in ipairs({"", "_30", "_45", "_60"}) do
|
|
|
|
minetest.register_alias("advtrains:dtrack_bumper"..rot, "advtrains:dtrack_bumper_st"..rot)
|
|
|
|
end
|
|
|
|
-- atc track
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_atc",
|
|
|
|
texture_prefix="advtrains_dtrack_atc",
|
|
|
|
models_prefix="advtrains_dtrack",
|
|
|
|
models_suffix=".b3d",
|
|
|
|
shared_texture="advtrains_dtrack_shared_atc.png",
|
|
|
|
description=attrans("ATC controller"),
|
|
|
|
formats={},
|
|
|
|
get_additional_definiton = advtrains.atc_function
|
|
|
|
}, advtrains.trackpresets.t_30deg_straightonly)
|
2017-12-18 12:21:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
-- Tracks for loading and unloading trains
|
|
|
|
-- Copyright (C) 2017 Gabriel Pérez-Cerezo <gabriel@gpcf.eu>
|
|
|
|
|
|
|
|
local function get_far_node(pos)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if node.name == "ignore" then
|
|
|
|
minetest.get_voxel_manip():read_from_map(pos, pos)
|
|
|
|
node = minetest.get_node(pos)
|
|
|
|
end
|
|
|
|
return node
|
|
|
|
end
|
|
|
|
|
2021-08-28 13:57:58 +02:00
|
|
|
|
|
|
|
local function show_fc_formspec(pos,player)
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
if minetest.is_protected(pos,pname) then
|
|
|
|
minetest.chat_send_player(pname, "Position is protected!")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local fc = meta:get_string("fc") or ""
|
|
|
|
|
|
|
|
local form = 'formspec_version[4]'..
|
|
|
|
'size[10,5]'..
|
|
|
|
'label[0.5,0.4;Advtrains Loading/Unloading Track]'..
|
|
|
|
'label[0.5,1.1;Set the code to match against the wagon\'s freight code]'..
|
|
|
|
'label[0.5,1.6;A blank field matches all wagons (default)]'..
|
|
|
|
'label[0.5,2.1;Use code # to disable the track section]'..
|
|
|
|
'field[0.5,3;5.5,1;fc;FC;'..minetest.formspec_escape(fc)..']'..
|
|
|
|
'button[6.5,3;3,1;save;Submit]'
|
|
|
|
minetest.show_formspec(pname, "at_load_unload_"..advtrains.encode_pos(pos), form)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
local pe = string.match(formname, "^at_load_unload_(............)$")
|
|
|
|
local pos = advtrains.decode_pos(pe)
|
|
|
|
if pos then
|
|
|
|
if minetest.is_protected(pos, pname) then
|
|
|
|
minetest.chat_send_player(pname, "Position is protected!")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if fields.save then
|
|
|
|
minetest.get_meta(pos):set_string("fc",tostring(fields.fc))
|
|
|
|
minetest.chat_send_player(pname,"Freight code set: "..tostring(fields.fc))
|
|
|
|
show_fc_formspec(pos,player)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
2017-12-18 12:21:54 +01:00
|
|
|
local function train_load(pos, train_id, unload)
|
2021-08-28 13:57:58 +02:00
|
|
|
local train=advtrains.trains[train_id]
|
|
|
|
local below = get_far_node({x=pos.x, y=pos.y-1, z=pos.z})
|
|
|
|
if not string.match(below.name, "chest") then
|
|
|
|
atprint("this is not a chest! at "..minetest.pos_to_string(pos))
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local node_fc = minetest.get_meta(pos):get_string("fc") or ""
|
|
|
|
if node_fc == "#" then
|
|
|
|
--track section is disabled
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local inv = minetest.get_inventory({type="node", pos={x=pos.x, y=pos.y-1, z=pos.z}})
|
|
|
|
if inv and train.velocity < 2 then
|
|
|
|
for k, v in ipairs(train.trainparts) do
|
2021-04-11 12:45:17 +02:00
|
|
|
local i=minetest.get_inventory({type="detached", name="advtrains_wgn_"..v})
|
|
|
|
if i and i:get_list("box") then
|
2021-08-28 13:57:58 +02:00
|
|
|
|
|
|
|
local wagon_data = advtrains.wagons[v]
|
|
|
|
local wagon_fc
|
|
|
|
if wagon_data.fc then
|
|
|
|
if not wagon_data.fcind then wagon_data.fcind = 1 end
|
|
|
|
wagon_fc = tostring(wagon_data.fc[wagon_data.fcind]) or ""
|
|
|
|
end
|
|
|
|
|
|
|
|
if node_fc == "" or wagon_fc == node_fc then
|
|
|
|
if not unload then
|
|
|
|
for _, item in ipairs(inv:get_list("main")) do
|
|
|
|
if i:get_list("box") and i:room_for_item("box", item) then
|
|
|
|
i:add_item("box", item)
|
|
|
|
inv:remove_item("main", item)
|
|
|
|
end
|
2021-04-11 12:45:17 +02:00
|
|
|
end
|
2021-08-28 13:57:58 +02:00
|
|
|
else
|
|
|
|
for _, item in ipairs(i:get_list("box")) do
|
|
|
|
if inv:get_list("main") and inv:room_for_item("main", item) then
|
|
|
|
i:remove_item("box", item)
|
|
|
|
inv:add_item("main", item)
|
|
|
|
end
|
2021-04-11 12:45:17 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-08-28 13:57:58 +02:00
|
|
|
end
|
|
|
|
end
|
2017-12-18 12:21:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-08-20 14:32:38 +02:00
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_unload",
|
|
|
|
texture_prefix="advtrains_dtrack_unload",
|
|
|
|
models_prefix="advtrains_dtrack",
|
|
|
|
models_suffix=".b3d",
|
|
|
|
shared_texture="advtrains_dtrack_shared_unload.png",
|
|
|
|
description=attrans("Unloading Track"),
|
|
|
|
formats={},
|
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
return {
|
2021-08-28 13:57:58 +02:00
|
|
|
after_dig_node=function(pos)
|
|
|
|
advtrains.invalidate_all_paths()
|
|
|
|
advtrains.ndb.clear(pos)
|
|
|
|
end,
|
|
|
|
on_rightclick = function(pos, node, player)
|
|
|
|
show_fc_formspec(pos, player)
|
|
|
|
end,
|
|
|
|
advtrains = {
|
|
|
|
on_train_enter = function(pos, train_id)
|
|
|
|
train_load(pos, train_id, true)
|
|
|
|
end,
|
|
|
|
},
|
2017-08-20 14:32:38 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
}, advtrains.trackpresets.t_30deg_straightonly)
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_load",
|
|
|
|
texture_prefix="advtrains_dtrack_load",
|
|
|
|
models_prefix="advtrains_dtrack",
|
|
|
|
models_suffix=".b3d",
|
|
|
|
shared_texture="advtrains_dtrack_shared_load.png",
|
|
|
|
description=attrans("Loading Track"),
|
|
|
|
formats={},
|
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
return {
|
2021-08-28 13:57:58 +02:00
|
|
|
after_dig_node=function(pos)
|
|
|
|
advtrains.invalidate_all_paths()
|
|
|
|
advtrains.ndb.clear(pos)
|
|
|
|
end,
|
|
|
|
on_rightclick = function(pos, node, player)
|
|
|
|
show_fc_formspec(pos, player)
|
|
|
|
end,
|
|
|
|
advtrains = {
|
|
|
|
on_train_enter = function(pos, train_id)
|
|
|
|
train_load(pos, train_id, false)
|
|
|
|
end,
|
|
|
|
},
|
2017-08-20 14:32:38 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
}, advtrains.trackpresets.t_30deg_straightonly)
|
|
|
|
|
2021-02-24 13:16:55 +01:00
|
|
|
-- mod-dependent crafts
|
|
|
|
local loader_core = "default:mese_crystal" --fallback
|
|
|
|
if minetest.get_modpath("basic_materials") then
|
|
|
|
loader_core = "basic_materials:ic"
|
|
|
|
elseif minetest.get_modpath("technic") then
|
|
|
|
loader_core = "technic:control_logic_unit"
|
|
|
|
end
|
|
|
|
--print("Loader Core: "..loader_core)
|
|
|
|
|
2021-02-19 18:46:03 +01:00
|
|
|
minetest.register_craft({
|
|
|
|
type="shapeless",
|
|
|
|
output = 'advtrains:dtrack_load_placer',
|
|
|
|
recipe = {
|
|
|
|
"advtrains:dtrack_placer",
|
2021-02-24 13:16:55 +01:00
|
|
|
loader_core,
|
2021-02-19 18:46:03 +01:00
|
|
|
"default:chest"
|
|
|
|
},
|
|
|
|
})
|
2021-02-24 13:16:55 +01:00
|
|
|
loader_core = nil --nil the crafting variable
|
|
|
|
|
|
|
|
--craft between load/unload tracks
|
2021-02-19 18:46:03 +01:00
|
|
|
minetest.register_craft({
|
|
|
|
type="shapeless",
|
|
|
|
output = 'advtrains:dtrack_unload_placer',
|
|
|
|
recipe = {
|
|
|
|
"advtrains:dtrack_load_placer",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
type="shapeless",
|
|
|
|
output = 'advtrains:dtrack_load_placer',
|
|
|
|
recipe = {
|
|
|
|
"advtrains:dtrack_unload_placer",
|
|
|
|
},
|
|
|
|
})
|
2017-08-20 14:32:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
if mesecon then
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_detector_off",
|
|
|
|
texture_prefix="advtrains_dtrack_detector",
|
|
|
|
models_prefix="advtrains_dtrack",
|
|
|
|
models_suffix=".b3d",
|
|
|
|
shared_texture="advtrains_dtrack_shared_detector_off.png",
|
|
|
|
description=attrans("Detector Rail"),
|
|
|
|
formats={},
|
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
return {
|
|
|
|
mesecons = {
|
|
|
|
receptor = {
|
|
|
|
state = mesecon.state.off,
|
|
|
|
rules = advtrains.meseconrules
|
|
|
|
}
|
|
|
|
},
|
|
|
|
advtrains = {
|
2021-02-04 12:35:24 +01:00
|
|
|
on_updated_from_nodedb = function(pos, node)
|
|
|
|
mesecon.receptor_off(pos, advtrains.meseconrules)
|
|
|
|
end,
|
2017-08-20 14:32:38 +02:00
|
|
|
on_train_enter=function(pos, train_id)
|
|
|
|
advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_on".."_"..suffix..rotation, param2=advtrains.ndb.get_node(pos).param2})
|
2021-02-04 12:35:24 +01:00
|
|
|
if advtrains.is_node_loaded(pos) then
|
|
|
|
mesecon.receptor_on(pos, advtrains.meseconrules)
|
|
|
|
end
|
2017-08-20 14:32:38 +02:00
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
}, advtrains.ap.t_30deg_straightonly)
|
|
|
|
advtrains.register_tracks("default", {
|
|
|
|
nodename_prefix="advtrains:dtrack_detector_on",
|
|
|
|
texture_prefix="advtrains_dtrack",
|
|
|
|
models_prefix="advtrains_dtrack",
|
|
|
|
models_suffix=".b3d",
|
|
|
|
shared_texture="advtrains_dtrack_shared_detector_on.png",
|
|
|
|
description="Detector(on)(you hacker you)",
|
|
|
|
formats={},
|
|
|
|
get_additional_definiton = function(def, preset, suffix, rotation)
|
|
|
|
return {
|
|
|
|
mesecons = {
|
|
|
|
receptor = {
|
|
|
|
state = mesecon.state.on,
|
|
|
|
rules = advtrains.meseconrules
|
|
|
|
}
|
|
|
|
},
|
|
|
|
advtrains = {
|
2021-02-04 12:35:24 +01:00
|
|
|
on_updated_from_nodedb = function(pos, node)
|
|
|
|
mesecon.receptor_on(pos, advtrains.meseconrules)
|
|
|
|
end,
|
2017-08-20 14:32:38 +02:00
|
|
|
on_train_leave=function(pos, train_id)
|
|
|
|
advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_off".."_"..suffix..rotation, param2=advtrains.ndb.get_node(pos).param2})
|
2021-02-04 12:35:24 +01:00
|
|
|
if advtrains.is_node_loaded(pos) then
|
|
|
|
mesecon.receptor_off(pos, advtrains.meseconrules)
|
|
|
|
end
|
2017-08-20 14:32:38 +02:00
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
}, advtrains.ap.t_30deg_straightonly_noplacer)
|
2021-02-19 18:46:03 +01:00
|
|
|
minetest.register_craft({
|
2020-07-07 18:03:09 +02:00
|
|
|
type="shapeless",
|
|
|
|
output = 'advtrains:dtrack_detector_off_placer',
|
|
|
|
recipe = {
|
|
|
|
"advtrains:dtrack_placer",
|
|
|
|
"mesecons:wire_00000000_off"
|
|
|
|
},
|
|
|
|
})
|
2017-08-20 14:32:38 +02:00
|
|
|
end
|
|
|
|
--TODO legacy
|
|
|
|
--I know lbms are better for this purpose
|
|
|
|
for name,rep in pairs({swl_st="swlst", swr_st="swrst", swl_cr="swlcr", swr_cr="swrcr", }) do
|
|
|
|
minetest.register_abm({
|
|
|
|
-- In the following two fields, also group:groupname will work.
|
|
|
|
nodenames = {"advtrains:track_"..name},
|
|
|
|
interval = 1.0, -- Operation interval in seconds
|
|
|
|
chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep, param2=node.param2}) end,
|
|
|
|
})
|
|
|
|
minetest.register_abm({
|
|
|
|
-- In the following two fields, also group:groupname will work.
|
|
|
|
nodenames = {"advtrains:track_"..name.."_45"},
|
|
|
|
interval = 1.0, -- Operation interval in seconds
|
|
|
|
chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep.."_45", param2=node.param2}) end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
if advtrains.register_replacement_lbms then
|
|
|
|
minetest.register_lbm({
|
|
|
|
name = "advtrains:ramp_replacement_1",
|
|
|
|
-- In the following two fields, also group:groupname will work.
|
|
|
|
nodenames = {"advtrains:track_vert1"},
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst1", param2=(node.param2+2)%4}) end,
|
|
|
|
})
|
|
|
|
minetest.register_lbm({
|
|
|
|
name = "advtrains:ramp_replacement_1",
|
|
|
|
-- -- In the following two fields, also group:groupname will work.
|
|
|
|
nodenames = {"advtrains:track_vert2"},
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst2", param2=(node.param2+2)%4}) end,
|
|
|
|
})
|
|
|
|
minetest.register_abm({
|
|
|
|
name = "advtrains:st_rep_1",
|
|
|
|
-- In the following two fields, also group:groupname will work.
|
|
|
|
nodenames = {"advtrains:track_st"},
|
|
|
|
interval=1,
|
|
|
|
chance=1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st", param2=node.param2}) end,
|
|
|
|
})
|
|
|
|
minetest.register_lbm({
|
|
|
|
name = "advtrains:st_rep_1",
|
|
|
|
-- -- In the following two fields, also group:groupname will work.
|
|
|
|
nodenames = {"advtrains:track_st_45"},
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st_45", param2=node.param2}) end,
|
|
|
|
})
|
|
|
|
end
|