mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-08-20 13:04:10 +02:00
Code cleanup, little bugfix (some conductors placed next to receptors didn't turn on)
This commit is contained in:
parent
987de2c7d5
commit
b197d29bef
@ -191,14 +191,15 @@ function mesecon:register_on_signal_change(action)
|
|||||||
mesecon.actions_change[i]=action
|
mesecon.actions_change[i]=action
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon:register_conductor (onstate, offstate)
|
function mesecon:register_conductor (onstate, offstate, rules)
|
||||||
local i=0
|
local i=0
|
||||||
while mesecon.conductors[i]~=nil do
|
while mesecon.conductors[i]~=nil do
|
||||||
i=i+1
|
i=i+1
|
||||||
end
|
end
|
||||||
mesecon.conductors[i]={}
|
mesecon.conductors[i]={}
|
||||||
mesecon.conductors[i].on=onstate
|
mesecon.conductors[i].on = onstate
|
||||||
mesecon.conductors[i].off=offstate
|
mesecon.conductors[i].off = offstate
|
||||||
|
mesecon.conductors[i].rules = offstate
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon:add_rules("default",
|
mesecon:add_rules("default",
|
||||||
|
@ -325,10 +325,11 @@ function mesecon:is_powered_by_receptor(pos)
|
|||||||
local i = 1
|
local i = 1
|
||||||
local j = 1
|
local j = 1
|
||||||
local k = 1
|
local k = 1
|
||||||
|
local rules
|
||||||
local pos_checked = false
|
local pos_checked = false
|
||||||
|
|
||||||
while mesecon.rules[i]~=nil do
|
while mesecon.rules[i]~=nil do
|
||||||
j=1
|
local j=1
|
||||||
while mesecon.rules[i].rules[j]~=nil do
|
while mesecon.rules[i].rules[j]~=nil do
|
||||||
rcpt_pos = {
|
rcpt_pos = {
|
||||||
x = pos.x-mesecon.rules[i].rules[j].x,
|
x = pos.x-mesecon.rules[i].rules[j].x,
|
||||||
@ -350,14 +351,15 @@ function mesecon:is_powered_by_receptor(pos)
|
|||||||
|
|
||||||
if mesecon:is_receptor_node(rcpt.name) then
|
if mesecon:is_receptor_node(rcpt.name) then
|
||||||
rules = mesecon:receptor_get_rules(rcpt)
|
rules = mesecon:receptor_get_rules(rcpt)
|
||||||
|
j = 1
|
||||||
while rules[j] ~= nil do
|
while rules[j] ~= nil do
|
||||||
if pos.x + rules[j].x == rcpt_pos.x
|
if rcpt_pos.x + rules[j].x == pos.x
|
||||||
and pos.y + rules[j].y == rcpt_pos.y
|
and rcpt_pos.y + rules[j].y == pos.y
|
||||||
and pos.z + rules[j].z == rcpt_pos.z then
|
and rcpt_pos.z + rules[j].z == pos.z then
|
||||||
return true
|
return true
|
||||||
|
end
|
||||||
|
j=j+1
|
||||||
end
|
end
|
||||||
j=j+1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
j=j+1
|
j=j+1
|
||||||
|
@ -26,9 +26,6 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
|
|||||||
drop='"mesecons_blinkyplant:blinky_plant_off" 1',
|
drop='"mesecons_blinkyplant:blinky_plant_off" 1',
|
||||||
light_source = LIGHT_MAX-7,
|
light_source = LIGHT_MAX-7,
|
||||||
description = "Blinky Plant",
|
description = "Blinky Plant",
|
||||||
after_dig_node = function(pos)
|
|
||||||
mesecon:receptor_off(pos)
|
|
||||||
end,
|
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||||
|
@ -56,9 +56,6 @@ minetest.register_node("mesecons_button:button_on", {
|
|||||||
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 1},
|
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 1},
|
||||||
drop = 'mesecons_button:button_off',
|
drop = 'mesecons_button:button_off',
|
||||||
description = "Button",
|
description = "Button",
|
||||||
after_dig_node = function(pos, oldnode)
|
|
||||||
mesecon:receptor_off(pos, mesecon.button_get_rules(oldnode.param2))
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||||
|
@ -14,9 +14,6 @@ minetest.register_node("mesecons_detector:object_detector_on", {
|
|||||||
groups = {cracky=3,not_in_creative_inventory=1, mesecon = 2},
|
groups = {cracky=3,not_in_creative_inventory=1, mesecon = 2},
|
||||||
drop = 'mesecons_detector:object_detector_off',
|
drop = 'mesecons_detector:object_detector_off',
|
||||||
description="Player Detector",
|
description="Player Detector",
|
||||||
after_dig_node = function(pos)
|
|
||||||
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -76,5 +73,5 @@ minetest.register_abm(
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_detector:object_detector_on")
|
mesecon:add_receptor_node("mesecons_detector:object_detector_on", mesecon:get_rules("pressureplate"))
|
||||||
mesecon:add_receptor_node_off("mesecons_detector:object_detector_off")
|
mesecon:add_receptor_node_off("mesecons_detector:object_detector_off", mesecon:get_rules("pressureplate"))
|
||||||
|
@ -10,12 +10,6 @@ minetest.register_node("mesecons_powerplant:power_plant", {
|
|||||||
groups = {dig_immediate=3, mesecon = 2},
|
groups = {dig_immediate=3, mesecon = 2},
|
||||||
light_source = LIGHT_MAX-9,
|
light_source = LIGHT_MAX-9,
|
||||||
description="Power Plant",
|
description="Power Plant",
|
||||||
after_place_node = function(pos)
|
|
||||||
mesecon:receptor_on(pos)
|
|
||||||
end,
|
|
||||||
after_dig_node = function(pos)
|
|
||||||
mesecon:receptor_off(pos)
|
|
||||||
end,
|
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
|
||||||
|
@ -36,9 +36,6 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
|
|||||||
},
|
},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
|
||||||
drop='"mesecons_pressureplates:pressure_plate_wood_off" 1',
|
drop='"mesecons_pressureplates:pressure_plate_wood_off" 1',
|
||||||
after_dig_node = function(pos)
|
|
||||||
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -77,9 +74,6 @@ minetest.register_abm(
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on")
|
|
||||||
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off")
|
|
||||||
|
|
||||||
-- PRESSURE PLATE STONE
|
-- PRESSURE PLATE STONE
|
||||||
|
|
||||||
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
|
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
|
||||||
@ -118,9 +112,6 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
|
|||||||
},
|
},
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
|
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
|
||||||
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
|
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
|
||||||
after_dig_node = function(pos)
|
|
||||||
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -159,9 +150,6 @@ minetest.register_abm(
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on")
|
|
||||||
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off")
|
|
||||||
|
|
||||||
mesecon:add_rules("pressureplate",
|
mesecon:add_rules("pressureplate",
|
||||||
{{x=0, y=1, z=-1},
|
{{x=0, y=1, z=-1},
|
||||||
{x=0, y=0, z=-1},
|
{x=0, y=0, z=-1},
|
||||||
@ -178,3 +166,9 @@ mesecon:add_rules("pressureplate",
|
|||||||
{x=0, y=-1, z=0},
|
{x=0, y=-1, z=0},
|
||||||
{x=0, y=-2, z=0},
|
{x=0, y=-2, z=0},
|
||||||
{x=0, y=1, z=0}})
|
{x=0, y=1, z=0}})
|
||||||
|
|
||||||
|
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on", mesecon:get_rules("pressureplate"))
|
||||||
|
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off", mesecon:get_rules("pressureplate"))
|
||||||
|
|
||||||
|
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on", mesecon:get_rules("pressureplate"))
|
||||||
|
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off", mesecon:get_rules("pressureplate"))
|
||||||
|
@ -23,9 +23,6 @@ minetest.register_node("mesecons_solarpanel:solar_panel", {
|
|||||||
furnace_burntime = 5,
|
furnace_burntime = 5,
|
||||||
groups = {dig_immediate=3, mesecon = 2},
|
groups = {dig_immediate=3, mesecon = 2},
|
||||||
description="Solar Panel",
|
description="Solar Panel",
|
||||||
after_dig_node = function(pos, node, digger)
|
|
||||||
mesecon:receptor_off(pos)
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -13,9 +13,6 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
|
|||||||
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 2},
|
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 2},
|
||||||
drop='"mesecons_switch:mesecon_switch_off" 1',
|
drop='"mesecons_switch:mesecon_switch_off" 1',
|
||||||
description="Switch",
|
description="Switch",
|
||||||
after_dig_node = function(pos)
|
|
||||||
mesecon:receptor_off(pos)
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon:add_receptor_node("mesecons_switch:mesecon_switch_on")
|
mesecon:add_receptor_node("mesecons_switch:mesecon_switch_on")
|
||||||
|
@ -46,13 +46,6 @@ minetest.register_node("mesecons_torch:mesecon_torch_on", {
|
|||||||
groups = {dig_immediate=3, mesecon = 2},
|
groups = {dig_immediate=3, mesecon = 2},
|
||||||
light_source = LIGHT_MAX-5,
|
light_source = LIGHT_MAX-5,
|
||||||
description="Mesecon Torch",
|
description="Mesecon Torch",
|
||||||
after_place_node = function(pos)
|
|
||||||
local rules = mesecon.torch_get_rules(minetest.env:get_node(pos).param2)
|
|
||||||
mesecon:receptor_on(pos, rules)
|
|
||||||
end,
|
|
||||||
after_dig_node = function(pos)
|
|
||||||
mesecon:receptor_off(pos)
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -59,9 +59,6 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
|||||||
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 1},
|
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 1},
|
||||||
drop = '"mesecons_walllever:wall_lever_off" 1',
|
drop = '"mesecons_walllever:wall_lever_off" 1',
|
||||||
description="Lever",
|
description="Lever",
|
||||||
after_dig_node = function(pos, oldnode)
|
|
||||||
mesecon:receptor_off(pos, mesecon.button_get_rules(oldnode.param2))
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||||
|
Loading…
Reference in New Issue
Block a user