diff options
author | Gabriel PĂ©rez-Cerezo <gabriel@gpcf.eu> | 2017-08-20 14:32:38 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2017-10-25 09:52:10 +0200 |
commit | f228e2d30e0d712c6490fb84d4edfadeba8c4cd7 (patch) | |
tree | 9f7eaf8be4e54e162586b44547d9f7af6ded4036 /advtrains/tracks.lua | |
parent | 291da56aa22608863252f419bbd8f226f0913c76 (diff) | |
download | advtrains-f228e2d30e0d712c6490fb84d4edfadeba8c4cd7.tar.gz advtrains-f228e2d30e0d712c6490fb84d4edfadeba8c4cd7.tar.bz2 advtrains-f228e2d30e0d712c6490fb84d4edfadeba8c4cd7.zip |
Moved default train track to separate mod, for integration with advcarts.
Diffstat (limited to 'advtrains/tracks.lua')
-rw-r--r-- | advtrains/tracks.lua | 163 |
1 files changed, 9 insertions, 154 deletions
diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index d63e5c8..fa7f84d 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -36,8 +36,8 @@ advtrains.all_tracktypes={} --definition preparation
local function conns(c1, c2, r1, r2, rh, rots) return {conn1=c1, conn2=c2, rely1=r1, rely2=r2, railheight=rh} end
-local ap={}
-ap.t_30deg_flat={
+advtrains.ap={}
+advtrains.ap.t_30deg_flat={
regstep=1,
variant={
st=conns(0,8),
@@ -94,7 +94,7 @@ ap.t_30deg_flat={ slopenodes={},
increativeinv={},
}
-ap.t_30deg_slope={
+advtrains.ap.t_30deg_slope={
regstep=1,
variant={
vst1=conns(8,0,0,0.5,0.25),
@@ -131,7 +131,7 @@ ap.t_30deg_slope={ trackworker={},
increativeinv={},
}
-ap.t_30deg_straightonly={
+advtrains.ap.t_30deg_straightonly={
regstep=1,
variant={
st=conns(0,8),
@@ -156,7 +156,7 @@ ap.t_30deg_straightonly={ rotation={"", "_30", "_45", "_60"},
increativeinv={"st"},
}
-ap.t_30deg_straightonly_noplacer={
+advtrains.ap.t_30deg_straightonly_noplacer={
regstep=1,
variant={
st=conns(0,8),
@@ -181,7 +181,7 @@ ap.t_30deg_straightonly_noplacer={ rotation={"", "_30", "_45", "_60"},
increativeinv={"st"},
}
-ap.t_45deg={
+advtrains.ap.t_45deg={
regstep=2,
variant={
st=conns(0,8),
@@ -242,7 +242,7 @@ ap.t_45deg={ rotation={"", "_45"},
increativeinv={vst1=true, vst2=true}
}
-advtrains.trackpresets = ap
+advtrains.trackpresets = advtrains.ap
--definition format: ([] optional)
--[[{
@@ -367,7 +367,7 @@ function advtrains.register_tracks(tracktype, def, preset) adef=def.get_additional_definiton(def, preset, suffix, rotation)
end
- minetest.register_node(def.nodename_prefix.."_"..suffix..rotation, advtrains.merge_tables(
+ minetest.register_node(":"..def.nodename_prefix.."_"..suffix..rotation, advtrains.merge_tables(
common_def,
make_overdef(
suffix, rotation,
@@ -471,7 +471,7 @@ end --crafted with rail and gravel
local sl={}
function sl.register_placer(def, preset)
- minetest.register_craftitem(def.nodename_prefix.."_slopeplacer",{
+ minetest.register_craftitem(":"..def.nodename_prefix.."_slopeplacer",{
description = attrans("@1 Slope", def.description),
inventory_image = def.texture_prefix.."_slopeplacer.png",
wield_image = def.texture_prefix.."_slopeplacer.png",
@@ -579,151 +579,6 @@ advtrains.slope=sl common={} change something on common rail appearance
}]]
-advtrains.register_tracks("regular", {
- nodename_prefix="advtrains:track",
- texture_prefix="advtrains_track",
- shared_model="trackplane.b3d",
- description=attrans("Deprecated Track"),
- formats={vst1={}, vst2={}},
-}, ap.t_45deg)
-
---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={},
-}, ap.t_30deg_flat)
---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}},
-}, ap.t_30deg_slope)
-
---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={},
-}, ap.t_30deg_straightonly)
---legacy bumpers
-for _,rot in ipairs({"", "_30", "_45", "_60"}) do
- minetest.register_alias("advtrains:dtrack_bumper"..rot, "advtrains:dtrack_bumper_st"..rot)
-end
-
-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 = {
- 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})
- mesecon.receptor_on(pos, advtrains.meseconrules)
- end
- }
- }
- end
- }, 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 = {
- 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})
- mesecon.receptor_off(pos, advtrains.meseconrules)
- end
- }
- }
- end
- }, ap.t_30deg_straightonly_noplacer)
-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
|