aboutsummaryrefslogtreecommitdiff
path: root/advtrains/debugitems.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2023-05-27 12:09:10 +0200
committerorwell96 <orwell@bleipb.de>2023-05-27 12:09:10 +0200
commit283efc44ce78001ebd17f64555eb795e36b27a61 (patch)
treec5be0288a325fa561e544cb0d86b1bfaa4f27adc /advtrains/debugitems.lua
parentbbe3856e3547aea133001f746cb72d439e5ed01d (diff)
downloadadvtrains-283efc44ce78001ebd17f64555eb795e36b27a61.tar.gz
advtrains-283efc44ce78001ebd17f64555eb795e36b27a61.tar.bz2
advtrains-283efc44ce78001ebd17f64555eb795e36b27a61.zip
Add function to get wagon in train from index
Can be used to determine which wagon is at a certain world position Testing: use debugitems.lua
Diffstat (limited to 'advtrains/debugitems.lua')
-rw-r--r--advtrains/debugitems.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/advtrains/debugitems.lua b/advtrains/debugitems.lua
index e672308..e598216 100644
--- a/advtrains/debugitems.lua
+++ b/advtrains/debugitems.lua
@@ -51,3 +51,33 @@ minetest.register_chatcommand("atyaw",
end
end,
})
+
+minetest.register_tool("advtrains:wagonpos_tester",
+{
+ description = "Wagon position tester",
+ groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
+ inventory_image = "drwho_screwdriver.png",
+ wield_image = "drwho_screwdriver.png",
+ stack_max = 1,
+ range = 7.0,
+
+ on_place = function(itemstack, placer, pointed_thing)
+
+ end,
+ --[[
+ ^ Shall place item and return the leftover itemstack
+ ^ default: minetest.item_place ]]
+ on_use = function(itemstack, user, pointed_thing)
+ if pointed_thing.type=="node" then
+ local pos = pointed_thing.under
+ local trains = advtrains.occ.get_trains_at(pos)
+ for train_id, index in pairs(trains) do
+ local wagon_num, wagon_id, wagon_data, offset_from_center = advtrains.get_wagon_at_index(train_id, index)
+ if wagon_num then
+ atdebug(wagon_num, wagon_id, offset_from_center)
+ end
+ end
+ end
+ end,
+}
+)