Advertisement
karelvysinka

Přijmac 2 z boku Turtle EMC REACTOR

Jan 28th, 2017
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. local version =
  2. 3.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 = "VuM50bxj"
  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.     while true do
  31.         print ("Program je aktuåA1lnåAD")
  32.         print ("Program bezi...")
  33.         rednet.open("right")
  34.         print ("Oteviram medem right.")
  35.         print("Cekam na zpravu...")
  36.         id, message  = rednet.receive(10000000000000)
  37.         print ("Computer ".. id .. " has sent us a message")
  38.         print ("The message is")
  39.         print (message)
  40.         provedPrikaz(message)
  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