aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authorGabriel PĂ©rez-Cerezo <gabriel@gpcf.eu>2017-08-20 14:32:38 +0200
committerorwell96 <orwell@bleipb.de>2017-10-25 09:52:10 +0200
commitf228e2d30e0d712c6490fb84d4edfadeba8c4cd7 (patch)
tree9f7eaf8be4e54e162586b44547d9f7af6ded4036 /advtrains
parent291da56aa22608863252f419bbd8f226f0913c76 (diff)
downloadadvtrains-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')
-rw-r--r--advtrains/atc.lua14
-rw-r--r--advtrains/loading.lua53
-rw-r--r--advtrains/trackplacer.lua6
-rw-r--r--advtrains/tracks.lua163
4 files changed, 15 insertions, 221 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua
index 5f1f64d..c8f7c90 100644
--- a/advtrains/atc.lua
+++ b/advtrains/atc.lua
@@ -80,15 +80,7 @@ local apn_func=function(pos, node)
end
end
-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 = function(def, preset, suffix, rotation)
+advtrains.atc_function = function(def, preset, suffix, rotation)
return {
after_place_node=apn_func,
after_dig_node=function(pos)
@@ -146,9 +138,7 @@ advtrains.register_tracks("default", {
end,
},
}
- end
-}, advtrains.trackpresets.t_30deg_straightonly)
-
+end
function atc.get_atc_controller_formspec(pos, meta)
local mode=tonumber(meta:get_string("mode")) or 1
diff --git a/advtrains/loading.lua b/advtrains/loading.lua
index 8ac7b00..e2c0e09 100644
--- a/advtrains/loading.lua
+++ b/advtrains/loading.lua
@@ -44,56 +44,3 @@ local function train_load(pos, train_id, unload)
end
-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 {
- after_dig_node=function(pos)
- advtrains.invalidate_all_paths()
- advtrains.ndb.clear(pos)
- -- local pts=minetest.pos_to_string(pos)
- -- atc.controllers[pts]=nil
- end,
- -- on_receive_fields = function(pos, formname, fields, player)
- -- if minetest.is_protected(pos, player:get_player_name()) then
- -- minetest.chat_send_player(player:get_player_name(), attrans("This position is protected!"))
- -- return
- -- end
- -- end,
- advtrains = {
- on_train_enter = function(pos, train_id)
- train_load(pos, train_id, true)
- end,
- },
- }
- 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 {
- after_dig_node=function(pos)
- advtrains.invalidate_all_paths()
- advtrains.ndb.clear(pos)
- end,
-
- advtrains = {
- on_train_enter = function(pos, train_id)
- train_load(pos, train_id, false)
- end,
- },
- }
- end
- }, advtrains.trackpresets.t_30deg_straightonly)
diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua
index e94b4ff..124e958 100644
--- a/advtrains/trackplacer.lua
+++ b/advtrains/trackplacer.lua
@@ -139,6 +139,7 @@ function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing)
p_rails[#p_rails+1]=i
end
end
+
if #p_rails==0 then
minetest.set_node(pos, {name=nnpref.."_"..tr.default})
if minetest.registered_nodes[nnpref.."_"..tr.default] and minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node then
@@ -181,7 +182,7 @@ end
function tp.register_track_placer(nnprefix, imgprefix, dispname)
- minetest.register_craftitem(nnprefix.."_placer",{
+ minetest.register_craftitem(":"..nnprefix.."_placer",{
description = dispname,
inventory_image = imgprefix.."_placer.png",
wield_image = imgprefix.."_placer.png",
@@ -200,7 +201,8 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname)
return itemstack, false
end
if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to
- and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then
+ and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then
+-- minetest.chat_send_all(nnprefix)
tp.placetrack(pos, nnprefix, placer, itemstack, pointed_thing)
if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item()
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