Added the resizer

This commit is contained in:
MysaaJava 2024-05-18 20:43:35 +02:00
parent 6e4c9f1b02
commit 3ea8517ff9
Signed by: Mysaa
GPG Key ID: DBA23608F23F5A10
3 changed files with 27 additions and 0 deletions

View File

@ -455,6 +455,16 @@ function logikraft.disconnectInCable(name,a)
then table.insert(conns,conn>=16 and 24 or 8) end then table.insert(conns,conn>=16 and 24 or 8) end
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) table.sort(conns)
return table.getkey1(logikraft.cablesconn,conns) return table.getkey1(logikraft.cablesconn,conns)
end end

View File

@ -109,6 +109,23 @@ minetest.register_craftitem("logikraft:unlinker", {
else minetest.remove_node(pointed_thing.under) else minetest.remove_node(pointed_thing.under)
end 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 return itemstack
end end
}) })

BIN
textures/resizer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB