Pages

Tags

.hack// series (14) .hack//Infection (6) .hack//mutation (6) .hack//outbreak (7) .hack//quarantine (5) 1bitHeart (4) A Bird Story (1) A Mortician's Tale (1) Ability Up (11) About Love Hate and the Other Ones (1) Achievements (4) Ahriman's Prophecy (1) Aladdin (1) Alice Elliot (6) Alicemare (1) Alphadia Genesis (5) Amnesia: Memories (1) An Octave Higher (2) Analogue: A Hate Story (1) Anodyne (4) Artefact (2) Artefact Adventure (1) Aveyond (2) BAD END (2) Bad Service (1) Before I Forget (1) Best Armour (16) Best Weapons (26) Bestiary (1) Beyd (1) Bioshock Infinite (1) Black Home (1) Blitzball (1) Blush Blush (1) Boss Fight (1) Boyfriend Dungeon (1) Boyfriend Maker/Boyfriend Plus (1) Braid (8) Breath of Fire (24) Breath of Fire II (18) Breath of Fire III (37) Breath of Fire IV (25) Breath of Fire Series (10) Breath of Fire: Dragon Quarter (4) Brothers (1) Casper (1) Cave Story (1) Celestian Tales: Old North (2) Cheat Engine (1) Cheats (1) Cinderella Phenomenon (3) Circuit Logic (1) Coffee Talk (1) Collectibles (11) competition (1) Completion Project (21) Confines of the Crown (1) Cozy Grove (1) crafts (1) Crash Bandicoot 2 (2) Croc: Legend of the Gobbos (2) Crush Crush (1) Crystal Story (2) Crystalline (1) Cubicle Quest (1) Dark Parables (5) Death Stranding (1) Deis (2) Deponia (1) Dèsirè (2) Dice (1) Discworld (1) Disgaea (1) Dreamworld (1) eBay (1) Ehrgeiz (3) Epic Battle Fantasy III (1) Equipment (3) eReader (1) Eternal Senia (1) Factorio (1) Fairy Village (1) Fanfiction (8) Final Fantasy (4) Final Fantasy II (2) Final Fantasy IV (3) Final Fantasy IX (7) Final Fantasy Series (5) Final Fantasy Tactics (1) Final Fantasy V (1) Final Fantasy VII (7) Final Fantasy VIII (10) Final Fantasy X (7) Final Fantasy X-2 (4) Final Fantasy: Crystal Chronicles (3) Fishing (11) Forget Me Not My Organic Garden (1) Freeware (8) Frontierville (1) Future Learn (1) Game (1) Game-Design (1) Ghost on the Shore (1) Ghost Trick (1) Giving Up (1) God Only Knows (1) Gone Home (1) Grunty (1) Guide (96) GymPact (1) Habitica (3) HabitRPG (3) Harry Potter and the Philosopher's Stone (1) Hellblade: Senua's Sacrifice (1) Hex Manipulation (1) Hitman GO (1) Horizon Zero Dawn (2) HuniePop (1) I Love You Colonel Sanders! (1) Idle Evolution (2) Imposter Factory (1) incentive (4) Incomplete (7) Interpretation (11) iOS (1) IRL (4) Jewish Screenshots (1) Justice for All (1) Kingdom Come: Deliverance (1) Kobo (2) Kongregate (1) Koudelka (2) Labyrinthine Dreams (1) Lake of Voices (1) Later Alligator (3) Legacy Challenge (53) Level Grinding (3) Liar (1) Little Goody Two Shoes (1) Littlewood (1) Long Live the Queen (2) Lord of Twilight (1) Lost Phone Series (1) Manillo (2) Marie's Room (1) Masters (9) Memento (1) Minami Lane (1) Mini-Game (5) missed messages (1) Mobile (1) Monster Camp (1) Monster Magic (3) Monster Prom (4) Murder by Numbers (1) My Time at Portia (1) Nina Wyndia (2) Nintendo DS (1) No Case Should Remain Unsolved (1) non-gaming (3) Notes (20) Octopath Traveler (2) Official Guides (1) Online Courses (1) Pacman World (1) Pact (1) Paradise Killer (2) PC Building (1) Persona 4 (4) Pheonix Wright Ace Attorney (1) Phoenix Wright (7) Pikmin Bloom (1) Plague Inc (1) Playing All My Steam Games (5) Pokemon (1) Princess Maker 2 (4) Princess Maker Series (3) Programming (1) Project Zero (2) PSYCHO-PASS Mandatory Happiness (3) Quick Overview (2) Rant (2) Rebuild (1) Recettear (1) Review (14) Science Girls! (1) sewing (1) Shadow Hearts (3) Shadow Hearts Series (8) Shadow Hearts: Covenant (17) Shadows and Lies (1) Shopping List (5) Sidequest (12) Sims 3 (53) Skyrim (1) Solomon's Club (1) Speed Dating for Ghosts (1) Speed Run (1) Spiderman (2) Spring of Myst (1) Spyro (2) Star Ocean: Til the End of Time (2) Stardew Valley (1) Stat-Raising (6) Steam (2) Stories Untold (1) Storyline (7) Street Fighter (1) Super Mario World (1) Tailor Tales (1) Tales of Symphonia (2) Tarkov (3) Tarzan (1) The 11th Hour (1) The 13th Doll (1) The 39 Steps (1) The 7th Guest (1) The Banner Saga (5) The Crooked Man (2) The Forgotten City (1) The King's Request (1) The Novelist (1) The Path (1) The Quiet Man (1) The Sacred Tears TRUE (1) The Sexy Brutale (2) The Sims (54) The Suicide of Rachel Foster (2) the white chamber (1) The Yawhg (1) Theory (1) Thunderhawk (3) Tigger's Honey Hunt (1) Tips (1) To Be or Not to Be (1) To the Moon (1) Trivia (21) Turing Test (1) Unlimited Cash (4) Vampire Survivors (1) Vandal Hearts II (4) Visual Novel (1) Walking Over Alice's Grave (4) Women in Games (3) Work-in-Progress (4) X-Men: Mutant Academy 2 (1) Xenosaga (1) Yuna (3) Yuri Hyuga (8) Zero Escape (2) Zodiac Challenge (53)

Saturday, 7 September 2024

I made an LED display for numbers in Factorio

Factorio is a ridiculously addictive game in which, having crash-landed on an alien planet, you start mining ore and building machines until you can build a rocket and leave. Amongst the items you can build are various components of logic circuits. Long story short, you can write programs with them.

 

I'm trying to build a smart train system (i.e., one which uses circuit logic to determine when/where a train is needed and send it there), and that involves a timer. I wanted to make a nice display for that timer. Specifically, I want to display the digits of the minutes and seconds with lights, like on a calculator.

 

Step 1 is to make a clock. For my test clock, I set an Arithmetic Combinator to calculate T (for time, or tick) plus 1, and output the new value of T. The output is then fed into a Decider combinator. The Decider outputs the input value of T as long as T does not equal 300, and is linked back into the Arithmetic Combinator.

 

This means T will count upwards for 10 seconds of real time, and then the Decider Combinator will send '0' instead of 300 and the count will start over. To see how many actual seconds have passed, the output of the Arithmetic combinator is fed into a second Arithmetic Combinator which divides T by 30 and outputs S (for 'seconds').


The 'tick rate' of Factorio is 60 per second. In other words, if you fed that first Combinator directly into itself, T would increase by 60 per second. But, I've fed my count through two combinators. Half the ticks are going into having the Decider Combinator check if we've met the limit or not. With this system, T only actually increases by 30 per second, hence 300 recorded ticks equalling 10 seconds.

 

(The alternative is to put T=1 on a Constant combinator, and feed that into the Decider. Attach the output back to the Constant Combinator, creating a loop. Have the Decider output the input value of T as long as T does not equal whatever you want to count up to, and then divide the output by 60 to see the value in seconds. This kind of clock will start counting at 1 instead of 0, which is very unlikely to matter).


Once you have a clock, it's time to work on the display. With a 3x5 light display, there are three options for how to do the numbers, based on whether you put '1' on the left, in the middle, or on the right.

 

I started building this with '1' on the right because, tbh, it did not occur to me to do anything else. On reflection, 1 in the middle has a lot to recommend it, and might be simpler. On the other hand, I already figured out most of 1-on-the right, so I'm sticking with it.

 

Lights can only be enabed or disabled by a single condition. That condition can be "if anything is equal to/less than/more than" a variable or a constant, but it can't be an 'And' or an 'Or' condition. So, I need to use more combinators to turn my S signal into whatever it is I want the lights to respond to. I want to use as few combinators as possible to do this.


I did quite a bit of experimenting with modulo, but the easiest way I found - which I think Dosh Doddington also relies on in this video - is by multiplying.


You will need the following combination of combinators:

For testing, you can also use a Constant Combinator with S set to whatever digit you want to see in place of the clock. You can also attach the LEDs to the input of another Arithmetic or Decider combinator. If you hover over it, it will display the inputs the LEDs are receiving.


The basic logic was to find values that, when multiplied by S, would have the same values for all the numbers I wanted a specific light to turn off for, but with that value not appearing for any other number. I could then set the light to turn off if everything did not equal that value. In human-speak, that's equivalent to if anything = x.

 


 

 I used the above settings for each light.

 

Always On

The Decider Combinator is what lets the always-on lights work. When S is 0, it emits the colour at input value, so there are never zero inputs. This also means the colour is continuous; if you use a different symbol, the lights will be uncoloured when S is 0. If you want to use a different colour, remember to change it in both the Constant and the Decider.


Off for 1

S*S=1 when S=1, so this light is enabled only when S does not equal 1.


Off for 2

SxS=4 when S=2, so this light is enabled only when S does not equal 4.

 

Off for 0, 1, 7

The colour is set to 70, so, when S=0, a value of 70 is emitted. Since we're multiplying S by everything, 70 blue is also emitted at S=1. Now we need something that equals 70 when S=7. That's the White 10 is for. At S=10, White = 70 and this light goes off.


Off for 1, 4, 7

1400 Iron Ore is emitted at 1, 4x350 Iron Plates are emitted when S=4, and 7x200 Steel are emitted when S=7. This light is only enabled as long as nothing = 1400, so it switches off at 1, 4, and 7. 

 

I initially tried 140, but 2x70 Blue appears when S=2, so this light was turning off for 2 as well, which we don't want. I just multiplied everything by 10 to stop them overlapping.

 

Off for 1, 7

Copper is at 490, so S*Copper=490 when S=1. S*Blue=490 when S=7. 

 

Off for 1, 4

S*S=16 whenS=4. Fish is set to 16, so S*Fish=16 when S=1.


Off for 5, 6

Water is set to 20, so S*Water=120 when S=60. Oil is set to 24, so S*Oil=120 when S=5.


Off for 1, 2, 3, 7

Various power poles at 12, 24, 48, and 84 = 84 when S is 1, 2, 3, or 7.  

 

Off for 1, 3, 4, 5, 7, 9

I used the letter symbols for 3780, 1260, 945, 540, and 420, which create 3780 when S is 1, 3, 4, 5, 7 and 9.


I picked 3780 because that's when you get when you multiple 1, 3, 4, 5, 7 and 9 together, and whatever number you use needs to be divisible by all of those. 


Blueprint String

Attach the clock/counter to the Constant with green wire.

Once you have seconds, you can use %60 to get how many seconds through the minute you are, and then use /10 and %10 to get the tens/units of that number. If you're counting over a minute, divide your total secons by 60, and use /10 and %10 on that number to gets 10 and units. You can then line up the digits and attach them in the right order.


0eNrdmVuO2zYUhrci8Kkt5IEu1M1AAxTpS5+bS9FmYNASbRGQSIGixjEGXkB2kbVlJaGk8YiWzZhWnDHSF8OUyZ88H8+Foh/BsmhwxQkVYP4IMlynnFSCMArm4A8hUJpbW9ZwK2UNFdYvGyJy6wHJMbXlzJJfLcEskWPrNaO1QLLHa1YuCUWCcavri6w1x5jKBsd3H+gH+teqFbQ2bWc5OM0RXeNOI2VFOxNbda2CrHNR2/sORFiMWksmJQ/mQzTrHvyJU5JhfgdsQFL5I5j/9whqsqaoaA0T2wpLi4jApexBUdm26hIVxaxAZQV2chjN8Ecwd3f22YGIS9NKLEg6S5/tVTS83b0NMBVEENyvpGtsF7Qpl5jLSU6twQYVq0nP/hFImRl0wrvABlv51Y/kVzmDtE1wViyWOEcPRM4qu6aEpw0RC/lb9jx+RXgtFkeGP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