a="0.0.1"locald=turtlelocale={}e.defaultSettings={debug=false,safe=true,destructive=false,fuels={"minecraft:coal","minecraft:charcoal"}}localfunctionf(t,u)ifuandu.debugthenprint("[MS] "..t)endendfunctiond.digBack(t)d.turnRight()d.turnRight()d.dig(t)d.turnRight()d.turnRight()endfunctiond.detectBack()d.turnRight()d.turnRight()localt=d.detect()d.turnRight()d.turnRight()returntendlocalfunctiong(t,u,v,w)w=wore.defaultSettingsb=w.safeore.defaultSettings.safec=w.destructiveore.defaultSettings.destructivelocalx=t()ifnotbthenreturnendwhilenotxdof("Unable to move.",w)ifcandv()thenf("Detected a block in the way; attempting to remove it.",w)u()endx=t()endendlocalfunctionh(t)f("Moving up.",t)g(d.up,d.digUp,d.detectUp,t)endlocalfunctionj(t)f("Moving down.",t)g(d.down,d.digDown,d.detectDown,t)endlocalfunctionk(t)f("Moving forward.",t)g(d.forward,d.dig,d.detect,t)endlocalfunctionl(t)f("Moving back.",t)g(d.back,d.digBack,d.detectBack,t)endlocalfunctionm(t)f("Turning right.",t)d.turnRight()endlocalfunctionn(t)f("Turning left.",t)d.turnLeft()endlocalo={["U"]={f=h,needsFuel=true},["D"]={f=j,needsFuel=true},["L"]={f=n,needsFuel=false},["R"]={f=m,needsFuel=false},["F"]={f=k,needsFuel=true},["B"]={f=l,needsFuel=true},["P"]={f=d.place,needsFuel=false},["Pu"]={f=d.placeUp,needsFuel=false},["Pd"]={f=d.placeDown,needsFuel=false},["A"]={f=d.attack,needsFuel=false},["Au"]={f=d.attackUp,needsFuel=false},["Ad"]={f=d.attackDown,needsFuel=false}}localfunctionp(t)f("Refueling...",t)localu=t.fuelsore.defaultSettings.fuelslocalv=falseforw=1,16dolocalx=d.getItemDetail(w)ifx~=nilthenfory,zinpairs(u)doifx.name==zthend.select(i)ifd.refuel(x.count)thenv=trueendbreakendendendendreturnvendlocalfunctionq(t,u)p(u)whiled.getFuelLevel<tdoprint("[MS] Fuel level is too low. Level: "..d.getFuelLevel()..". Required: "..t..". Please add some of the following fuels:")localv=u.fuelsore.defaultSettings.fuelsforx,yinpairs(v)doprint(" - "..y)endlocalw=falsewhilenotwdoos.pullEvent("turtle_inventory")w=p()endendendlocalfunctionr(t,u)localv=o[t.action]ifvthenf("Executing action \""..t.action.."\""..t.count.." times.",u)localw=((u.safeortrue)and(v.needsFuel)and(t.count>d.getFuelLevel()))ifwthenlocalx=t.countq(x,u)endforx=1,t.countdov.f()endendendlocalfunctions(t,u)localv={}forwinstring.gfind(t,"%W*(%d*%u%l*)%W*")dolocalx,y=string.find(w,"%d+")localz,A=string.find(w,"%u%l*")localB=1ifx~=nilthenB=tonumber(string.sub(w,x,y))endlocalC=string.sub(w,z,A)ifB<1orB>d.getFuelLimit()thenerror("Instruction at index "..z.." has an invalid count of "..B..". It should be >= 1 and <= "..d.getFuelLimit())endifo[C]==nilthenerror("Instruction at index "..z..", \""..C.."\", does not refer to a valid action.")endtable.insert(v,{action=C,count=B})f("Parsed instruction: "..w,u)endreturnvendfunctione.run(t,u)u=uore.defaultSettingst=tor""f("Executing script: "..t,u)localv=s(t,u)forw,xinpairs(v)dor(x,u)endendfunctione.runFile(t,u)localv=fs.open(t,"r")localw=v.readAll()v.close()e.run(w,u)endreturne