aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/advtrains/depends.txt3
-rw-r--r--advtrains/advtrains/digtron.lua25
-rw-r--r--advtrains/advtrains/init.lua3
-rw-r--r--advtrains/advtrains/trackplacer.lua8
4 files changed, 34 insertions, 5 deletions
diff --git a/advtrains/advtrains/depends.txt b/advtrains/advtrains/depends.txt
index 20aa884..1815e54 100644
--- a/advtrains/advtrains/depends.txt
+++ b/advtrains/advtrains/depends.txt
@@ -1,2 +1,3 @@
default
-mesecons? \ No newline at end of file
+mesecons?
+digtron? \ No newline at end of file
diff --git a/advtrains/advtrains/digtron.lua b/advtrains/advtrains/digtron.lua
new file mode 100644
index 0000000..7105a54
--- /dev/null
+++ b/advtrains/advtrains/digtron.lua
@@ -0,0 +1,25 @@
+--digtron.lua
+--make tracks placeable by digtrons by overriding the place function.
+
+local old_item_place = digtron.item_place_node
+
+digtron.item_place_node = function(itemstack, placer, place_to, param2)
+ if minetest.get_item_group(itemstack:get_name(), "advtrains_trackplacer")>0 then
+ return advtrains.pcall(function()
+ local def = minetest.registered_items[itemstack:get_name()]
+ if not def then return itemstack, false end
+
+ local pointed_thing = {}
+ pointed_thing.type = "node"
+ pointed_thing.above = {x=place_to.x, y=place_to.y, z=place_to.z}
+ pointed_thing.under = {x=place_to.x, y=place_to.y - 1, z=place_to.z}
+
+ --call the on_rightclick callback
+ local success
+ itemstack, success = def.on_place(itemstack, placer, pointed_thing)
+ return itemstack, success
+ end)
+ else
+ return old_item_place(itemstack, placer, place_to, param2)
+ end
+end
diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua
index 4ebde24..c0d581d 100644
--- a/advtrains/advtrains/init.lua
+++ b/advtrains/advtrains/init.lua
@@ -121,6 +121,9 @@ dofile(advtrains.modpath.."/misc_nodes.lua")
dofile(advtrains.modpath.."/crafting.lua")
dofile(advtrains.modpath.."/craft_items.lua")
+if digtron then
+ dofile(advtrains.modpath.."/digtron.lua")
+end
--load/save
diff --git a/advtrains/advtrains/trackplacer.lua b/advtrains/advtrains/trackplacer.lua
index 105b77e..4c82db8 100644
--- a/advtrains/advtrains/trackplacer.lua
+++ b/advtrains/advtrains/trackplacer.lua
@@ -185,19 +185,19 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname)
description = dispname,
inventory_image = imgprefix.."_placer.png",
wield_image = imgprefix.."_placer.png",
- groups={},
+ groups={advtrains_trackplacer=1},
on_place = function(itemstack, placer, pointed_thing)
return advtrains.pcall(function()
local name = placer:get_player_name()
if not name then
- return itemstack
+ return itemstack, false
end
if pointed_thing.type=="node" then
local pos=pointed_thing.above
local upos=vector.subtract(pointed_thing.above, {x=0, y=1, z=0})
if advtrains.is_protected(pos,name) then
minetest.record_protection_violation(pos, name)
- return itemstack
+ 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
@@ -207,7 +207,7 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname)
end
end
end
- return itemstack
+ return itemstack, true
end)
end,
})