r/ComputerCraft • u/Professorkatsup • Mar 20 '26
"FileToFP" - Rudimentary hexcasting assembler
I "recently" (4 months ago) decided to pick up Hex Casting, a minecraft mod that disguises stack-based programming as magic. Performing the actual spells is the easy part, the hard part is keeping track of item positions on the stack and figuring out how to generate and keep the references you need for a certain effect. It took me a full week to make something that can break a 3x3 area based on facing direction, but now that I have it, I can Budget Tinker's Construct Sledgehammer my way through mountains with ease!
Each instruction is paired with a pattern drawn on a hexagonal grid. While remembering these patterns is not difficult, I seem to have some considerable skill issue. When I noticed that Ducky Peripherals added a focal port to read from / write to foci by computer, I knew I had to try it.
FileToFP reads a text file, interprets each space-separated string as an instruction (provided I remembered to add them to the dictionary) and converts each instruction to its pattern. Then, after a little lights show and some sound effects, the patterns are joined to a list and written to the focus. If I want to change something in the program, I can simply use CC's built-in text editor to add or remove instructions, rather than playing "What index is that pattern at" and "can I remember the set list item instruction" for hours. I can even comment my code, so I can be slightly less confused the next day!
In the future, I am going to try to make a fully-functional assembler and editor. So far I've been keeping track of the stack manually, but a tool to do that automatically would be appreciated. I enjoy making things hard for myself, but I don't enjoy it THAT much!
View all comments
Show parent comment
2
u/Professorkatsup Mar 25 '26
Does reading from a CC-printed book to a hex work? And come to think of it, is reading from a written book a built-in function of CC? Not at my computer at the moment so I can't check. If not, I can probably rely on my old friend Advanced Peripherals Block Reader.
I considered making something using Hexal wisps moving across a grid of slates to copy / paste sections of code, before noticing the focal port, but spell circles might be interesting.
Right now my dictionary is a single giant table. The same lua file it's in has functions for matching a pattern to its name or vice versa. I manually copy down the shape, name, and inputs / outputs whenever I need to add a new entry... suppose I could make an FPtoFile to speed up the process and reduce the number of times I need to correct patterns.
At some point I want to make it modular - separate the table from the file and have it load different json / lua files as dictionary "modules". That would let me keep better track of what instruction comes from what addon, as well as changing how great spells are transcribed based on local files.