{"id":260,"date":"2018-05-21T12:00:47","date_gmt":"2018-05-21T19:00:47","guid":{"rendered":"http:\/\/letsbuildroboticswithshadow8472.com\/?p=260"},"modified":"2018-05-20T22:01:22","modified_gmt":"2018-05-21T05:01:22","slug":"lootrepair0-3","status":"publish","type":"post","link":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2018\/05\/21\/lootrepair0-3\/","title":{"rendered":"lootRepair0.3"},"content":{"rendered":"<p>Good Morning from my Robotics Lab! This is Shadow_8472 and today, I am reviewing my progress on the lootRepair program from my previous two posts. Let&#8217;s get started.<\/p>\n<p>I started this iteration of the program with a major paradigm shift. My first two attempts at the program could be modeled as following a coded track. I gave up when I had trouble tracking down too many bugs when I tried to break my second attempt.<\/p>\n<p>My new version has two phases in its main loop: a getState phase, and an action phase. The getState phase takes a look at the turtle&#8217;s state, and the action phase acts on that phase, handling the upstream redstone output, weather or not to wait on an event, and there&#8217;s even a spot where I can put extra code; all of which were previously handled with multiple instances of redundant code, each copy of which had to be visited when a change was made to one of them. I think of it as a state machine, but I&#8217;m not exactly sure if that&#8217;s the proper name for it. Whatever the case, the debugged product should be able to handle me giving it more abuse with less patchwork.<\/p>\n<p>Building up the code to check for a crafting table took four attempts before I came up with a version that wasn&#8217;t too ugly to follow, and then one still needs to know what they&#8217;re looking at. Early startup() attempts were based on &#8220;use the correct tool, turtle.getItemDetail(n)[&#8220;name&#8221;], and baby its weak spot, (possible crash from a nil return)&#8221; ideas, so I ended up using the slightly slower, but more ingenuitive approach, try to equip each item in the turtle&#8217;s inventory and see if it can craft if something equips. Keep track of if and where a workable slot is found, and try the other equipped slot. (There&#8217;s a bug where crafty turtles forget their crafting benches, but they work after unequipping and reequipping them.)<\/p>\n<p>As of right now, I still need to finish debugging it. When I transferred my Notepad++ generated document and stuffed it in the ComputerCraft folder where executable programs are stored, I got a bunch of errors and wide gaps where lines of code should be, or more likely, they are some other character interpreted as a line feed. After all, the CC editor doesn&#8217;t use proper tabs, maybe something else is messed up.<\/p>\n<p>I&#8217;ve been editing the original program in parallel as I debug the in-game version. It&#8217;s a little redundant, but I really want to publish this some time here, hopefully next week&#8230; if I don&#8217;t take a break and blog about something else.<\/p>\n<p>Final Question: Do you know a lot about ComputerCraft? Why is the turtle glitching its crafting table away on chunk reload?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good Morning from my Robotics Lab! This is Shadow_8472 and today, I am reviewing my progress on the lootRepair program from my previous two posts. Let&#8217;s get started. I started this iteration of the program with a major paradigm shift. My first two attempts at the program could be modeled as following a coded track. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2018\/05\/21\/lootrepair0-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;lootRepair0.3&#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":[1],"tags":[],"class_list":["post-260","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/260","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=260"}],"version-history":[{"count":1,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/260\/revisions"}],"predecessor-version":[{"id":261,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/260\/revisions\/261"}],"wp:attachment":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/media?parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/categories?post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/tags?post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}