Compare commits

..

No commits in common. "3ea8517ff9d18ee6b09f44113cd51bad647d76d0" and "3d9944921f5af34290e0598acfb9567d760886db" have entirely different histories.

3 changed files with 7 additions and 37 deletions

View File

@ -367,8 +367,7 @@ 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 then return i
return i
end end
end end
return nil return nil
@ -391,12 +390,10 @@ 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,math.fmod(dira+2,4)) local cib2 = logikraft.connFromDir(nameb,3 - dira)
print(dira) print(dira)
print(cia) print(cia)
print(cia2) print(cia2)
@ -410,7 +407,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 (cia ~= cia2) elseif (a ~= 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)
@ -420,8 +417,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,math.fmod(dira+2,4)) connsb[cib] = connsb[cib] + math.pow(2,3-dira)
elseif (cib ~= cib2) elseif (b ~= 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)
@ -455,16 +452,6 @@ 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

@ -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(minetest.get_node(selectedpos).name,"logikraft:cable_"),selectedpos,selectednb, string.without(node.name,"logikraft:cable_"),selectedpos,selectednb,
string.without(node.name,"logikraft:cable_"),pointed_thing.under,thisnb) string.without(minetest.get_node(pointed_thing.under).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,23 +109,6 @@ 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
}) })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB