Mineclonia/mods/ITEMS/REDSTONE/mcl_observers/init.lua

64 lines
1.9 KiB
Lua
Raw Normal View History

2018-01-10 18:12:27 +01:00
local rules_flat = {
{ x = 0, y = 0, z = -1 },
}
local get_rules_flat = function(node)
local rules = rules_flat
for i=1, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
2017-02-15 03:06:01 +01:00
minetest.register_node("mcl_observers:observer", {
description = "Observer",
2017-02-15 03:06:01 +01:00
is_ground_content = false,
sounds = mcl_sounds.node_sound_stone_defaults(),
paramtype2 = "facedir",
-- TODO: Add to craft guide and creative inventory when it's useful
groups = {pickaxey=1, not_in_craft_guide=1, not_in_creative_inventory=1 },
2017-02-15 03:06:01 +01:00
tiles = {
"mcl_observers_observer_top.png", "default_furnace_bottom.png",
"mcl_observers_observer_side.png", "mcl_observers_observer_side.png",
"mcl_observers_observer_front.png", "mcl_observers_observer_back.png",
},
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for i=1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.add_item(p, stack)
end
end
meta:from_table(meta2:to_table())
end,
2017-02-22 16:22:28 +01:00
_mcl_blast_resistance = 17.5,
_mcl_hardness = 3.5,
2017-02-15 03:06:01 +01:00
-- TODO: Mesecons handling
mesecons = {effector = {
2018-01-10 18:12:27 +01:00
rules = get_rules_flat,
}},
on_rotate = false,
2017-02-15 03:06:01 +01:00
})
minetest.register_craft({
output = "mcl_observers:observer",
recipe = {
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
{ "mcl_nether:quartz", "mesecons:redstone", "mesecons:redstone" },
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
}
})
minetest.register_craft({
output = "mcl_observers:observer",
recipe = {
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
{ "mesecons:redstone", "mesecons:redstone", "mcl_nether:quartz" },
{ "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" },
}
})