Changed mod name to logikraft
This commit is contained in:
parent
7524c13e7a
commit
55f9fa3367
@ -113,11 +113,11 @@ end
|
|||||||
nbconn: Which correspond each nodebox correspond to
|
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
|
ex: {1,1,2,1} -> nodeboxes 1,2,3 correspond to connection ES, and nodebox 2 correspond to connection W
|
||||||
--]]
|
--]]
|
||||||
circuits.cablesnb = {}
|
logikraft.cablesnb = {}
|
||||||
circuits.cablesconn = {}
|
logikraft.cablesconn = {}
|
||||||
circuits.cablesnbconn = {}
|
logikraft.cablesnbconn = {}
|
||||||
local function createCables(name,nodeboxes,connections,nbconn)
|
local function createCables(name,nodeboxes,connections,nbconn)
|
||||||
minetest.register_node("circuits:cable_"..name, {
|
minetest.register_node("logikraft:cable_"..name, {
|
||||||
tiles = {
|
tiles = {
|
||||||
"cable_gray.png",
|
"cable_gray.png",
|
||||||
"cable_gray.png",
|
"cable_gray.png",
|
||||||
@ -150,9 +150,9 @@ local function createCables(name,nodeboxes,connections,nbconn)
|
|||||||
if name == "EW8_N1_S1"
|
if name == "EW8_N1_S1"
|
||||||
then print(dump(connections2)) end
|
then print(dump(connections2)) end
|
||||||
|
|
||||||
circuits.cablesnb[name] = nodeboxes
|
logikraft.cablesnb[name] = nodeboxes
|
||||||
circuits.cablesconn[name] = connections2
|
logikraft.cablesconn[name] = connections2
|
||||||
circuits.cablesnbconn[name] = nbconn2
|
logikraft.cablesnbconn[name] = nbconn2
|
||||||
end
|
end
|
||||||
|
|
||||||
-- cable_NSEW0
|
-- cable_NSEW0
|
||||||
@ -334,24 +334,24 @@ end
|
|||||||
end
|
end
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
circuits.cablesfromconn = table.invert(circuits.cablesconn)
|
logikraft.cablesfromconn = table.invert(logikraft.cablesconn)
|
||||||
|
|
||||||
|
|
||||||
function circuits.rotateCable(name,r)
|
function logikraft.rotateCable(name,r)
|
||||||
local conn = circuits.cablesconn[name]
|
local conn = logikraft.cablesconn[name]
|
||||||
local newconn = {}
|
local newconn = {}
|
||||||
for i,v in ipairs(conn)
|
for i,v in ipairs(conn)
|
||||||
do
|
do
|
||||||
newconn[i] = rotate4dir(v,r)
|
newconn[i] = rotate4dir(v,r)
|
||||||
end
|
end
|
||||||
table.sort(newconn)
|
table.sort(newconn)
|
||||||
return table.getkey1(circuits.cablesconn,newconn)
|
return table.getkey1(logikraft.cablesconn,newconn)
|
||||||
end
|
end
|
||||||
|
|
||||||
function circuits.connectInCable(name,a,b)
|
function logikraft.connectInCable(name,a,b)
|
||||||
local conns = table.copy(circuits.cablesconn[name])
|
local conns = table.copy(logikraft.cablesconn[name])
|
||||||
local cia = circuits.cablesnbconn[name][a]
|
local cia = logikraft.cablesnbconn[name][a]
|
||||||
local cib = circuits.cablesnbconn[name][b]
|
local cib = logikraft.cablesnbconn[name][b]
|
||||||
local conna = conns[cia]
|
local conna = conns[cia]
|
||||||
local connb = conns[cib]
|
local connb = conns[cib]
|
||||||
|
|
||||||
@ -361,12 +361,12 @@ function circuits.connectInCable(name,a,b)
|
|||||||
table.remove(conns,cib)
|
table.remove(conns,cib)
|
||||||
|
|
||||||
table.sort(conns)
|
table.sort(conns)
|
||||||
return table.getkey1(circuits.cablesconn,conns)
|
return table.getkey1(logikraft.cablesconn,conns)
|
||||||
end
|
end
|
||||||
|
|
||||||
function circuits.disconnectInCable(name,a)
|
function logikraft.disconnectInCable(name,a)
|
||||||
local conns = table.copy(circuits.cablesconn[name])
|
local conns = table.copy(logikraft.cablesconn[name])
|
||||||
local cindex = circuits.cablesnbconn[name][a]
|
local cindex = logikraft.cablesnbconn[name][a]
|
||||||
local conn = conns[cindex]
|
local conn = conns[cindex]
|
||||||
|
|
||||||
table.remove(conns,cindex)
|
table.remove(conns,cindex)
|
||||||
@ -384,5 +384,5 @@ function circuits.disconnectInCable(name,a)
|
|||||||
end
|
end
|
||||||
|
|
||||||
table.sort(conns)
|
table.sort(conns)
|
||||||
return table.getkey1(circuits.cablesconn,conns)
|
return table.getkey1(logikraft.cablesconn,conns)
|
||||||
end
|
end
|
||||||
@ -1,6 +1,6 @@
|
|||||||
local _contexts = {}
|
local _contexts = {}
|
||||||
|
|
||||||
function circuits.setNameFormspec(targetType, defaultName)
|
function logikraft.setNameFormspec(targetType, defaultName)
|
||||||
|
|
||||||
local text = "Please enter the name of this " .. targetType
|
local text = "Please enter the name of this " .. targetType
|
||||||
|
|
||||||
@ -16,12 +16,12 @@ function circuits.setNameFormspec(targetType, defaultName)
|
|||||||
return table.concat(formspec, "")
|
return table.concat(formspec, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function circuits.showSetNameFormspec(playerName, targetName)
|
function logikraft.showSetNameFormspec(playerName, targetName)
|
||||||
minetest.show_formspec(playerName, "circuits:setNameFormSpec", circuits.setNameFormspec(targetName))
|
minetest.show_formspec(playerName, "logikraft:setNameFormSpec", logikraft.setNameFormspec(targetName))
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
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
|
if fields.commit then
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
@ -29,11 +29,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_node("circuits:circuitBlock", {
|
minetest.register_node("logikraft:circuitBlock", {
|
||||||
description = "Circuit Block",
|
description = "Circuit Block",
|
||||||
tiles = {"circuit_block.png"},
|
tiles = {"circuit_block.png"},
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
circuits.discoverBlocks(pos)
|
logikraft.discoverBlocks(pos)
|
||||||
end,
|
end,
|
||||||
groups = {circuitry = 1,dig_immediate = 3}
|
groups = {circuitry = 1,dig_immediate = 3}
|
||||||
})
|
})
|
||||||
@ -42,7 +42,7 @@ local function remove_no_destruct(pos)
|
|||||||
minetest.check_for_falling(pos)
|
minetest.check_for_falling(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("circuits:component_head", {
|
minetest.register_node("logikraft:component_head", {
|
||||||
drawtype = "block",
|
drawtype = "block",
|
||||||
tiles = {"component.png"},
|
tiles = {"component.png"},
|
||||||
groups = {circuitry = 1,dig_immediate = 3},
|
groups = {circuitry = 1,dig_immediate = 3},
|
||||||
@ -85,10 +85,10 @@ minetest.register_node("circuits:component_head", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- If we reached this point, we can build the component
|
-- 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
|
for i = 1,w*h-1 do
|
||||||
local loc = addToPos8dir(dir,pos,i%w,(i-i%w)/w)
|
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
|
end
|
||||||
|
|
||||||
if not minetest.is_creative_enabled(player_name) then
|
if not minetest.is_creative_enabled(player_name) then
|
||||||
@ -104,11 +104,11 @@ minetest.register_node("circuits:component_head", {
|
|||||||
|
|
||||||
dir = node.param2
|
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
|
for i = 1,w*h-1 do
|
||||||
local loc = addToPos8dir(dir,pos,i%w,(i-i%w)/w)
|
local loc = addToPos8dir(dir,pos,i%w,(i-i%w)/w)
|
||||||
local onode = minetest.get_node(loc)
|
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
|
then
|
||||||
remove_no_destruct(loc)
|
remove_no_destruct(loc)
|
||||||
end
|
end
|
||||||
@ -117,7 +117,7 @@ minetest.register_node("circuits:component_head", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("circuits:component_tail", {
|
minetest.register_node("logikraft:component_tail", {
|
||||||
drawtype = "block",
|
drawtype = "block",
|
||||||
paramtype2 = "4dir",
|
paramtype2 = "4dir",
|
||||||
groups = {circuitry = 1},
|
groups = {circuitry = 1},
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
-- }
|
-- }
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
function circuits.computeCircuit(circuit, input)
|
function logikraft.computeCircuit(circuit, input)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ local function has_value (tab, len, val)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function circuits.discoverBlocks(pos)
|
function logikraft.discoverBlocks(pos)
|
||||||
local i = 2
|
local i = 2
|
||||||
local j = 1
|
local j = 1
|
||||||
local poz = {}
|
local poz = {}
|
||||||
|
|||||||
22
init.lua
22
init.lua
@ -1,23 +1,23 @@
|
|||||||
|
|
||||||
circuits = {}
|
logikraft = {}
|
||||||
|
|
||||||
dofile(minetest.get_modpath("circuits") .. "/utils.lua")
|
dofile(minetest.get_modpath("logikraft") .. "/utils.lua")
|
||||||
dofile(minetest.get_modpath("circuits") .. "/circuits.lua")
|
dofile(minetest.get_modpath("logikraft") .. "/circuits.lua")
|
||||||
dofile(minetest.get_modpath("circuits") .. "/blocks/circuit.lua")
|
dofile(minetest.get_modpath("logikraft") .. "/blocks/circuit.lua")
|
||||||
dofile(minetest.get_modpath("circuits") .. "/blocks/component.lua")
|
dofile(minetest.get_modpath("logikraft") .. "/blocks/component.lua")
|
||||||
dofile(minetest.get_modpath("circuits") .. "/blocks/cable.lua")
|
dofile(minetest.get_modpath("logikraft") .. "/blocks/cable.lua")
|
||||||
dofile(minetest.get_modpath("circuits") .. "/items.lua")
|
dofile(minetest.get_modpath("logikraft") .. "/items.lua")
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
player:hud_set_hotbar_itemcount(24)
|
player:hud_set_hotbar_itemcount(24)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_node("circuits:inputBlock", {
|
minetest.register_node("logikraft:inputBlock", {
|
||||||
description = "Input Block",
|
description = "Input Block",
|
||||||
tiles = {"input_block.png"},
|
tiles = {"input_block.png"},
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
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,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, player)
|
on_receive_fields = function(pos, formname, fields, player)
|
||||||
if fields.quit then
|
if fields.quit then
|
||||||
@ -27,12 +27,12 @@ minetest.register_node("circuits:inputBlock", {
|
|||||||
end,
|
end,
|
||||||
groups = {circuitry = 1,dig_immediate = 3}
|
groups = {circuitry = 1,dig_immediate = 3}
|
||||||
})
|
})
|
||||||
minetest.register_node("circuits:outputBlock", {
|
minetest.register_node("logikraft:outputBlock", {
|
||||||
description = "Output Block",
|
description = "Output Block",
|
||||||
tiles = {"output_block.png"},
|
tiles = {"output_block.png"},
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
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,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, player)
|
on_receive_fields = function(pos, formname, fields, player)
|
||||||
if fields.quit then
|
if fields.quit then
|
||||||
|
|||||||
36
items.lua
36
items.lua
@ -1,59 +1,59 @@
|
|||||||
minetest.register_craftitem("circuits:rotator", {
|
minetest.register_craftitem("logikraft:rotator", {
|
||||||
description = "The rotator",
|
description = "The rotator",
|
||||||
inventory_image = "rotator.png",
|
inventory_image = "rotator.png",
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
on_place = function(itemstack, user, pointed_thing)
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
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
|
then return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local new = circuits.rotateCable(string.without(node.name,"circuits:cable_"),1)
|
local new = logikraft.rotateCable(string.without(node.name,"logikraft:cable_"),1)
|
||||||
minetest.swap_node(pointed_thing.under, {name = "circuits:cable_" .. new})
|
minetest.swap_node(pointed_thing.under, {name = "logikraft:cable_" .. new})
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
minetest.register_craftitem("circuits:linker", {
|
minetest.register_craftitem("logikraft:linker", {
|
||||||
description = "The linker",
|
description = "The linker",
|
||||||
inventory_image = "linker.png",
|
inventory_image = "linker.png",
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
on_place = function(itemstack, user, pointed_thing)
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
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
|
then return itemstack
|
||||||
end
|
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
|
-- We check if we clicked the last selected node
|
||||||
local meta = minetest.get_meta(pointed_thing.under)
|
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
|
then
|
||||||
-- We connect
|
-- We connect
|
||||||
local firsti = meta:get_int("circuits:last_selected_nb")
|
local firsti = meta:get_int("logikraft:last_selected_nb")
|
||||||
local new = circuits.connectInCable(string.without(node.name,"circuits:cable_"),firsti,index)
|
local new = logikraft.connectInCable(string.without(node.name,"logikraft:cable_"),firsti,index)
|
||||||
minetest.swap_node(pointed_thing.under, {name = "circuits:cable_" .. new})
|
minetest.swap_node(pointed_thing.under, {name = "logikraft:cable_" .. new})
|
||||||
|
|
||||||
-- We destroy the saved selected nb
|
-- We destroy the saved selected nb
|
||||||
meta:set_int("circuits:last_selected_nb",0)
|
meta:set_int("logikraft:last_selected_nb",0)
|
||||||
else
|
else
|
||||||
-- We save the selected nb
|
-- We save the selected nb
|
||||||
meta:set_int("circuits:last_selected_nb",index)
|
meta:set_int("logikraft:last_selected_nb",index)
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
minetest.register_craftitem("circuits:unlinker", {
|
minetest.register_craftitem("logikraft:unlinker", {
|
||||||
description = "The unlinker",
|
description = "The unlinker",
|
||||||
inventory_image = "unlinker.png",
|
inventory_image = "unlinker.png",
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
on_place = function(itemstack, user, pointed_thing)
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
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
|
then return itemstack
|
||||||
end
|
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)
|
local new = logikraft.disconnectInCable(string.without(node.name,"logikraft:cable_"),index)
|
||||||
minetest.swap_node(pointed_thing.under, {name = "circuits:cable_" .. new})
|
minetest.swap_node(pointed_thing.under, {name = "logikraft:cable_" .. new})
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|||||||
@ -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[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)
|
(((nb[3] < p[3]) and (p[3] - nb[3])) or ((p[3] < nb[6]) and (nb[6] - p[3])) or 0)
|
||||||
end
|
end
|
||||||
function circuits.nearestNodeboxIndex(nodeboxes,point)
|
function logikraft.nearestNodeboxIndex(nodeboxes,point)
|
||||||
local minindex=-1
|
local minindex=-1
|
||||||
local minvalue = 9999
|
local minvalue = 9999
|
||||||
for i,nb in ipairs(nodeboxes)
|
for i,nb in ipairs(nodeboxes)
|
||||||
@ -67,7 +67,7 @@ function circuits.nearestNodeboxIndex(nodeboxes,point)
|
|||||||
return minindex
|
return minindex
|
||||||
end
|
end
|
||||||
|
|
||||||
function circuits.lookingAtNbIndex(user,under)
|
function logikraft.lookingAtNbIndex(user,under)
|
||||||
local range=5
|
local range=5
|
||||||
local eye = vector.add(user:get_pos(),{x=0,y=1.625,z=0})
|
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))
|
local objective = vector.add(eye, vector.multiply(user:get_look_dir(),range))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user