From 3ea8517ff9d18ee6b09f44113cd51bad647d76d0 Mon Sep 17 00:00:00 2001 From: MysaaJava Date: Sat, 18 May 2024 20:43:35 +0200 Subject: [PATCH] Added the resizer --- blocks/cable.lua | 10 ++++++++++ items.lua | 17 +++++++++++++++++ textures/resizer.png | Bin 0 -> 4641 bytes 3 files changed, 27 insertions(+) create mode 100644 textures/resizer.png diff --git a/blocks/cable.lua b/blocks/cable.lua index 2d09ed1..ab390fa 100644 --- a/blocks/cable.lua +++ b/blocks/cable.lua @@ -455,6 +455,16 @@ function logikraft.disconnectInCable(name,a) then table.insert(conns,conn>=16 and 24 or 8) end end + table.sort(conns) + return table.getkey1(logikraft.cablesconn,conns) +end + +function logikraft.resizeInCable(name,a) + local conns = table.copy(logikraft.cablesconn[name]) + local cindex = logikraft.cablesnbconn[name][a] + + conns[cindex] = (conns[cindex] >= 16) and (conns[cindex] - 16) or (conns[cindex] + 16) + table.sort(conns) return table.getkey1(logikraft.cablesconn,conns) end \ No newline at end of file diff --git a/items.lua b/items.lua index f1c5dce..d0488e7 100644 --- a/items.lua +++ b/items.lua @@ -109,6 +109,23 @@ minetest.register_craftitem("logikraft:unlinker", { else minetest.remove_node(pointed_thing.under) end + return itemstack + end +}) +minetest.register_craftitem("logikraft:resizer", { + description = "The Resizer", + inventory_image = "resizer.png", + on_place = function(itemstack, user, pointed_thing) + local node = minetest.get_node(pointed_thing.under) + if not string.startsWith(node.name,"logikraft:cable_") + then return itemstack + end + + local index = logikraft.lookingAtNbIndex(user,pointed_thing.under) + + local new = logikraft.resizeInCable(string.without(node.name,"logikraft:cable_"),index) + minetest.swap_node(pointed_thing.under, {name = "logikraft:cable_" .. new}) + return itemstack end }) \ No newline at end of file diff --git a/textures/resizer.png b/textures/resizer.png new file mode 100644 index 0000000000000000000000000000000000000000..9213bde11f6ff189a6ca3e0e96c2f0e6dba19091 GIT binary patch literal 4641 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7-c*G|lms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