minetest-mods / mesecons

Mod for minetest that adds digital circuitry [=Minecraft redstone]
https://mesecons.net
Other
206 stars 120 forks source link

Effectors that are conductors #638

Open Desour opened 1 year ago

Desour commented 1 year ago

Defining nodes that are a conductor and an effector at the same time doesn't work. Example:

local rules_conductor = {
    vector.new( 1, 0, 0),
    vector.new(-1, 0, 0),
}

local rules_effector = {
    vector.new(0, 0, 1),
}

minetest.register_node("mesecons_conduct_effect:node_off", {
    description = "Mesecon Conductor and Effector",
    drawtype = "normal",
    tiles = {"default_stone.png^mesecons_silicon.png"},
    groups = {dig_immediate=2},
    mesecons = {
        conductor = {
            state = mesecon.state.off,
            offstate = "mesecons_conduct_effect:node_off",
            onstate = "mesecons_conduct_effect:node_on",
            rules = rules_conductor,
        },
        effector = {
            rules = rules_effector,
            action_on = function (pos, node)
                minetest.log("(c off) action_on at "..vector.to_string(pos))
            end,
            action_off = function (pos, node)
                minetest.log("(c off) action_off at "..vector.to_string(pos))
            end,
            action_change = function (pos, node)
                minetest.log("(c off) action_change at "..vector.to_string(pos))
            end,
        }
    },
})

minetest.register_node("mesecons_conduct_effect:node_on", {
    description = "You hacker you!",
    drawtype = "normal",
    tiles = {"default_stone.png^mesecons_silicon.png"},
    drop = "mesecons_conduct_effect:node_off",
    groups = {dig_immediate=2, not_in_creative_inventory=1},
    mesecons = {
        conductor = {
            state = mesecon.state.on,
            offstate = "mesecons_conduct_effect:node_off",
            onstate = "mesecons_conduct_effect:node_on",
            rules = rules_conductor,
        },
        effector = {
            rules = rules_effector,
            action_on = function (pos, node)
                minetest.log("(c on) action_on at "..vector.to_string(pos))
            end,
            action_off = function (pos, node)
                minetest.log("(c on) action_off at "..vector.to_string(pos))
            end,
            action_change = function (pos, node)
                minetest.log("(c on) action_change at "..vector.to_string(pos))
            end,
        }
    },
})

One could expect that the action_* callbacks get executed whenever some effector-rule input changes.

I'm unsure if this is a bug report or feature request.

numberZero commented 1 year ago

See also: #406