mesecons/mesecons_random/init.lua
Carter Kolwey 912f17f335 Split wires into their own mod, introduce autoconnect hooks
The update_autoconnect function had to be abstracted away from the
default wires, any kind of wire can now register autoconnect hooks,
which should make having multiple different wire types much easier.

mesecons_mvps, mesecons_receiver and mesecons_random made use of
update_autoconnect, their code was also adapted. This also fixes a
receiver bug: If a receiver was placed with a onstate receptor next
to it (but not the wall lever / button that caused the receiver to
appear) the receiver didn't turn on in the past.

Also move documentation for mesecon wire into mesecons_wire.
2016-08-23 11:08:53 +02:00

86 lines
2.2 KiB
Lua

-- REMOVESTONE
minetest.register_node("mesecons_random:removestone", {
tiles = {"jeija_removestone.png"},
inventory_image = minetest.inventorycube("jeija_removestone_inv.png"),
groups = {cracky=3},
description="Removestone",
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
minetest.remove_node(pos)
mesecon.on_dignode(pos, node)
end
}}
})
minetest.register_craft({
output = 'mesecons_random:removestone 4',
recipe = {
{"", "default:cobble", ""},
{"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
{"", "default:cobble", ""},
}
})
-- GHOSTSTONE
minetest.register_node("mesecons_random:ghoststone", {
description="Ghoststone",
tiles = {"jeija_ghoststone.png"},
is_ground_content = true,
inventory_image = minetest.inventorycube("jeija_ghoststone_inv.png"),
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
mesecons = {conductor = {
state = mesecon.state.off,
rules = { --axes
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = -1, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 1},
},
onstate = "mesecons_random:ghoststone_active"
}}
})
minetest.register_node("mesecons_random:ghoststone_active", {
drawtype = "airlike",
pointable = false,
walkable = false,
diggable = false,
sunlight_propagates = true,
paramtype = "light",
mesecons = {conductor = {
state = mesecon.state.on,
rules = {
{x = -1, y = 0, z = 0},
{x = 1, y = 0, z = 0},
{x = 0, y = -1, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y = 0, z = -1},
{x = 0, y = 0, z = 1},
},
offstate = "mesecons_random:ghoststone"
}},
on_construct = function(pos)
-- remove shadow
shadowpos = vector.add(pos, vector.new(0, 1, 0))
if (minetest.get_node(shadowpos).name == "air") then
minetest.dig_node(shadowpos)
end
end
})
minetest.register_craft({
output = 'mesecons_random:ghoststone 4',
recipe = {
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
{"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
}
})