Bimgo

Minecraft-Computercraft (Manager program))

Jan 17th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. -- Selon le tuto de BSGSamuel ;)
  2. -- http://youtu.be/SYhVwc4Itu0
  3. --
  4. -- en cours de corrections
  5. --Next steps :
  6. -- * calculate how many fuel is need for do the job
  7. -- * send qty of fuel need and turtle go to pick up coal or charcoal need
  8. -- *
  9. print("station: "..os.computerID())
  10.  
  11. JobDispo = true
  12.  
  13. xStart = 584
  14. zStart = 637
  15.  
  16. xEnd = 614
  17. zEnd = 699
  18.  
  19. qDist = 5
  20.  
  21. xNextJob= xStart
  22. zNextJob= zStart
  23. yNextJob= 68
  24.  
  25. rednet.close("right")
  26. rednet.open("right")
  27.  
  28. function setNextJob()
  29.   xNextJob = xNextJob + qDist
  30.   if xNextJob < xEnd then
  31.     xNextJob = xStart
  32.     zNextJob = zNextJob + qDist
  33.     if zNextJob < zEnd then
  34.       JobDispo = false
  35.     end
  36.   end
  37. end
  38.  
  39. while JobDispo do
  40.   print("En attente d'une turtle")
  41.  
  42.   id, message, dist = rednet.receive()
  43.  
  44.   print("Turtle "..id.." demande job")
  45.  
  46.   if message == "getJob" then
  47.     print("Job dispo aux coord "..xNextJob.." "..zNextJob)
  48.     rednet.send(id, "Oui")
  49.     print("Envoi des données")
  50.     rednet.send(id, tostring(xNextJob))
  51.     rednet.send(id, tostring(zNextJob))
  52.     rednet.send(id, tostring(yNextJob))
  53.  
  54.     setNextJob()
  55.   end
  56. end
  57.  
  58. print("Plus de job...")
  59. ----------------------------------------
  60. -- when manager send one job all is ok except it print the "Plus de job..." and no more job are
  61. -- avaible when turtle go back...
  62. -- there is something wrong with the while do ...
  63. ----------------------------------------
  64. while true do  
  65.   id, message, dist = rednet.receive()
  66.   if message == "getJob" then
  67.     rednet.send(id,"Non")
  68.   end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment