diff options
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | init.lua | 99 | ||||
-rw-r--r-- | textures/digistuff_camera_back.png | bin | 0 -> 1881 bytes | |||
-rw-r--r-- | textures/digistuff_camera_bottom.png | bin | 0 -> 303 bytes | |||
-rw-r--r-- | textures/digistuff_camera_front.png | bin | 0 -> 1784 bytes | |||
-rw-r--r-- | textures/digistuff_camera_left.png | bin | 0 -> 1754 bytes | |||
-rw-r--r-- | textures/digistuff_camera_pole.png | bin | 0 -> 3213 bytes | |||
-rw-r--r-- | textures/digistuff_camera_right.png | bin | 0 -> 1831 bytes | |||
-rw-r--r-- | textures/digistuff_camera_top.png | bin | 0 -> 239 bytes |
9 files changed, 105 insertions, 1 deletions
@@ -10,7 +10,7 @@ Textures WITH "adwaita" in the file name - These are icons by the GNOME Project, Depends: Required: digilines (base only) and mesecons (base only) -Only needed for craft recipes: default and mesecons_luacontroller +Only needed for craft recipes: default, mesecons_luacontroller, homedecor How to use digilines buttons: @@ -34,3 +34,8 @@ Once a channel is set, any messages sent on that channel will be shown on the "L How to use the NIC: Send a digilines signal with the URL you want to download. The HTTPRequestResult table will be sent back on the same channel. + + +How to use the camera: +Set the channel, distance, and radius. The camera will search for a node "distance" meters away and up to 10m down. +Every second while a player is within "radius" meters of that point, a table listing the players in range will be sent via digilines on the chosen channel. @@ -829,3 +829,102 @@ if http then } }) end + +minetest.register_node("digistuff:camera", { + tiles = { + "digistuff_camera_top.png", + "digistuff_camera_bottom.png", + "digistuff_camera_right.png", + "digistuff_camera_left.png", + "digistuff_camera_back.png", + "digistuff_camera_front.png", + }, + digiline = + { + receptor = {} + }, + groups = {cracky=2}, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.1,-0.5,-0.28,0.1,-0.3,0.3}, --Camera Body + {-0.045,-0.42,-0.34,0.045,-0.36,-0.28}, -- Lens + {-0.05,-0.9,-0.05,0.05,-0.5,0.05}, --Pole + } + }, + selection_box = { + type = "fixed", + fixed = { + {-0.1,-0.5,-0.34,0.1,-0.3,0.3}, --Camera Body + } + }, + description = "Digilines Camera", + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec","size[8,6;]field[1,1;6,2;channel;Channel;${channel}]field[1,2;6,2;radius;Radius (max 10);${radius}]field[1,3;6,2;distance;Distance (max 20);${distance}]button_exit[2.25,4;3,1;submit;Save]") + end, + on_receive_fields = function(pos, formname, fields, sender) + local name = sender:get_player_name() + if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then + minetest.record_protection_violation(pos,name) + return + end + local meta = minetest.get_meta(pos) + if fields.channel then meta:set_string("channel",fields.channel) end + if fields.distance and tonumber(fields.distance) then meta:set_int("distance",math.max(math.min(20,fields.distance),0)) end + if fields.radius and tonumber(fields.radius) then meta:set_int("radius",math.max(math.min(10,fields.radius),1)) end + end, + sounds = default.node_sound_stone_defaults() +}) + +minetest.register_abm({ + nodenames = {"digistuff:camera"}, + interval = 1.0, + chance = 1, + action = function(pos,node) + local meta = minetest.get_meta(pos) + local channel = meta:get_string("channel") + local radius = meta:get_int("radius") + local distance = meta:get_int("distance") + local dir = vector.multiply(minetest.facedir_to_dir(node.param2),-1) + local spot = vector.add(pos,vector.multiply(dir,distance)) + local i = 0 + while i <= 10 and minetest.get_node(spot).name == "air" do + --Downward search for ground level + spot = vector.add(spot,vector.new(0,-1,0)) + i = i + 1 + end + if minetest.get_node(spot).name == "air" or minetest.get_node(spot).name == "ignore" then + --Ground not in range + return + end + + local found_any = false + local players_found = {} + local objs = minetest.get_objects_inside_radius(spot,radius) + if objs then + local _,obj + for _,obj in ipairs(objs) do + if obj:is_player() then + table.insert(players_found,obj:get_player_name()) + found_any = true + end + end + if found_any then + digiline:receptor_send({x=pos.x,y=pos.y-1,z=pos.z}, digiline.rules.default, channel, players_found) + end + end + end +}) + +minetest.register_craft({ + output = "digistuff:camera", + recipe = { + {"homedecor:plastic_sheeting","homedecor:plastic_sheeting","homedecor:plastic_sheeting"}, + {"default:glass","homedecor:ic","mesecons_luacontroller:luacontroller0000"}, + {"homedecor:plastic_sheeting","homedecor:plastic_sheeting","homedecor:plastic_sheeting"}, + } +}) diff --git a/textures/digistuff_camera_back.png b/textures/digistuff_camera_back.png Binary files differnew file mode 100644 index 0000000..61653a7 --- /dev/null +++ b/textures/digistuff_camera_back.png diff --git a/textures/digistuff_camera_bottom.png b/textures/digistuff_camera_bottom.png Binary files differnew file mode 100644 index 0000000..72bce61 --- /dev/null +++ b/textures/digistuff_camera_bottom.png diff --git a/textures/digistuff_camera_front.png b/textures/digistuff_camera_front.png Binary files differnew file mode 100644 index 0000000..4981c98 --- /dev/null +++ b/textures/digistuff_camera_front.png diff --git a/textures/digistuff_camera_left.png b/textures/digistuff_camera_left.png Binary files differnew file mode 100644 index 0000000..0243ad1 --- /dev/null +++ b/textures/digistuff_camera_left.png diff --git a/textures/digistuff_camera_pole.png b/textures/digistuff_camera_pole.png Binary files differnew file mode 100644 index 0000000..49a5ef8 --- /dev/null +++ b/textures/digistuff_camera_pole.png diff --git a/textures/digistuff_camera_right.png b/textures/digistuff_camera_right.png Binary files differnew file mode 100644 index 0000000..5dca35f --- /dev/null +++ b/textures/digistuff_camera_right.png diff --git a/textures/digistuff_camera_top.png b/textures/digistuff_camera_top.png Binary files differnew file mode 100644 index 0000000..fca75f8 --- /dev/null +++ b/textures/digistuff_camera_top.png |