Added the resizer
This commit is contained in:
parent
6e4c9f1b02
commit
3ea8517ff9
@ -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
|
||||||
17
items.lua
17
items.lua
@ -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
BIN
textures/resizer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
Loading…
x
Reference in New Issue
Block a user