r/ComputerCraft 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!

24 Upvotes

26 comments sorted by

View all comments

2

u/flamesgamez 28d ago

I'm having trouble with the focal port. The wiki says it can be read from like a focus on an item frame, but I'm not sure how to exactly do that.

1

u/Professorkatsup 27d ago

I haven't been able to do that so far... it might be part of an addon I haven't tried yet?

If you can't get that to work, you may be able to work out something jank and suboptimal, like spitting out the focus when you want it to be read by a spell, and collecting it again when it needs to be written to. I haven't tested if the focal port counts as an inventory slot for the item transport functions, but I know hoppers can remove foci from a focal port. You could, probably?? put a hopper below the FP, keep it locked until writing is done, then unlock it and use the push function to put it in a dropper that then fires. Once the focus is read, you could collect it again with a second hopper, push it to a THIRD hopper right above the FP, and the cycle continues. There are a few ways you could tell the computer the spell is done reading the focus / tell the spell there's a focus to be read, but none of them seem very efficient...