From 916627c6b6baa75201a73ed2051f0c7b3fbc5316 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 10 Jan 2018 18:27:47 +0100 Subject: [PATCH] Add on state for observers --- mods/ITEMS/REDSTONE/mcl_observers/init.lua | 51 ++++++++++++---------- mods/MISC/mcl_wip/init.lua | 3 +- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_observers/init.lua b/mods/ITEMS/REDSTONE/mcl_observers/init.lua index 596792dda5..b23299f2c0 100644 --- a/mods/ITEMS/REDSTONE/mcl_observers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_observers/init.lua @@ -9,43 +9,48 @@ local get_rules_flat = function(node) return rules end -minetest.register_node("mcl_observers:observer", { - description = "Observer", +mesecon.register_node("mcl_observers:observer", +{ 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 }, + on_rotate = false, + _mcl_blast_resistance = 17.5, + _mcl_hardness = 3.5, +}, +{ + description = "Observer", 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, - _mcl_blast_resistance = 17.5, - _mcl_hardness = 3.5, -- TODO: Mesecons handling - mesecons = {effector = { + mesecons = { receptor = { + state = mesecon.state.off, rules = get_rules_flat, }}, - on_rotate = false, -}) +}, +{ + _doc_items_create_entry = false, + 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_lit.png", + }, + -- TODO: Mesecons handling + mesecons = { receptor = { + state = mesecon.state.on, + rules = get_rules_flat, + }}, +} +) + minetest.register_craft({ - output = "mcl_observers:observer", + output = "mcl_observers:observer_off", recipe = { { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, { "mcl_nether:quartz", "mesecons:redstone", "mesecons:redstone" }, @@ -53,7 +58,7 @@ minetest.register_craft({ } }) minetest.register_craft({ - output = "mcl_observers:observer", + output = "mcl_observers:observer_off", recipe = { { "mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble" }, { "mesecons:redstone", "mesecons:redstone", "mcl_nether:quartz" }, diff --git a/mods/MISC/mcl_wip/init.lua b/mods/MISC/mcl_wip/init.lua index 845d1c86e1..98a2b13405 100644 --- a/mods/MISC/mcl_wip/init.lua +++ b/mods/MISC/mcl_wip/init.lua @@ -8,7 +8,8 @@ local wip_items = { "mcl_fishing:fishing_rod", "mcl_maps:empty_map", "gemalde:node_1", - "mcl_observers:observer", + "mcl_observers:observer_off", + "mcl_observers:observer_on", "mcl_chests:trapped_chest", "mobs_mc:totem", "mcl_paintings:painting",