Last active
August 10, 2016 07:24
-
-
Save justarandomgeek/24e357347e71fe1a56e0782290007155 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do local script=true | |
--[[The line above allows Foreman to recognize this as a script.]] | |
--[[ upper and lower row strings ]] | |
local strings = { | |
"O P Q R S T U V W X Y ", | |
"Z 0 1 2 3 4 5 6 7 8 9 ", | |
} | |
--[[ SignGen Code begins here ]] | |
local chars={ | |
["0"]='signal-0',["1"]='signal-1',["2"]='signal-2',["3"]='signal-3',["4"]='signal-4', | |
["5"]='signal-5',["6"]='signal-6',["7"]='signal-7',["8"]='signal-8',["9"]='signal-9', | |
["A"]='signal-A',["B"]='signal-B',["C"]='signal-C',["D"]='signal-D',["E"]='signal-E', | |
["F"]='signal-F',["G"]='signal-G',["H"]='signal-H',["I"]='signal-I',["J"]='signal-J', | |
["K"]='signal-K',["L"]='signal-L',["M"]='signal-M',["N"]='signal-N',["O"]='signal-O', | |
["P"]='signal-P',["Q"]='signal-Q',["R"]='signal-R',["S"]='signal-S',["T"]='signal-T', | |
["U"]='signal-U',["V"]='signal-V',["W"]='signal-W',["X"]='signal-X',["Y"]='signal-Y', | |
["Z"]='signal-Z',[" "]='signal-blue', | |
} | |
function mapChar(s,i) | |
if not s then return chars[' '] end | |
local c = s:sub(i,i) | |
if c and chars[c] then | |
return chars[c] | |
else | |
return chars[' '] | |
end | |
end | |
local count = 1 | |
--[[ CC() Creates a constant combinator with the given data ]] | |
function CC(position, s1, s2) | |
local cc = { | |
entity_number = count, | |
control_behavior={filters={ | |
{index=1, count=1, signal={name = mapChar(s1,1), type = 'virtual'}}, | |
{index=2, count=1, signal={name = mapChar(s1,2), type = 'virtual'}}, | |
{index=3, count=1, signal={name = mapChar(s2,1), type = 'virtual'}}, | |
{index=4, count=1, signal={name = mapChar(s2,2), type = 'virtual'}}, | |
}}, | |
name = "constant-combinator", | |
direction=2, | |
position = position | |
} | |
count = count+1 | |
return cc | |
end | |
function prefix(s) | |
if not s then | |
return nil,nil | |
elseif #s<=2 then | |
return s,nil | |
else | |
return s:sub(1,2), s:sub(3) | |
end | |
end | |
local xpos=0 | |
local s1,s2 | |
local entities={} | |
local name=strings[1] .. "|" .. strings[2] | |
repeat | |
s1,strings[1] = prefix(strings[1]) | |
s2,strings[2] = prefix(strings[2]) | |
table.insert(entities, CC({x = xpos+1,y = 0}, s1, s2)) | |
xpos = xpos + 1 | |
until(not strings[1] and not strings[2]) | |
--[[ Assemble and return blueprint ]] | |
local blueprintData = { | |
entities = entities, | |
icons={ | |
{index=1, signal={type="item",name="constant-combinator"}} | |
}, | |
name = name, | |
} | |
return blueprintData | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment