aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-10-21 16:36:35 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2019-10-21 16:36:35 +0200
commit7977776b4a8067ea513d95ab2b0d699456596209 (patch)
tree221564975cee9195d206d023cb845217ec938880 /advtrains
parent2d8c13885aa33a0f5eb43b16a1131f187fad75e7 (diff)
downloadadvtrains-7977776b4a8067ea513d95ab2b0d699456596209.tar.gz
advtrains-7977776b4a8067ea513d95ab2b0d699456596209.tar.bz2
advtrains-7977776b4a8067ea513d95ab2b0d699456596209.zip
Changes for linetrack
Allows defining a suitable substrate for tracks, and liquid pointable tracks
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/trackplacer.lua21
-rw-r--r--advtrains/tracks.lua2
2 files changed, 15 insertions, 8 deletions
diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua
index 9f5fadd..db65cd9 100644
--- a/advtrains/trackplacer.lua
+++ b/advtrains/trackplacer.lua
@@ -262,12 +262,13 @@ function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing, yaw)
end
-function tp.register_track_placer(nnprefix, imgprefix, dispname)
+function tp.register_track_placer(nnprefix, imgprefix, dispname, def)
minetest.register_craftitem(":"..nnprefix.."_placer",{
description = dispname,
inventory_image = imgprefix.."_placer.png",
wield_image = imgprefix.."_placer.png",
groups={advtrains_trackplacer=1, digtron_on_place=1},
+ liquids_pointable = def.liquids_pointable,
on_place = function(itemstack, placer, pointed_thing)
return advtrains.pcall(function()
local name = placer:get_player_name()
@@ -280,13 +281,19 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname)
if not advtrains.check_track_protection(pos, name) then
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
+ if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to then
+ if def.suitable_substrate then
+ s = def.suitable_substrate(upos)
+ else
+ s = minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable
+ end
+ if s then
-- minetest.chat_send_all(nnprefix)
- local yaw = placer:get_look_horizontal()
- tp.placetrack(pos, nnprefix, placer, itemstack, pointed_thing, yaw)
- if not advtrains.is_creative(name) then
- itemstack:take_item()
+ local yaw = placer:get_look_horizontal()
+ tp.placetrack(pos, nnprefix, placer, itemstack, pointed_thing, yaw)
+ if not advtrains.is_creative(name) then
+ itemstack:take_item()
+ end
end
end
end
diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua
index 1c0b36b..4475cb0 100644
--- a/advtrains/tracks.lua
+++ b/advtrains/tracks.lua
@@ -244,7 +244,7 @@ Depending on the number of connections:
function advtrains.register_tracks(tracktype, def, preset)
advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault)
if preset.regtp then
- advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description)
+ advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description, def)
end
if preset.regsp then
advtrains.slope.register_placer(def, preset)