From cf6080f7237af1c55a6d80bea4725dcb5c8cb1eb Mon Sep 17 00:00:00 2001 From: Jeija Date: Sat, 8 Dec 2012 22:28:46 +0100 Subject: Port more blocks to nodedef system: object detector, extrawires, water turbine, insulated wire --- mesecons_detector/init.lua | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'mesecons_detector/init.lua') diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua index cbee787..1d5b214 100644 --- a/mesecons_detector/init.lua +++ b/mesecons_detector/init.lua @@ -1,19 +1,29 @@ ---SHORT RANGE DETECTORS +-- Object detector +-- Detects all entities in a certain radius +-- The radius can be specified in mesecons/settings.lua + minetest.register_node("mesecons_detector:object_detector_off", { tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png"}, paramtype = "light", walkable = true, - groups = {cracky=3, mesecon = 2}, + groups = {cracky=3}, description="Player Detector", + mesecons = {receptor = { + state = mesecon.state.off, + rules = mesecon.rules.pressurplatelike + }} }) minetest.register_node("mesecons_detector:object_detector_on", { tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"}, paramtype = "light", walkable = true, - groups = {cracky=3,not_in_creative_inventory=1, mesecon = 2}, + groups = {cracky=3,not_in_creative_inventory=1}, drop = 'mesecons_detector:object_detector_off', - description="Player Detector", + mesecons = {receptor = { + state = mesecon.state.on, + rules = mesecon.rules.pressurplatelike + }} }) minetest.register_craft({ @@ -30,9 +40,9 @@ minetest.register_abm( interval = 1.0, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - local objs = minetest.env:get_objects_inside_radius(pos, 6) + local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS) for k, obj in pairs(objs) do - if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj:get_player_name()~=nil then -- Detected object is not piston pusher - will be changed if every entity has a type (like entity_type=mob) + if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj:get_player_name()~=nil then if minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name=="default:sign_wall" then if obj:get_player_name()~=minetest.env:get_meta({x=pos.x, y=pos.y-1, z=pos.z}):get_string("text") then return @@ -51,7 +61,7 @@ minetest.register_abm( interval = 1.0, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - local objs = minetest.env:get_objects_inside_radius(pos, 6) + local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS) local objectfound=0 for k, obj in pairs(objs) do if obj:get_entity_name()~="mesecons_pistons:piston_pusher_sticky" and obj:get_entity_name()~="mesecons_pistons:piston_pusher_normal" and obj~=nil @@ -72,6 +82,3 @@ minetest.register_abm( end end, }) - -mesecon:add_receptor_node("mesecons_detector:object_detector_on", mesecon:get_rules("pressureplate")) -mesecon:add_receptor_node_off("mesecons_detector:object_detector_off", mesecon:get_rules("pressureplate")) -- cgit v1.2.3 From b37bdbf55cf6d3205d5dd7a2491a8bd855cbbd76 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 9 Dec 2012 00:42:30 +0100 Subject: Port a lot more (basically everything apart from gates, pistons and extrawire crossing) to the new nodedef system. There are some problems with wall button and wall lever (in the way they visually connect to wires) --- mesecons_detector/init.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'mesecons_detector/init.lua') diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua index 1d5b214..2394e96 100644 --- a/mesecons_detector/init.lua +++ b/mesecons_detector/init.lua @@ -9,8 +9,7 @@ minetest.register_node("mesecons_detector:object_detector_off", { groups = {cracky=3}, description="Player Detector", mesecons = {receptor = { - state = mesecon.state.off, - rules = mesecon.rules.pressurplatelike + state = mesecon.state.off }} }) @@ -21,8 +20,7 @@ minetest.register_node("mesecons_detector:object_detector_on", { groups = {cracky=3,not_in_creative_inventory=1}, drop = 'mesecons_detector:object_detector_off', mesecons = {receptor = { - state = mesecon.state.on, - rules = mesecon.rules.pressurplatelike + state = mesecon.state.on }} }) @@ -50,7 +48,7 @@ minetest.register_abm( end local objpos=obj:getpos() minetest.env:add_node(pos, {name="mesecons_detector:object_detector_on"}) - mesecon:receptor_on(pos, mesecon:get_rules("pressureplate")) + mesecon:receptor_on(pos) end end end, @@ -78,7 +76,7 @@ minetest.register_abm( end if objectfound==0 then minetest.env:add_node(pos, {name="mesecons_detector:object_detector_off"}) - mesecon:receptor_off(pos, mesecon:get_rules("pressureplate")) + mesecon:receptor_off(pos) end end, }) -- cgit v1.2.3