{"id":255,"date":"2018-05-14T12:00:46","date_gmt":"2018-05-14T19:00:46","guid":{"rendered":"http:\/\/letsbuildroboticswithshadow8472.com\/?p=255"},"modified":"2018-05-13T23:37:05","modified_gmt":"2018-05-14T06:37:05","slug":"turtle-program-rewrite","status":"publish","type":"post","link":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2018\/05\/14\/turtle-program-rewrite\/","title":{"rendered":"Turtle Program Rewrite"},"content":{"rendered":"<p>Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am reporting my progress once again on my lootRepair program. Let&#8217;s get started.<\/p>\n<p>Last week, I left off with my discovery of the failed premise of my first program. It works well enough if treated properly, but the core function, turtle.craft(), didn&#8217;t behave as nicely as I would have hoped in unexpected situations. My whole design philosophy was<\/p>\n<p>1. Wait for an item to be shoved in<br \/>\n2. Make sure everything was all good to craft<br \/>\n3. Craft<br \/>\n4. Output<br \/>\n5. Check inventory for any more items to evaluate<br \/>\n6. Repeat<\/p>\n<p>Problems arose when too many items clogged up in the turtle inventory at once. My new design will focus around a turtle opening itself up for an item when it&#8217;s ready and closing itself up again when one arrives. Hoppers shut off when powered, so I&#8217;m going to have the turtles follow the same protocols. While I&#8217;m at it, I want to make a second signal so the turtles can activate an error mode and turn on a light when there&#8217;s a problem.<\/p>\n<p>This re-write, I want to actually write my program in such a way that it will be a versatile, well written program. Good code is easier to maintain, though it might be harder to write at first.<\/p>\n<p>I started the rewrite by opening Notepad++, an awesome plaintext editor for Windows, and wrote my program in what was supposed to be pseudocode, but ended up growing into attempted proper Lua. Funny how a better tool can clear the head, because the editor that came with ComputerCraft does not have cut and paste, and when I developed several functions and wanted to order them according to other functions each one calls, retyping a chunk of code longer than a few lines gets a bit discouraging.<\/p>\n<p>I transferred the files to the server computer and onto the very in-game disk I was using for my computer setup. Once again, I ended up in the same low-end, default editor for debugging my program. Admittedly, my program is still incomplete. At this point, I&#8217;m not even sure if it has the &#8220;next item&#8221; code correct.<\/p>\n<p>One thing I do like about my working prototype program is how I can hot swap items&#8230; I just had an idea, but implementing it might involve rewriting the way it&#8217;s supposed to work, but maintenance should be a bit easier. Right now, I have the turtle&#8217;s state follow a cascade controlled by a series of spaghetti-code if-then statements. My new idea would have the main loop get the turtle&#8217;s state each event and act on that. I don&#8217;t even know if it&#8217;s reasonable. Honestly, I think I should be fine with my working prototype and another turtle to regulate the item speed, but I want to publish my code here.<\/p>\n<p>Final Question: A good artist of any discipline should be able to work with any set of tools they have to work with. When you don&#8217;t care about formatting, or wish to avoid it, what plaintext editor do you use?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good Morning from my Robotics Lab! This is Shadow_8472, and today, I am reporting my progress once again on my lootRepair program. Let&#8217;s get started. Last week, I left off with my discovery of the failed premise of my first program. It works well enough if treated properly, but the core function, turtle.craft(), didn&#8217;t behave &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2018\/05\/14\/turtle-program-rewrite\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Turtle Program Rewrite&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[10,9],"tags":[],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-minecraft","category-programming"],"_links":{"self":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":3,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}