aboutsummaryrefslogtreecommitdiff
path: root/advtrains/wagonprop_tool.lua
diff options
context:
space:
mode:
authororwell <orwell@bleipb.de>2024-11-11 20:50:28 +0100
committerorwell <orwell@bleipb.de>2024-11-11 20:50:28 +0100
commit380c26f7a851f4b4edb3879b544a542e7bfbb490 (patch)
tree158ac366c93a8581f5792f95eba6932bafe4c325 /advtrains/wagonprop_tool.lua
parent29180f0f60871f92889f686fe666c029ac07861a (diff)
parent3d2d19f6f7eba90f0d19b002824b2ff466567608 (diff)
downloadadvtrains-380c26f7a851f4b4edb3879b544a542e7bfbb490.tar.gz
advtrains-380c26f7a851f4b4edb3879b544a542e7bfbb490.tar.bz2
advtrains-380c26f7a851f4b4edb3879b544a542e7bfbb490.zip
Merge branch 'master' into route_prog_rework
Diffstat (limited to 'advtrains/wagonprop_tool.lua')
-rw-r--r--advtrains/wagonprop_tool.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/advtrains/wagonprop_tool.lua b/advtrains/wagonprop_tool.lua
new file mode 100644
index 0000000..2a4a9e2
--- /dev/null
+++ b/advtrains/wagonprop_tool.lua
@@ -0,0 +1,43 @@
+minetest.register_craftitem("advtrains:wagon_prop_tool",{ --craftitem because it does nothing on its own
+ description = attrans("Wagon Properties Tool\nPunch a wagon to view and edit the Wagon Properties"),
+ short_description = attrans("Wagon Properties Tool"),
+ groups = {},
+ inventory_image = "advtrains_wagon_prop_tool.png",
+ wield_image = "advtrains_wagon_prop_tool.png",
+ stack_max = 1,
+ on_use = function(itemstack, user, pointed_thing)
+ local pname = user:get_player_name()
+ if not pname or pname == "" then
+ return
+ end
+
+ --sanity checks in case of clicking the wrong entity/node/nothing
+ if pointed_thing.type ~= "object" then return end --not an entity
+ local object = pointed_thing.ref:get_luaentity()
+ if not object.id then return end --entity doesn't have an id field
+
+ local wagon = advtrains.wagons[object.id] --check if wagon exists in advtrains
+ if not wagon then --not a wagon
+ return
+ end --end sanity checks
+
+ --whitelist protection check
+ if not advtrains.check_driving_couple_protection(pname,wagon.owner,wagon.whitelist) then
+ minetest.chat_send_player(pname, attrans("Insufficient privileges to use this!"))
+ return
+ end
+ object:show_wagon_properties(pname)
+ return itemstack
+ end,
+})
+
+if minetest.get_modpath("default") then --register recipe
+ minetest.register_craft({
+ output = "advtrains:wagon_prop_tool",
+ recipe = {
+ {"advtrains:dtrack_placer","dye:black","default:paper"},
+ {"screwdriver:screwdriver","default:paper","default:paper"},
+ {"","","group:wood"},
+ }
+ })
+end \ No newline at end of file