Skip to content

Instantly share code, notes, and snippets.

@demipixel
Created June 25, 2016 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demipixel/4417b836976a121ab15cb8218ddb0ca7 to your computer and use it in GitHub Desktop.
Save demipixel/4417b836976a121ab15cb8218ddb0ca7 to your computer and use it in GitHub Desktop.
60x60 Factorio Screen made of lamps
const Blueprint = require('factorio-blueprint');
const inputs = Object.keys(Blueprint.getEntityData()).filter(key => !Blueprint.getEntityData()[key].combinator).slice(0, 60);
const carries = Object.keys(Blueprint.getEntityData()).filter(key => !Blueprint.getEntityData()[key].combinator).slice(60, 90);
const bp = new Blueprint();
for (let i = 0; i < 2; i++) {
const start = i == 0 ? 0 : 59;
const dir = i == 0 ? 1 : -1;
let prevCombinator = null;
let prevConstant = null;
for (let y = 0; y < 60; y++) {
const combinatorX = start - (y % 2 == 0 ? 3 : 4)*dir
let prev = null;
let first = null;
for (let x = 0; x < 30; x++) {
const Y = y;
const X = start + dir*x;
if (X >= 15 && Y >= 15 && (X - 15) % 28 < 2 && (Y - 15) % 28 < 2) continue;
const ent = bp.createEntity('small_lamp', { x: X, y: Y })
.setCondition({
left: carries[x],
operator: '<',
right: 0
});
if (prev) ent.connect(prev, null, null, 'red');
else first = ent;
prev = ent;
}
const combinatorEnt = bp.createEntity('arithmetic-combinator', { x: combinatorX+0.5, y: y })
.setCondition({
left: 'signal_each',
operator: '*',
right: inputs[y],
out: 'signal_each'
})
.connect(first, 'out', null, 'red');
if (prevCombinator) combinatorEnt.connect(prevCombinator, 'in', 'in', 'red');
prevCombinator = combinatorEnt;
if (y >= 58) {
const constantEnt = bp.createEntity('constant_combinator', { x: start - 6*dir, y: y })
for (let j = 0; j < 15; j++) {
let index = j+(y-58)*15;
constantEnt.setFilter(j+1, carries[index], Math.abs(2 << (index+1)));
}
if (y == 59)
constantEnt.connect(prevConstant, null, null, 'red')
.connect(prevCombinator, null, 'in', 'red');
else
prevConstant = constantEnt;
}
}
}
bp.center();
//console.log(bp.luaString());
console.log(bp.encode());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment