Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added static vertical mesecons (for more compact circuits) #480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 86 additions & 4 deletions mesecons_extrawires/vertical.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ local bottom_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16},
{-1/16, -7/16, -1/16, 1/16, 8/16, 1/16},
{-1/16, -7/16, -1/16, 1/16, 8/16, 1/16}
}
}


local vertical_rules = {
{x=0, y=1, z=0},
{x=0, y=-1, z=0}
Expand All @@ -38,10 +39,20 @@ local bottom_rules = {
{x=0, y=2, z=0} -- receive power from pressure plate / detector / ... 2 nodes above
}

local static_bottom_rules = { -- same as bottom rules, but also receives power from below
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=0, y=0, z=-1},
{x=0, y=1, z=0},
{x=0, y=-1, z=0},
{x=0, y=2, z=0} -- receive power from pressure plate / detector / ... 2 nodes above
}

local vertical_updatepos = function (pos)
local node = minetest.get_node(pos)
if minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].is_vertical_conductor then
and (minetest.registered_nodes[node.name].is_vertical_conductor or minetest.registered_nodes[node.name].is_static_vertical_conductor) then
local node_above = minetest.get_node(vector.add(pos, vertical_rules[1]))
local node_below = minetest.get_node(vector.add(pos, vertical_rules[2]))

Expand All @@ -63,8 +74,9 @@ local vertical_updatepos = function (pos)
else -- no vertical wire above, no vertical wire below: use bottom
newname = newname .. "bottom_off"
end

minetest.set_node(pos, {name = newname})
if not minetest.registered_nodes[node.name].is_static_vertical_conductor then
minetest.set_node(pos, {name = newname})
end
mesecon.on_placenode(pos, {name = newname})
end
end
Expand Down Expand Up @@ -172,6 +184,76 @@ mesecon.register_node("mesecons_extrawires:vertical_bottom", {
}}
})

-- Static vertical wire bottom
mesecon.register_node("mesecons_extrawires:static_vertical_bottom", {
description = "Bottom-static vertical mesecon",
drawtype = "nodebox",
walkable = false,
paramtype = "light",
is_ground_content = false,
sunlight_propagates = true,
groups = {dig_immediate = 3},
selection_box = bottom_box,
node_box = bottom_box,
is_static_vertical_conductor = true,
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
after_dig_node = vertical_update,
sounds = default.node_sound_defaults(),
},{
tiles = {"mesecons_wire_off.png"},
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:static_vertical_bottom_on",
rules = static_bottom_rules,
}}
},{
tiles = {"mesecons_wire_on.png"},
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:static_vertical_bottom_off",
rules = static_bottom_rules,
}}

})


-- Static Vertical wire
mesecon.register_node("mesecons_extrawires:static_vertical", {
description = "Static Vertical Mesecon",
drawtype = "nodebox",
walkable = false,
paramtype = "light",
is_ground_content = false,
sunlight_propagates = true,
selection_box = vertical_box,
node_box = vertical_box,
is_static_vertical_conductor = true,
drop = "mesecons_extrawires:static_vertical_off",
after_place_node = vertical_update,
after_dig_node = vertical_update,
sounds = default.node_sound_defaults(),
},{
tiles = {"mesecons_wire_off.png"},
groups = {dig_immediate=3},
mesecons = {conductor = {
state = mesecon.state.off,
onstate = "mesecons_extrawires:static_vertical_on",
rules = vertical_rules,
}}
},{
tiles = {"mesecons_wire_on.png"},
groups = {dig_immediate=3, not_in_creative_inventory=1},
mesecons = {conductor = {
state = mesecon.state.on,
offstate = "mesecons_extrawires:static_vertical_off",
rules = vertical_rules,
}}
})


-- Craftings
minetest.register_craft({
output = "mesecons_extrawires:vertical_off 3",
recipe = {
Expand Down