summaryrefslogtreecommitdiff
path: root/controller.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-04-25 14:14:39 -0500
committercheapie <no-email-for-you@example.com>2024-04-25 14:14:39 -0500
commitdb5cd70f04824216506d0e6a04dcd927bd7e5421 (patch)
tree49908ba41cf3fd8fa61dfaab88d1a210b06d28bb /controller.lua
parentc5954749b7cba8f17bb4ce551946f1537b803fc0 (diff)
downloadcelevator-db5cd70f04824216506d0e6a04dcd927bd7e5421.tar
celevator-db5cd70f04824216506d0e6a04dcd927bd7e5421.tar.gz
celevator-db5cd70f04824216506d0e6a04dcd927bd7e5421.tar.bz2
celevator-db5cd70f04824216506d0e6a04dcd927bd7e5421.tar.xz
celevator-db5cd70f04824216506d0e6a04dcd927bd7e5421.zip
Require sneak to be held to remove controllers/dispatchers
These nodes are a huge pain to set back up if one is accidentally removed. This makes that less likely.
Diffstat (limited to 'controller.lua')
-rw-r--r--controller.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/controller.lua b/controller.lua
index 7001a91..184da36 100644
--- a/controller.lua
+++ b/controller.lua
@@ -116,6 +116,16 @@ local function controllerleds(pos,running)
end
end
+local function candig(_,player)
+ local controls = player:get_player_control()
+ if controls.sneak then
+ return true
+ else
+ minetest.chat_send_player(player:get_player_name(),"Hold the sneak button while digging to remove.")
+ return false
+ end
+end
+
minetest.register_node("celevator:controller",{
description = "Elevator Controller",
groups = {
@@ -148,6 +158,7 @@ minetest.register_node("celevator:controller",{
on_destruct = ondestruct,
on_rotate = onrotate,
on_receive_fields = handlefields,
+ can_dig = candig,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("mem",minetest.serialize({}))
@@ -226,6 +237,7 @@ minetest.register_node("celevator:controller_open",{
on_destruct = ondestruct,
on_rotate = onrotate,
on_receive_fields = handlefields,
+ can_dig = candig,
on_punch = function(pos,node,puncher)
if not puncher:is_player() then
return