Compare commits
2 Commits
3d9944921f
...
3ea8517ff9
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ea8517ff9 | |||
| 6e4c9f1b02 |
@ -367,7 +367,8 @@ function logikraft.connFromDir(name,dir)
|
|||||||
for i,c in ipairs(conns)
|
for i,c in ipairs(conns)
|
||||||
do
|
do
|
||||||
if (math.fmod(c,2*dir8) - dir8 >= 0)
|
if (math.fmod(c,2*dir8) - dir8 >= 0)
|
||||||
then return i
|
then
|
||||||
|
return i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
@ -390,10 +391,12 @@ function logikraft.connectContiguousCable(namea,posa,a,nameb,posb,b)
|
|||||||
|
|
||||||
local connsa = table.copy(logikraft.cablesconn[namea])
|
local connsa = table.copy(logikraft.cablesconn[namea])
|
||||||
local connsb = table.copy(logikraft.cablesconn[nameb])
|
local connsb = table.copy(logikraft.cablesconn[nameb])
|
||||||
|
print(dump(connsa))
|
||||||
|
print(dump(connsb))
|
||||||
local cia = logikraft.cablesnbconn[namea][a]
|
local cia = logikraft.cablesnbconn[namea][a]
|
||||||
local cib = logikraft.cablesnbconn[nameb][b]
|
local cib = logikraft.cablesnbconn[nameb][b]
|
||||||
local cia2 = logikraft.connFromDir(namea,dira)
|
local cia2 = logikraft.connFromDir(namea,dira)
|
||||||
local cib2 = logikraft.connFromDir(nameb,3 - dira)
|
local cib2 = logikraft.connFromDir(nameb,math.fmod(dira+2,4))
|
||||||
print(dira)
|
print(dira)
|
||||||
print(cia)
|
print(cia)
|
||||||
print(cia2)
|
print(cia2)
|
||||||
@ -407,7 +410,7 @@ function logikraft.connectContiguousCable(namea,posa,a,nameb,posb,b)
|
|||||||
if (cia2 == nil)
|
if (cia2 == nil)
|
||||||
then
|
then
|
||||||
connsa[cia] = connsa[cia] + math.pow(2,dira)
|
connsa[cia] = connsa[cia] + math.pow(2,dira)
|
||||||
elseif (a ~= cia2)
|
elseif (cia ~= cia2)
|
||||||
then
|
then
|
||||||
-- We take the v size of selected cable
|
-- We take the v size of selected cable
|
||||||
local v = math.fmod(math.floor(connsa[cia]/16),2)
|
local v = math.fmod(math.floor(connsa[cia]/16),2)
|
||||||
@ -417,8 +420,8 @@ function logikraft.connectContiguousCable(namea,posa,a,nameb,posb,b)
|
|||||||
|
|
||||||
if (cib2 == nil)
|
if (cib2 == nil)
|
||||||
then
|
then
|
||||||
connsb[cib] = connsb[cib] + math.pow(2,3-dira)
|
connsb[cib] = connsb[cib] + math.pow(2,math.fmod(dira+2,4))
|
||||||
elseif (b ~= cib2)
|
elseif (cib ~= cib2)
|
||||||
then
|
then
|
||||||
-- We take the v size of selected cable
|
-- We take the v size of selected cable
|
||||||
local v = math.fmod(math.floor(connsb[cib]/16),2)
|
local v = math.fmod(math.floor(connsb[cib]/16),2)
|
||||||
@ -452,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
|
||||||
21
items.lua
21
items.lua
@ -40,8 +40,8 @@ minetest.register_craftitem("logikraft:linker", {
|
|||||||
else
|
else
|
||||||
local thisnb = logikraft.lookingAtNbIndex(user,pointed_thing.under)
|
local thisnb = logikraft.lookingAtNbIndex(user,pointed_thing.under)
|
||||||
local new = logikraft.connectContiguousCable(
|
local new = logikraft.connectContiguousCable(
|
||||||
string.without(node.name,"logikraft:cable_"),selectedpos,selectednb,
|
string.without(minetest.get_node(selectedpos).name,"logikraft:cable_"),selectedpos,selectednb,
|
||||||
string.without(minetest.get_node(pointed_thing.under).name,"logikraft:cable_"),pointed_thing.under,thisnb)
|
string.without(node.name,"logikraft:cable_"),pointed_thing.under,thisnb)
|
||||||
if new
|
if new
|
||||||
then
|
then
|
||||||
minetest.swap_node(selectedpos, {name = "logikraft:cable_" .. new[1]})
|
minetest.swap_node(selectedpos, {name = "logikraft:cable_" .. new[1]})
|
||||||
@ -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