From 7d9d2a2d784b5a2a637638165bd6ef4b5df32480 Mon Sep 17 00:00:00 2001 From: prescientmoon Date: Wed, 27 Nov 2024 08:56:36 +0100 Subject: [PATCH] Make comparators only output one bit-wide signals --- src/modules/saving/templates/comparator.ts | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/modules/saving/templates/comparator.ts b/src/modules/saving/templates/comparator.ts index 3c9f3c4..1d226a0 100644 --- a/src/modules/saving/templates/comparator.ts +++ b/src/modules/saving/templates/comparator.ts @@ -5,36 +5,36 @@ import { categories } from '../data/categories' * The template of the comparator gate */ const comparatorTemplate: PartialTemplate = { - metadata: { - name: 'comparator' - }, - info: ['https://www.technobyte.org/comparator/'], - category: categories.math, - code: { - activation: ` - const a = context.getBinary(0) - const b = context.getBinary(1) + metadata: { + name: 'comparator' + }, + info: ['https://www.technobyte.org/comparator/'], + category: categories.math, + code: { + activation: ` + const a = context.getBinary(0) + const b = context.getBinary(1) - context.setBinary(0, Number(a > b)) - context.setBinary(1, Number(a === b)) - context.setBinary(2, Number(a < b)) - ` + context.setBinary(0, Number(a > b), 1) + context.setBinary(1, Number(a === b), 1) + context.setBinary(2, Number(a < b), 1) + ` + }, + pins: { + inputs: { + count: 2 }, - pins: { - inputs: { - count: 2 - }, - outputs: { - count: 3 - } - }, - material: { - type: 'image', - fill: require('../../../assets/comparator.svg') - }, - shape: { - scale: [125, 125] + outputs: { + count: 3 } + }, + material: { + type: 'image', + fill: require('../../../assets/comparator.svg') + }, + shape: { + scale: [125, 125] + } } export default comparatorTemplate