Advertisement
Guest User

Untitled

a guest
Aug 15th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.95 KB | None | 0 0
  1. local function isempty(s)
  2.   return s == nil or s == ''
  3. end
  4.  
  5. minetest.register_node("firesafety:beepybox", {
  6.     description = "Emergency button for fires",
  7.     tiles = {
  8.     "fire_safety_redside.png",
  9.     "fire_safety_redside.png",
  10.     "fire_safety_redside.png",
  11.     "fire_safety_redside.png",
  12.     "fire_safety_redside.png",
  13.     "fire_safety_fire_button.png"},
  14.     groups = {dig_immediate=2},
  15.     paramtype = "light",
  16.     paramtype2 = "facedir",
  17.     drawtype = "nodebox",
  18.     paramtype = "light",
  19.     node_box = {
  20.         type = "fixed",
  21.         fixed = {
  22.             {-0.3125, -0.3125, 0.125, -0.1875, 0.3125, 0.5}, -- NodeBox2
  23.             {-0.1875, -0.25, 0.1875, 0.1875, 0.1875, 0.5}, -- NodeBox3
  24.             {-0.25, 0.1875, 0.125, 0.3125, 0.3125, 0.5}, -- NodeBox4
  25.             {0.1875, -0.3125, 0.125, 0.3125, 0.3125, 0.5}, -- NodeBox5
  26.             {-0.25, -0.3125, 0.125, 0.3125, -0.1875, 0.5}, -- NodeBox6
  27.         }
  28.     },
  29.    
  30.     digilines = {
  31.         effector = {
  32.             action = function() end
  33.         }
  34.     },
  35.    
  36.     on_punch = function(pos, node, puncher, pointed_thing) 
  37.         if puncher:is_player() then
  38.             print(puncher:get_player_name() .. " pounded the alarm at ")
  39.             print(pos)
  40.         end
  41.        
  42.         local setchan = minetest.get_meta(pos):get_string("channel")
  43.        
  44.         print("Sending to " ..  setchan)
  45.            
  46.         digilines.receptor_send(pos, rules, setchan, "fire")
  47.        
  48.         -- TODO: store the name of the puncher in somewhere permanent
  49.     end,
  50.    
  51.     on_construct = function(pos)
  52.         local meta = minetest.get_meta(pos)
  53.         meta:set_string("formspec", "field[channel;Channel;${channel}]")
  54.     end,
  55.    
  56.     on_receive_fields = function(pos, _, fields, sender)
  57.         local name = sender:get_player_name()
  58.         if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then
  59.             minetest.record_protection_violation(pos, name)
  60.             return
  61.         end
  62.         if (fields.channel) then
  63.             minetest.get_meta(pos):set_string("channel", fields.channel)
  64.         end
  65.     end
  66. })
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement