Changed mod name to logikraft

This commit is contained in:
Samy Avrillon 2024-05-16 00:43:01 +02:00
parent 7524c13e7a
commit 55f9fa3367
No known key found for this signature in database
GPG Key ID: 3E163E7603E330FE
7 changed files with 65 additions and 65 deletions

View File

@ -113,11 +113,11 @@ end
nbconn: Which correspond each nodebox correspond to
ex: {1,1,2,1} -> nodeboxes 1,2,3 correspond to connection ES, and nodebox 2 correspond to connection W
--]]
circuits.cablesnb = {}
circuits.cablesconn = {}
circuits.cablesnbconn = {}
logikraft.cablesnb = {}
logikraft.cablesconn = {}
logikraft.cablesnbconn = {}
local function createCables(name,nodeboxes,connections,nbconn)
minetest.register_node("circuits:cable_"..name, {
minetest.register_node("logikraft:cable_"..name, {
tiles = {
"cable_gray.png",
"cable_gray.png",
@ -150,9 +150,9 @@ local function createCables(name,nodeboxes,connections,nbconn)
if name == "EW8_N1_S1"
then print(dump(connections2)) end
circuits.cablesnb[name] = nodeboxes
circuits.cablesconn[name] = connections2
circuits.cablesnbconn[name] = nbconn2
logikraft.cablesnb[name] = nodeboxes
logikraft.cablesconn[name] = connections2
logikraft.cablesnbconn[name] = nbconn2
end
-- cable_NSEW0
@ -334,24 +334,24 @@ end
end
--]]
circuits.cablesfromconn = table.invert(circuits.cablesconn)
logikraft.cablesfromconn = table.invert(logikraft.cablesconn)
function circuits.rotateCable(name,r)
local conn = circuits.cablesconn[name]
function logikraft.rotateCable(name,r)
local conn = logikraft.cablesconn[name]
local newconn = {}
for i,v in ipairs(conn)
do
newconn[i] = rotate4dir(v,r)
end
table.sort(newconn)
return table.getkey1(circuits.cablesconn,newconn)
return table.getkey1(logikraft.cablesconn,newconn)
end
function circuits.connectInCable(name,a,b)
local conns = table.copy(circuits.cablesconn[name])
local cia = circuits.cablesnbconn[name][a]
local cib = circuits.cablesnbconn[name][b]
function logikraft.connectInCable(name,a,b)
local conns = table.copy(logikraft.cablesconn[name])
local cia = logikraft.cablesnbconn[name][a]
local cib = logikraft.cablesnbconn[name][b]
local conna = conns[cia]
local connb = conns[cib]
@ -361,12 +361,12 @@ function circuits.connectInCable(name,a,b)
table.remove(conns,cib)
table.sort(conns)
return table.getkey1(circuits.cablesconn,conns)
return table.getkey1(logikraft.cablesconn,conns)
end
function circuits.disconnectInCable(name,a)
local conns = table.copy(circuits.cablesconn[name])
local cindex = circuits.cablesnbconn[name][a]
function logikraft.disconnectInCable(name,a)
local conns = table.copy(logikraft.cablesconn[name])
local cindex = logikraft.cablesnbconn[name][a]
local conn = conns[cindex]
table.remove(conns,cindex)
@ -384,5 +384,5 @@ function circuits.disconnectInCable(name,a)
end
table.sort(conns)
return table.getkey1(circuits.cablesconn,conns)
return table.getkey1(logikraft.cablesconn,conns)
end

View File

@ -1,6 +1,6 @@
local _contexts = {}
function circuits.setNameFormspec(targetType, defaultName)
function logikraft.setNameFormspec(targetType, defaultName)
local text = "Please enter the name of this " .. targetType
@ -16,12 +16,12 @@ function circuits.setNameFormspec(targetType, defaultName)
return table.concat(formspec, "")
end
function circuits.showSetNameFormspec(playerName, targetName)
minetest.show_formspec(playerName, "circuits:setNameFormSpec", circuits.setNameFormspec(targetName))
function logikraft.showSetNameFormspec(playerName, targetName)
minetest.show_formspec(playerName, "logikraft:setNameFormSpec", logikraft.setNameFormspec(targetName))
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "circuits:setNameFormSpec" then return end
if formname ~= "logikraft:setNameFormSpec" then return end
if fields.commit then
local pname = player:get_player_name()
@ -29,11 +29,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end)
minetest.register_node("circuits:circuitBlock", {
minetest.register_node("logikraft:circuitBlock", {
description = "Circuit Block",
tiles = {"circuit_block.png"},
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
circuits.discoverBlocks(pos)
logikraft.discoverBlocks(pos)
end,
groups = {circuitry = 1,dig_immediate = 3}
})

View File

@ -42,7 +42,7 @@ local function remove_no_destruct(pos)
minetest.check_for_falling(pos)
end
minetest.register_node("circuits:component_head", {
minetest.register_node("logikraft:component_head", {
drawtype = "block",
tiles = {"component.png"},
groups = {circuitry = 1,dig_immediate = 3},
@ -85,10 +85,10 @@ minetest.register_node("circuits:component_head", {
end
end
-- If we reached this point, we can build the component
minetest.set_node(pos, {name = "circuits:component_head", param2 = dir})
minetest.set_node(pos, {name = "logikraft:component_head", param2 = dir})
for i = 1,w*h-1 do
local loc = addToPos8dir(dir,pos,i%w,(i-i%w)/w)
minetest.set_node(loc, {name = "circuits:component_tail", param2 = dir})
minetest.set_node(loc, {name = "logikraft:component_tail", param2 = dir})
end
if not minetest.is_creative_enabled(player_name) then
@ -104,11 +104,11 @@ minetest.register_node("circuits:component_head", {
dir = node.param2
remove_no_destruct(pos) -- Should be circuits:component_head
remove_no_destruct(pos) -- Should be logikraft:component_head
for i = 1,w*h-1 do
local loc = addToPos8dir(dir,pos,i%w,(i-i%w)/w)
local onode = minetest.get_node(loc)
if onode.name == "circuits:component_tail" and onode.param2 == dir
if onode.name == "logikraft:component_tail" and onode.param2 == dir
then
remove_no_destruct(loc)
end
@ -117,7 +117,7 @@ minetest.register_node("circuits:component_head", {
end
})
minetest.register_node("circuits:component_tail", {
minetest.register_node("logikraft:component_tail", {
drawtype = "block",
paramtype2 = "4dir",
groups = {circuitry = 1},

View File

@ -8,7 +8,7 @@
-- }
-- }
function circuits.computeCircuit(circuit, input)
function logikraft.computeCircuit(circuit, input)
end
@ -22,7 +22,7 @@ local function has_value (tab, len, val)
return false
end
function circuits.discoverBlocks(pos)
function logikraft.discoverBlocks(pos)
local i = 2
local j = 1
local poz = {}

View File

@ -1,23 +1,23 @@
circuits = {}
logikraft = {}
dofile(minetest.get_modpath("circuits") .. "/utils.lua")
dofile(minetest.get_modpath("circuits") .. "/circuits.lua")
dofile(minetest.get_modpath("circuits") .. "/blocks/circuit.lua")
dofile(minetest.get_modpath("circuits") .. "/blocks/component.lua")
dofile(minetest.get_modpath("circuits") .. "/blocks/cable.lua")
dofile(minetest.get_modpath("circuits") .. "/items.lua")
dofile(minetest.get_modpath("logikraft") .. "/utils.lua")
dofile(minetest.get_modpath("logikraft") .. "/circuits.lua")
dofile(minetest.get_modpath("logikraft") .. "/blocks/circuit.lua")
dofile(minetest.get_modpath("logikraft") .. "/blocks/component.lua")
dofile(minetest.get_modpath("logikraft") .. "/blocks/cable.lua")
dofile(minetest.get_modpath("logikraft") .. "/items.lua")
minetest.register_on_joinplayer(function(player)
player:hud_set_hotbar_itemcount(24)
end)
minetest.register_node("circuits:inputBlock", {
minetest.register_node("logikraft:inputBlock", {
description = "Input Block",
tiles = {"input_block.png"},
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",circuits.setNameFormspec("Input Block"),meta:get_string("name"))
meta:set_string("formspec",logikraft.setNameFormspec("Input Block"),meta:get_string("name"))
end,
on_receive_fields = function(pos, formname, fields, player)
if fields.quit then
@ -27,12 +27,12 @@ minetest.register_node("circuits:inputBlock", {
end,
groups = {circuitry = 1,dig_immediate = 3}
})
minetest.register_node("circuits:outputBlock", {
minetest.register_node("logikraft:outputBlock", {
description = "Output Block",
tiles = {"output_block.png"},
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",circuits.setNameFormspec("Output Block"),meta:get_string("name"))
meta:set_string("formspec",logikraft.setNameFormspec("Output Block"),meta:get_string("name"))
end,
on_receive_fields = function(pos, formname, fields, player)
if fields.quit then

View File

@ -1,59 +1,59 @@
minetest.register_craftitem("circuits:rotator", {
minetest.register_craftitem("logikraft:rotator", {
description = "The rotator",
inventory_image = "rotator.png",
on_place = function(itemstack, user, pointed_thing)
local node = minetest.get_node(pointed_thing.under)
if not string.startsWith(node.name,"circuits:cable_")
if not string.startsWith(node.name,"logikraft:cable_")
then return itemstack
end
local new = circuits.rotateCable(string.without(node.name,"circuits:cable_"),1)
minetest.swap_node(pointed_thing.under, {name = "circuits:cable_" .. new})
local new = logikraft.rotateCable(string.without(node.name,"logikraft:cable_"),1)
minetest.swap_node(pointed_thing.under, {name = "logikraft:cable_" .. new})
return itemstack
end
})
minetest.register_craftitem("circuits:linker", {
minetest.register_craftitem("logikraft:linker", {
description = "The linker",
inventory_image = "linker.png",
on_place = function(itemstack, user, pointed_thing)
local node = minetest.get_node(pointed_thing.under)
if not string.startsWith(node.name,"circuits:cable_")
if not string.startsWith(node.name,"logikraft:cable_")
then return itemstack
end
local index = circuits.lookingAtNbIndex(user,pointed_thing.under)
local index = logikraft.lookingAtNbIndex(user,pointed_thing.under)
-- We check if we clicked the last selected node
local meta = minetest.get_meta(pointed_thing.under)
if meta:get_int("circuits:last_selected_nb") ~= 0
if meta:get_int("logikraft:last_selected_nb") ~= 0
then
-- We connect
local firsti = meta:get_int("circuits:last_selected_nb")
local new = circuits.connectInCable(string.without(node.name,"circuits:cable_"),firsti,index)
minetest.swap_node(pointed_thing.under, {name = "circuits:cable_" .. new})
local firsti = meta:get_int("logikraft:last_selected_nb")
local new = logikraft.connectInCable(string.without(node.name,"logikraft:cable_"),firsti,index)
minetest.swap_node(pointed_thing.under, {name = "logikraft:cable_" .. new})
-- We destroy the saved selected nb
meta:set_int("circuits:last_selected_nb",0)
meta:set_int("logikraft:last_selected_nb",0)
else
-- We save the selected nb
meta:set_int("circuits:last_selected_nb",index)
meta:set_int("logikraft:last_selected_nb",index)
end
return itemstack
end
})
minetest.register_craftitem("circuits:unlinker", {
minetest.register_craftitem("logikraft:unlinker", {
description = "The unlinker",
inventory_image = "unlinker.png",
on_place = function(itemstack, user, pointed_thing)
local node = minetest.get_node(pointed_thing.under)
if not string.startsWith(node.name,"circuits:cable_")
if not string.startsWith(node.name,"logikraft:cable_")
then return itemstack
end
local index = circuits.lookingAtNbIndex(user,pointed_thing.under)
local index = logikraft.lookingAtNbIndex(user,pointed_thing.under)
local new = circuits.disconnectInCable(string.without(node.name,"circuits:cable_"),index)
minetest.swap_node(pointed_thing.under, {name = "circuits:cable_" .. new})
local new = logikraft.disconnectInCable(string.without(node.name,"logikraft:cable_"),index)
minetest.swap_node(pointed_thing.under, {name = "logikraft:cable_" .. new})
return itemstack
end

View File

@ -52,7 +52,7 @@ local function nodeboxDistance(nb,p)
(((nb[2] < p[2]) and (p[2] - nb[2])) or ((p[2] < nb[5]) and (nb[5] - p[2])) or 0) +
(((nb[3] < p[3]) and (p[3] - nb[3])) or ((p[3] < nb[6]) and (nb[6] - p[3])) or 0)
end
function circuits.nearestNodeboxIndex(nodeboxes,point)
function logikraft.nearestNodeboxIndex(nodeboxes,point)
local minindex=-1
local minvalue = 9999
for i,nb in ipairs(nodeboxes)
@ -67,7 +67,7 @@ function circuits.nearestNodeboxIndex(nodeboxes,point)
return minindex
end
function circuits.lookingAtNbIndex(user,under)
function logikraft.lookingAtNbIndex(user,under)
local range=5
local eye = vector.add(user:get_pos(),{x=0,y=1.625,z=0})
local objective = vector.add(eye, vector.multiply(user:get_look_dir(),range))