diff --git a/digicode.lua b/digicode.lua index 0d89183..174b9b7 100644 --- a/digicode.lua +++ b/digicode.lua @@ -2,6 +2,7 @@ -------------- -- Digicode -- -------------- +local has_mesecons = minetest.get_modpath("mesecons") local secret_code = "1234" local allowed_chars = "0123456789" @@ -122,7 +123,11 @@ minetest.register_node("scifi_nodes:digicode_on", { light_source = 5, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1}, drop = {items = {"scifi_nodes:digicode_off"}}, - mesecons = {receptor = {state = mesecon.state.on,}}, + mesecons = { + receptor = { + state = (has_mesecons and mesecon.state.on) + } + }, on_timer = toggle_digicode, sounds = default.node_sound_glass_defaults(), }) @@ -140,7 +145,11 @@ minetest.register_node("scifi_nodes:digicode_off", { paramtype = "light", paramtype2 = "wallmounted", groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1}, - mesecons = {receptor = {state = mesecon.state.off,}}, + mesecons = { + receptor = { + state = (has_mesecons and mesecon.state.off) + } + }, after_place_node = set_owner, on_rightclick = show_digicode_formspec, sounds = default.node_sound_glass_defaults(), diff --git a/mod.conf b/mod.conf index aa27b70..f05a2c8 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = scifi_nodes description = Minetest mod that adds scifi themed blocks, doors, materials, plants and other assets. -depends = default,dye,basic_materials, mesecons -optional_depends = xpanes,moreblocks,mesecons_microcontroller,mesecons_button,mesecons_torch,mesecons_receiver +depends = default,dye +optional_depends = xpanes,mesecons,moreblocks,mesecons_microcontroller,mesecons_button,mesecons_torch,mesecons_receiver,basic_materials diff --git a/palm_scanner.lua b/palm_scanner.lua index da17cbc..5f07ea7 100644 --- a/palm_scanner.lua +++ b/palm_scanner.lua @@ -7,6 +7,8 @@ -- re-use all the parameters in same order ! -- ----------------------------------------------- +local has_mesecons = minetest.get_modpath("mesecons") + -- after_place_node -- placer is a player object local function set_scanner_owner(pos, placer, itemstack, pointed_thing) @@ -47,7 +49,7 @@ local function check_owner(pos, elapsed) if clicker == owner then minetest.sound_play("scifi_nodes_scanner_granted", {max_hear_distance = 8, pos = pos, gain = 1.0}) minetest.chat_send_player(clicker, "Access granted !") - toggle_palm_scanner (pos) + toggle_palm_scanner(pos) else minetest.chat_send_player(clicker, "Access refused !") minetest.sound_play("scifi_nodes_scanner_refused", {max_hear_distance = 8, pos = pos, gain = 1.0}) @@ -69,9 +71,13 @@ minetest.register_node("scifi_nodes:palm_scanner_off", { paramtype = "light", paramtype2 = "wallmounted", groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1}, - mesecons = {receptor = {state = mesecon.state.off,}}, + mesecons = { + receptor = { + state = (has_mesecons and mesecon.state.off) + } + }, after_place_node = set_scanner_owner, - on_rightclick = toggle_palm_scanner, + on_rightclick = (has_mesecons and toggle_palm_scanner), sounds = default.node_sound_glass_defaults(), }) @@ -109,8 +115,12 @@ minetest.register_node("scifi_nodes:palm_scanner_on", { light_source = 5, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1}, drop = "scifi_nodes:palm_scanner_off", - mesecons = {receptor = {state = mesecon.state.on,}}, - on_timer = toggle_palm_scanner, + mesecons = { + receptor = { + state = (has_mesecons and mesecon.state.on) + } + }, + on_timer = (has_mesecons and toggle_palm_scanner), sounds = default.node_sound_glass_defaults(), }) diff --git a/switches.lua b/switches.lua index eb79053..a1bdef0 100644 --- a/switches.lua +++ b/switches.lua @@ -3,6 +3,8 @@ -- Switches -- -------------- +local has_mesecons = minetest.get_modpath("mesecons") + local function toggle_switch(pos) local node = minetest.get_node(pos) local name = node.name @@ -32,10 +34,14 @@ minetest.register_node("scifi_nodes:switch_on", { paramtype2 = "wallmounted", light_source = 5, groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1}, - mesecons = {receptor = {state = mesecon.state.on,}}, + mesecons = { + receptor = { + state = (has_mesecons and mesecon.state.on) + } + }, sounds = default.node_sound_glass_defaults(), - on_rightclick = toggle_switch, - on_timer = toggle_switch + on_rightclick = (has_mesecons and toggle_switch), + on_timer = (has_mesecons and toggle_switch) }) minetest.register_node("scifi_nodes:switch_off", { @@ -51,9 +57,13 @@ minetest.register_node("scifi_nodes:switch_off", { paramtype = "light", paramtype2 = "wallmounted", groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1}, - mesecons = {receptor = {state = mesecon.state.off,}}, + mesecons = { + receptor = { + state = (has_mesecons and mesecon.state.off) + } + }, sounds = default.node_sound_glass_defaults(), - on_rightclick = toggle_switch + on_rightclick = (has_mesecons and toggle_switch) }) minetest.register_craft({