Added more components
This commit is contained in:
@@ -29,7 +29,7 @@ function logikraft.registerComponent(name,cmp)
|
||||
((y==h) and (cables.top and cables.top[x] and "component_port.png" or "component.png") or "component.png"), -- z+
|
||||
((y==1) and (cables.bottom and cables.bottom[x] and "component_port.png" or "component.png") or "component.png"), -- z-
|
||||
},
|
||||
groups = {circuitry = 1,dig_immediate = 3},
|
||||
groups = {circuitry = 1,dig_immediate = 3, not_in_creative_inventory = (x==1 and y==1 and 0) or 1},
|
||||
paramtype2 = "4dir",
|
||||
inventory_image = (x == 1 and y == 1 and "component_"..name..".png") or nil,
|
||||
drop = "logikraft:component_"..name.."_1_1",
|
||||
|
||||
@@ -16,6 +16,81 @@ logikraft.components = {
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = (inz["in_1"] * inz["in_2"] == 0) and 0 or 1} end
|
||||
},
|
||||
["nand"] = {
|
||||
width = 2,
|
||||
height = 3,
|
||||
ports = {
|
||||
left = {"in_2",nil,"in_1"},
|
||||
right = {nil,"out",nil}
|
||||
},
|
||||
inputs = {"in_1","in_2"},
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = (inz["in_1"] * inz["in_2"] == 0) and 1 or 0} end
|
||||
},
|
||||
["or"] = {
|
||||
width = 2,
|
||||
height = 3,
|
||||
ports = {
|
||||
left = {"in_2",nil,"in_1"},
|
||||
right = {nil,"out",nil}
|
||||
},
|
||||
inputs = {"in_1","in_2"},
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = (inz["in_1"] + inz["in_2"] == 0) and 0 or 1} end
|
||||
},
|
||||
["nor"] = {
|
||||
width = 2,
|
||||
height = 3,
|
||||
ports = {
|
||||
left = {"in_2",nil,"in_1"},
|
||||
right = {nil,"out",nil}
|
||||
},
|
||||
inputs = {"in_1","in_2"},
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = (inz["in_1"] + inz["in_2"] == 0) and 1 or 0} end
|
||||
},
|
||||
["xor"] = {
|
||||
width = 2,
|
||||
height = 3,
|
||||
ports = {
|
||||
left = {"in_2",nil,"in_1"},
|
||||
right = {nil,"out",nil}
|
||||
},
|
||||
inputs = {"in_1","in_2"},
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = (inz["in_1"] + inz["in_2"] == 1) and 1 or 0} end
|
||||
},
|
||||
["not"] = {
|
||||
width = 2,
|
||||
height = 1,
|
||||
ports = {
|
||||
left = {"in"},
|
||||
right = {"out"}
|
||||
},
|
||||
inputs = {"in"},
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = 1 - inz["in"]} end
|
||||
},
|
||||
["on"] = {
|
||||
width = 1,
|
||||
height = 1,
|
||||
ports = {
|
||||
right = {"out"}
|
||||
},
|
||||
inputs = {},
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = 1} end
|
||||
},
|
||||
["off"] = {
|
||||
width = 1,
|
||||
height = 1,
|
||||
ports = {
|
||||
right = {"out"}
|
||||
},
|
||||
inputs = {},
|
||||
outputs = {"out"},
|
||||
compute = function(inz) return {out = 0} end
|
||||
},
|
||||
["switch"] = {
|
||||
width = 2,
|
||||
height = 1,
|
||||
@@ -36,7 +111,17 @@ logikraft.components = {
|
||||
right = {"out_8","out_7","out_6","out_5","out_4","out_3","out_2","out_1"}
|
||||
},
|
||||
inputs = {"in_1","in_2","in_3"},
|
||||
outputs = {"out_8","out_7","out_6","out_5","out_4","out_3","out_2","out_1"}
|
||||
outputs = {"out_8","out_7","out_6","out_5","out_4","out_3","out_2","out_1"},
|
||||
compute = function(inz) return {
|
||||
out_1 = (inz.in_1 == 0) and (inz.in_2 == 0) and (inz.in_3 == 0) and 1 or 0,
|
||||
out_2 = (inz.in_1 == 1) and (inz.in_2 == 0) and (inz.in_3 == 0) and 1 or 0,
|
||||
out_3 = (inz.in_1 == 0) and (inz.in_2 == 1) and (inz.in_3 == 0) and 1 or 0,
|
||||
out_4 = (inz.in_1 == 1) and (inz.in_2 == 1) and (inz.in_3 == 0) and 1 or 0,
|
||||
out_5 = (inz.in_1 == 0) and (inz.in_2 == 0) and (inz.in_3 == 1) and 1 or 0,
|
||||
out_6 = (inz.in_1 == 1) and (inz.in_2 == 0) and (inz.in_3 == 1) and 1 or 0,
|
||||
out_7 = (inz.in_1 == 0) and (inz.in_2 == 1) and (inz.in_3 == 1) and 1 or 0,
|
||||
out_8 = (inz.in_1 == 1) and (inz.in_2 == 1) and (inz.in_3 == 1) and 1 or 0,
|
||||
} end
|
||||
},
|
||||
["input"] = {
|
||||
width = 1,
|
||||
|
||||
Reference in New Issue
Block a user