Advertisement
Kobzord

letra

Jul 16th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.27 KB | None | 0 0
  1. -- fix
  2. local meuid = tonumber(os.computerID())
  3.  
  4. -- functions de blocos
  5.  
  6. local function f()
  7. turtle.forward()
  8. end
  9.  
  10. local function d()
  11. turtle.down()
  12. end
  13.  
  14. local function sai()
  15. turtle.turnRight()
  16. turtle.turnRight()
  17. turtle.back()
  18. end
  19.  
  20.  
  21. local function roda()
  22. turtle.turnRight()
  23. turtle.turnRight()
  24. turtle.back()
  25. end
  26.  
  27. local function df()
  28. turtle.dig() turtle.forward()
  29. end
  30.  
  31. local function sobe()
  32. turtle.up()
  33. end
  34.  
  35. local function b0()
  36. turtle.back()
  37. end
  38.  
  39. local function b1()
  40. turtle.back()
  41. turtle.place()
  42. end
  43.  
  44. local function return1()
  45. sobe() f() f() f() f() f() f()
  46. d() d() d() d() d()
  47. end
  48.  
  49. local function return2()
  50. b0() b0() b0() b0() b0()
  51. d() d() d() d()
  52. turtle.turnRight()
  53. turtle.turnRight()
  54. end
  55.  
  56. -- functions de letras usando os blocos
  57.  
  58. local function letraA()
  59. b0()
  60. b1() b0() b0() b0() b1() sobe() roda()
  61. b1() b0() b0() b0() b1() sobe() roda()
  62. b1() b1() b1() b1() b1() sobe() roda()
  63. b1() b0() b0() b0() b1() sobe() roda()
  64. b0() b1() b1() b1() b0()
  65. end
  66.  
  67. local function letraB()
  68. b0()
  69. b1() b1() b1() b1() b1() sobe() roda()
  70. b1() b0() b0() b0() b1() sobe() roda()
  71. b1() b1() b1() b1() b1() sobe() roda()
  72. b0() b1() b0() b0() b1() sobe() roda()
  73. b1() b1() b1() b1() b0()
  74. end
  75.  
  76. local function letraC()
  77. b0()
  78. b1() b1() b1() b1() b1() sobe() roda()
  79. b0() b0() b0() b0() b1() sobe() roda()
  80. b1() b0() b0() b0() b0() sobe() roda()
  81. b0() b0() b0() b0() b1() sobe() roda()
  82. b1() b1() b1() b1() b1()
  83. end
  84.  
  85. local function letraD()
  86. b0()
  87. b1() b1() b1() b1() b1() sobe() roda()
  88. b1() b0() b0() b0() b1() sobe() roda()
  89. b1() b0() b0() b0() b1() sobe() roda()
  90. b1() b0() b0() b0() b1() sobe() roda()
  91. b1() b1() b1() b1() b1()
  92. end
  93.  
  94. local function letraE()
  95. b0()
  96. b1() b1() b1() b1() b1() sobe() roda()
  97. b0() b0() b0() b0() b1() sobe() roda()
  98. b1() b1() b1() b1() b0() sobe() roda()
  99. b0() b0() b0() b0() b1() sobe() roda()
  100. b1() b1() b1() b1() b1()
  101. end
  102.  
  103. local function letraF()
  104. b0()
  105. b1() b0() b0() b0() b0() sobe() roda()
  106. b0() b0() b0() b0() b1() sobe() roda()
  107. b1() b1() b1() b1() b0() sobe() roda()
  108. b0() b0() b0() b0() b1() sobe() roda()
  109. b1() b1() b1() b1() b1()
  110. end
  111.  
  112. local function letraG()
  113. b0()
  114. b1() b1() b1() b1() b1() sobe() roda()
  115. b1() b0() b0() b0() b1() sobe() roda()
  116. b1() b0() b0() b1() b1() sobe() roda()
  117. b0() b0() b0() b0() b1() sobe() roda()
  118. b1() b1() b1() b1() b1()
  119. end
  120.  
  121. local function letraH()
  122. b0()
  123. b1() b0() b0() b0() b1() sobe() roda()
  124. b1() b0() b0() b0() b1() sobe() roda()
  125. b1() b1() b1() b1() b1() sobe() roda()
  126. b1() b0() b0() b0() b1() sobe() roda()
  127. b1() b0() b0() b0() b1()
  128. end
  129.  
  130. local function letraI()
  131. b0()
  132. b1() b1() b1() b1() b1() sobe() roda()
  133. b0() b0() b1() b0() b0() sobe() roda()
  134. b0() b0() b1() b0() b0() sobe() roda()
  135. b0() b0() b1() b0() b0() sobe() roda()
  136. b1() b1() b1() b1() b1()
  137. end
  138.  
  139. local function letraJ()
  140. b0()
  141. b1() b1() b1() b1() b0() sobe() roda()
  142. b0() b1() b0() b0() b1() sobe() roda()
  143. b0() b0() b0() b1() b0() sobe() roda()
  144. b0() b1() b0() b0() b0() sobe() roda()
  145. b0() b1() b1() b1() b1()
  146. end
  147.  
  148. local function letraK()
  149. b0()
  150. b1() b0() b0() b1() b0() sobe() roda()
  151. b0() b0() b1() b0() b1() sobe() roda()
  152. b1() b1() b0() b0() b0() sobe() roda()
  153. b0() b0() b1() b0() b1() sobe() roda()
  154. b1() b0() b0() b1() b0()
  155. end
  156.  
  157. local function letraL()
  158. b0()
  159. b1() b1() b1() b1() b1() sobe() roda()
  160. b0() b0() b0() b0() b1() sobe() roda()
  161. b1() b0() b0() b0() b0() sobe() roda()
  162. b0() b0() b0() b0() b1() sobe() roda()
  163. b1() b0() b0() b0() b0()
  164. end
  165.  
  166. local function letraM()
  167. b0()
  168. b1() b0() b0() b0() b1() sobe() roda()
  169. b1() b0() b0() b0() b1() sobe() roda()
  170. b1() b0() b1() b0() b1() sobe() roda()
  171. b1() b1() b0() b1() b1() sobe() roda()
  172. b1() b0() b0() b0() b1()
  173. end
  174.  
  175. local function letraN()
  176. b0()
  177. b1() b0() b0() b0() b1() sobe() roda()
  178. b1() b1() b0() b0() b1() sobe() roda()
  179. b1() b0() b1() b0() b1() sobe() roda()
  180. b1() b0() b0() b1() b1() sobe() roda()
  181. b1() b0() b0() b0() b1()
  182. end
  183.  
  184. local function letraO()
  185. b0()
  186. b0() b1() b1() b1() b0() sobe() roda()
  187. b1() b0() b0() b0() b1() sobe() roda()
  188. b1() b0() b0() b0() b1() sobe() roda()
  189. b1() b0() b0() b0() b1() sobe() roda()
  190. b0() b1() b1() b1() b0()
  191. end
  192.  
  193. local function letraP()
  194. b0()
  195. b1() b0() b0() b0() b0() sobe() roda()
  196. b0() b0() b0() b0() b1() sobe() roda()
  197. b1() b1() b1() b1() b1() sobe() roda()
  198. b1() b0() b0() b0() b1() sobe() roda()
  199. b1() b1() b1() b1() b1()
  200. end
  201.  
  202. local function letraQ()
  203. b0()
  204. b1() b1() b1() b1() b1() sobe() roda()
  205. b1() b1() b0() b0() b1() sobe() roda()
  206. b1() b0() b0() b0() b1() sobe() roda()
  207. b1() b0() b0() b0() b1() sobe() roda()
  208. b1() b1() b1() b1() b1()
  209. end
  210.  
  211. local function letraR()
  212. b0()
  213. b1() b0() b0() b0() b1() sobe() roda()
  214. b1() b1() b0() b0() b0() sobe() roda()
  215. b1() b1() b1() b1() b1() sobe() roda()
  216. b0() b0() b0() b0() b1() sobe() roda()
  217. b1() b1() b1() b1() b1()
  218. end
  219.  
  220. local function letraS()
  221. b0()
  222. b1() b1() b1() b1() b1() sobe() roda()
  223. b1() b0() b0() b0() b0() sobe() roda()
  224. b1() b1() b1() b1() b1() sobe() roda()
  225. b0() b0() b0() b0() b1() sobe() roda()
  226. b1() b1() b1() b1() b1()
  227. end
  228.  
  229. local function letraT()
  230. b0()
  231. b1() b1() b1() b1() b1() sobe() roda()
  232. b0() b0() b1() b0() b0() sobe() roda()
  233. b0() b0() b1() b0() b0() sobe() roda()
  234. b0() b0() b1() b0() b0() sobe() roda()
  235. b0() b0() b1() b0() b0()
  236. end
  237.  
  238. local function letraU()
  239. b0()
  240. b0() b1() b1() b1() b0() sobe() roda()
  241. b1() b0() b0() b0() b1() sobe() roda()
  242. b1() b0() b0() b0() b1() sobe() roda()
  243. b1() b0() b0() b0() b1() sobe() roda()
  244. b1() b0() b0() b0() b1()
  245. end
  246.  
  247. local function letraV()
  248. b0()
  249. b0() b0() b1() b0() b0() sobe() roda()
  250. b0() b1() b0() b1() b0() sobe() roda()
  251. b1() b0() b0() b0() b1() sobe() roda()
  252. b1() b0() b0() b0() b1() sobe() roda()
  253. b1() b0() b0() b0() b1()
  254. end
  255.  
  256. local function letraW()
  257. b0()
  258. b0() b1() b0() b1() b0() sobe() roda()
  259. b1() b0() b1() b0() b1() sobe() roda()
  260. b1() b0() b0() b0() b1() sobe() roda()
  261. b1() b0() b0() b0() b1() sobe() roda()
  262. b1() b0() b0() b0() b1()
  263. end
  264.  
  265. local function letraX()
  266. b0()
  267. b1() b0() b0() b0() b1() sobe() roda()
  268. b0() b1() b0() b1() b0() sobe() roda()
  269. b0() b0() b1() b0() b0() sobe() roda()
  270. b0() b1() b0() b1() b0() sobe() roda()
  271. b1() b0() b0() b0() b1()
  272. end
  273.  
  274. local function letraY()
  275. b0()
  276. b0() b0() b1() b0() b0() sobe() roda()
  277. b0() b0() b1() b0() b0() sobe() roda()
  278. b0() b0() b1() b0() b0() sobe() roda()
  279. b0() b1() b0() b1() b0() sobe() roda()
  280. b1() b0() b0() b0() b1()
  281. end
  282.  
  283. local function letraZ()
  284. b0()
  285. b1() b1() b1() b1() b1() sobe() roda()
  286. b0() b0() b0() b1() b0() sobe() roda()
  287. b0() b0() b1() b0() b0() sobe() roda()
  288. b0() b1() b0() b0() b0() sobe() roda()
  289. b1() b1() b1() b1() b1()
  290. end
  291.  
  292. local function apagar()
  293. turtle.turnRight()
  294. turtle.turnRight()
  295. df() df() df() df() df() sai() sobe()
  296. df() df() df() df() df() sai() sobe()
  297. df() df() df() df() df() sai() sobe()
  298. df() df() df() df() df() sai() sobe()
  299. df() df() df() df() df()
  300. return2()
  301. end
  302.  
  303. ----------------------------------------------- end of letter functions ----------------------
  304. local function jump() --2 up 2 down
  305. turtle.up()
  306. turtle.up()
  307. turtle.down()
  308. turtle.down()
  309. end
  310.  
  311. local function presente() -- gets selected and jumps
  312. rednet.broadcast("Selecionado!Aguardando Ordens!")
  313. jump()
  314. end
  315.  
  316. local function oi() -- answers global call
  317. rednet.broadcast("Letra aguardando, Senhor!")
  318. end
  319.  
  320. local function refuel() -- refuels
  321. fuel = turtle.getFuelLevel()
  322. while fuel < 400 do
  323. turtle.select(1)
  324. turtle.refuel(1)
  325. fuel = turtle.getFuelLevel()
  326. end
  327. end
  328.  
  329. local function chamada2() -- waits for letter
  330. id,msg4,dist = rednet.receive()
  331. turtle.select(2)
  332. if msg4 == "A" then letraA() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  333. elseif msg4 == "B" then letraB() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  334. elseif msg4 == "C" then letraC() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  335. elseif msg4 == "D" then letraD() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  336. elseif msg4 == "E" then letraE() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  337. elseif msg4 == "F" then letraF() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  338. elseif msg4 == "G" then letraG() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  339. elseif msg4 == "H" then letraH() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  340. elseif msg4 == "I" then letraI() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  341. elseif msg4 == "J" then letraJ() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  342. elseif msg4 == "K" then letraK() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  343. elseif msg4 == "L" then letraL() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  344. elseif msg4 == "M" then letraM() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  345. elseif msg4 == "N" then letraN() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  346. elseif msg4 == "O" then letraO() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  347. elseif msg4 == "P" then letraP() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  348. elseif msg4 == "Q" then letraQ() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  349. elseif msg4 == "R" then letraR() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  350. elseif msg4 == "S" then letraS() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  351. elseif msg4 == "T" then letraT() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  352. elseif msg4 == "U" then letraU() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  353. elseif msg4 == "V" then letraV() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  354. elseif msg4 == "W" then letraW() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  355. elseif msg4 == "X" then letraX() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  356. elseif msg4 == "Y" then letraY() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  357. elseif msg4 == "Z" then letraZ() rednet.broadcast("Letra "..msg4.." pronta, senhor!") return1()
  358. elseif msg4 == "Apagar" then apagar() rednet.broadcast("Letra apagada, senhor!")
  359. end
  360. end
  361.  
  362. local function chamada() -- waits for turtle select or global call
  363. id,msg,dist = rednet.receive()
  364. msgn = tonumber(msg)
  365. if msg == "Respondam!" then
  366. oi()
  367. elseif meuid == msgn then
  368. presente()
  369. chamada2()
  370. elseif msg == "TODOS" then
  371. presente()
  372. chamada2()
  373. end
  374. end
  375.  
  376. --Ínicio
  377. rednet.open("right")
  378. while true do
  379. refuel()
  380. chamada()
  381. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement