The Hazards of Programming Nicely

Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am returning to the modded MineCraft world where I am working on exactly what I said I wanted to move on from last week. Let’s get started.

The smeltery program I wrote for last week was nice and all, but it had a bunch of potential improvements. For one, it was blind to its environment. It could only send out pulses when it was time for the next one. Plus, with the “analogue” capabilities of the regular computers, and my previous experience with dealing with analogue redstone, I was tempted beyond my ability to resist to tear out some space around the smeltery and upgrade the hardware.

Observer blocks were capable of giving off a pulse when a basin or table was filled and quickly emptied by a hopper. There are six sides in total for the computer to work with, but the front is on display and the top of this one is occupied with another block while the tight quarters makes threat of cross wiring redstone lines very real. Given these limitations, I set about working on a new setup capable of taking advantage of  the rs.setAnalogueOutput(string side) and rs.getAnalogueInput(string side) functions.

While I was working on the new hardware, I decided to combine the programs, and add functionality so I could pour from both places at once. I set to work with three modes in mind, meant to run almost the same code at once: “Basins”, “Tables”, and “Both”. (For the aspiring coders and grammar critics, the punctuation outside the quotes is intentional; the quotes mark the beginning and end of strings, or lengths of characters (a single symbol like a letter or digit).) The code quickly became messy, and I started going into writing functions to modularize the more deeply nested segments of code. I used a little trick I learned while writing assignments in C++ where I made a comment consisting of the comment character such that it covered a line of the editor.

//////////////////////////////////////////////////////////////////////////////////////////////////////////

The section break I just put in works in C++. Unfortunately, when I tried the Lua equivalent, WordPress changed the repeated — into a single line. Anyway, the trick is that after the comment signal, the rest of it can be either an odd or even number of character repetitions, even if the first  is double. The trick helped a little, and I pushed on, working from the extremities of the code to the main loop until I realized a bit of a mistake.

My original program was designed to loop over a number of pours to a single output. I wanted the new program to handle both at once and possibly more. I was nearing completion when I when I came to halt. The main loop was incompatible with handling both outputs at once. Ouch!

I went about redesigning it in my head, but the project just kept inflating and inflating. Soon enough, it was too big without additional notes, so I just modified my old program to work with my new hardware. Funny, how an estimated one day project ended up taking half the week and it wouldn’t have worked anyway. At this point, I am content to just leave that as it is. The hardware is set up such that the computer can tell which set of outputs to trigger and which outputs are responding, but the program doesn’t use the full functionality.

/*********************************************************************************************/

Another example of my section break for C++. This one uses the long comment format. I’ve thrown together a few more programs, but nothing amazing, and nothing refined. I have noticed a consistent pattern: once I get the code working, I want to make another, better version. ‘Maybe if I just make it do this a little bit differently…’

For my automated skeleton grinder, I already have coded up the turtles to kill the skeletons. They aren’t perfect, but they sort out the unstackables by themselves. I also learned a little more about their inventory management, so I have another idea on how to make them handle better. Besides, I also want to use more turtles to move the items about better and free up the attack turtles to actually do their main job.

My goal for this week is to fully automate the farm, at least in code even if I don’t get a presentable design in order.

Final Question: Problems can usually be solved from any different number of angles. What was the last time you scrapped progress in favor of an easier approach?

Leave a Reply