Advertisement
karelvysinka

Turtle macerator 1

Feb 1st, 2017
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1. local version =
  2. 2.0
  3. -- Program pro prijem zprav pres modem
  4. -- Pri zmene programu je treba na radku 2 zmenit verzi, aby se program automaticky aktualizoval
  5. -- local code je treba zmenit dle potreby
  6.  
  7. local code = "2rWh8k33"
  8.  
  9. --check version
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. print("Program loading...")
  13. print("Current version: "..version)
  14. local updateSite= http.get("http://pastebin.com/raw.php?i="..code)
  15. updateSite.readLine()
  16. local newVersion = updateSite.readLine()
  17. if tonumber(newVersion) > version then
  18.         print("Update required. Updating now...")
  19.         local updateSite = http.get("http://pastebin.com/raw.php?i="..code)
  20.         local siteFile = updateSite.readAll()
  21.         local writeFile = fs.open(shell.getRunningProgram(),"w")
  22.         writeFile.write(siteFile)
  23.         writeFile.close()
  24.         print("The program will now restart your computer.")
  25.         sleep(1)
  26.         os.reboot()
  27. end
  28.  
  29. function start()
  30. local cyklu = 0
  31.     while true do
  32.         print ("Program je aktualizovany")
  33.         print ("Program bezi...")
  34.         rednet.open("right")
  35.         print ("Oteviram medem right.")
  36.         print("Cekam na zpravu...")
  37.  
  38.         provedPrikaz("as")
  39.         cyklu = cyklu + 1
  40.         print("Pocet cyklu:"..cyklu)
  41.     end
  42. end
  43.  
  44. function turtlesuckdrop()
  45.     turtle.suck()
  46.     turtle.turnLeft()
  47.     turtle.turnLeft()
  48.     turtle.drop()
  49.     turtle.turnRight()
  50.     turtle.turnRight()
  51. end
  52.  
  53. function testcondenseru()
  54.     local success, data = turtle.inspect()
  55.     if success then
  56.         print("Block name: ", data.name)
  57.         print("Block metadata: ", data.metadata)
  58.         local datan = data.name    
  59.         if datan == "ProjectE:condenser_mk1" then
  60.             turtlesuckdrop()
  61.             return true
  62.         else
  63.             return false
  64.         end
  65.     end
  66. end
  67.  
  68. function provedPrikaz(message)
  69.     if message == "as" then    
  70. --prvni test
  71.         local a = testcondenseru()
  72.         if a == false then
  73.             turtle.turnRight()
  74.         end
  75.         local b = testcondenseru()
  76.         if b == false then
  77.             turtle.turnRight()
  78.         end
  79.         local c = testcondenseru()
  80.         if c == false then
  81.             turtle.turnRight()
  82.         end
  83.         local d = testcondenseru()
  84.         if d == false then
  85.             turtle.turnRight()
  86.             print("condenser_mk1 nenalezen...")
  87.         end
  88.     print("Konec provadeni prikazu")
  89.     end
  90. end
  91.  
  92. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement