From f873bb551f8c0efd15ed35850bed4d75bf3e354e Mon Sep 17 00:00:00 2001 From: loosewheel <76670709+loosewheel@users.noreply.github.com> Date: Sat, 5 Feb 2022 02:08:42 +1000 Subject: [PATCH] Add files via upload --- change.log | 3 ++ crafting.lua | 16 +++++++++- init.lua | 3 +- license.txt | 2 ++ readme.txt | 3 +- through_wire.lua | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 through_wire.lua diff --git a/change.log b/change.log index 67918d9..1bad0f1 100644 --- a/change.log +++ b/change.log @@ -95,3 +95,6 @@ v0.1.16 v0.1.17 * Fixed unintended global variable in pistons.lua. + +v0.1.18 +* Added mesecons through wire. diff --git a/crafting.lua b/crafting.lua index 9ebfbd3..0079277 100644 --- a/crafting.lua +++ b/crafting.lua @@ -49,7 +49,21 @@ minetest.register_craft( { { "default:iron_lump", "default:coalblock" }, }, }) -end +end -- minetest.global_exists ("fire") + + + +if utils.mesecon_supported then + +minetest.register_craft( { + output = "lwcomponents:through_wire_off 2", + recipe = { + { "", "mesecons:wire_00000000_off" }, + { "mesecons:wire_00000000_off", "" }, + }, +}) + +end -- utils.mesecon_supported diff --git a/init.lua b/init.lua index 797fd39..4592fcc 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -local version = "0.1.17" +local version = "0.1.18" local mod_storage = minetest.get_mod_storage () @@ -35,6 +35,7 @@ loadfile (modpath.."/conduit.lua") (utils, mod_storage) loadfile (modpath.."/cannon.lua") (utils) loadfile (modpath.."/cannon_shell.lua") (utils) loadfile (modpath.."/pistons.lua") (utils) +loadfile (modpath.."/through_wire.lua") (utils) loadfile (modpath.."/extras.lua") (utils) loadfile (modpath.."/digiswitch.lua") (utils) loadfile (modpath.."/movefloor.lua") (utils) diff --git a/license.txt b/license.txt index 66d38de..df9399d 100644 --- a/license.txt +++ b/license.txt @@ -13,6 +13,8 @@ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR See the GNU Lesser General Public License for more details: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html +Mesecons through wire code was adapted from mesecons_receiver. + lwsiren-buzz.ogg diff --git a/readme.txt b/readme.txt index 4ee195a..5e8f5d0 100644 --- a/readme.txt +++ b/readme.txt @@ -13,7 +13,7 @@ CC BY-SA 3.0 Version ======= -0.1.17 +0.1.18 Minetest Version @@ -66,6 +66,7 @@ Various components for mesecons and digilines. * Double (optionally single) reach pistons and sticky pistons. * Digiswitch, digilines controlled mesecons power. * Movefloor, similar to vertical mesecons movestone. +* Mesecons Through Wire, transmits through 1 to 2 solid blocks. * Solid color conductor blocks, same as Solid Color Block but also mesecons and digilines conductor. diff --git a/through_wire.lua b/through_wire.lua new file mode 100644 index 0000000..e1cda7b --- /dev/null +++ b/through_wire.lua @@ -0,0 +1,80 @@ +local utils = ... +local S = utils.S + + + +if utils.mesecon_supported then + + + +local through_wire_get_rules = function (node) + local rules = { {x = -1, y = 0, z = 0}, + {x = 2, y = 0, z = 0}, + {x = 3, y = 0, z = 0} } + + if node.param2 == 2 then + rules = mesecon.rotate_rules_left(rules) + elseif node.param2 == 3 then + rules = mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules)) + elseif node.param2 == 0 then + rules = mesecon.rotate_rules_right(rules) + end + + return rules +end + + + +mesecon.register_node ("lwcomponents:through_wire", { + description = S("Mesecons Through Wire"), + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + sunlight_propagates = true, + walkable = false, + on_rotate = false, + selection_box = { + type = "fixed", + fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 } + }, + node_box = { + type = "fixed", + fixed = { + { -3/16, -3/16, 13/32 , 3/16, 3/16 , 8/16 }, -- the smaller bump + { -1/32, -1/32, 1/2 , 1/32, 1/32 , 3/2 }, -- the wire through the block + { -2/32, -1/2 , 0.5002-3/32 , 2/32, 0 , 0.5 }, -- the vertical wire bit + { -2/32, -1/2 , -16/32+0.001 , 2/32, -14/32, 7/16+0.002 } -- the horizontal wire + } + }, + drop = "lwcomponents:through_wire_off", + sounds = default.node_sound_defaults(), +}, { + tiles = { "mesecons_wire_off.png" }, + groups = { dig_immediate = 3 }, + mesecons = { + conductor = { + state = mesecon.state.off, + rules = through_wire_get_rules, + onstate = "lwcomponents:through_wire_on" + } + } +}, { + tiles = { "mesecons_wire_on.png" }, + groups = { dig_immediate = 3, not_in_creative_inventory = 1 }, + mesecons = { + conductor = { + state = mesecon.state.on, + rules = through_wire_get_rules, + offstate = "lwcomponents:through_wire_off" + } + } +}) + + + +end -- utils.mesecon_supported + + + +--