marko_rus

trader2

May 8th, 2018
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local com =require("component")
  2. local chat =com.chat
  3. local red =com.redstone
  4. local comp =require("computer")
  5. local radar =com.radar
  6. local event = require("event")
  7. local r = require("robot")
  8.  
  9. local user ={}
  10. local name
  11. local item = 0
  12. local inv
  13. local answ
  14. local price = {}
  15. price[1] = 1
  16. price[2] = 2
  17. price[3] = 3
  18. price[4] = 4
  19. local v
  20. while true do
  21. if red.getInput(3) == 15 then
  22. user =radar.getPlayers(3)
  23. chat.say("Здраствуйте "..user[1].name)
  24. chat.say("Напишите в чат ID предмета для покупки")
  25. while item == 0 do
  26. _, _, name, item = event.pull(1,"chat_message")
  27. if name == user[1].name then
  28. if item == "1" or item == "2" or item == "3" or item == "4" then
  29. if item == "1" then v = 1 end
  30. if item == "2" then v = 2 end
  31. if item == "3" then v = 3 end
  32. if item == "4" then v = 4 end
  33.  
  34. while true do
  35. if r.space(v) == 64 then
  36. chat.say("Ошибка: Товар изчерпан!")
  37. inv =1
  38. end
  39.  
  40. if r.space(16) == 0 then
  41. chat.say("Ошибка: Инвентарь полон")
  42. inv =1
  43. break
  44. end
  45.  
  46. if i == 16 then
  47. break
  48. end
  49. if inv == 1 then
  50. break
  51. else
  52. chat.say("Для обмена киньте железо роботу")
  53. inv = 0
  54. while true do
  55. if red.getInput(3) == 0 then
  56. chat.say("Эй! Мы ещё не завершили сделку!")
  57. break
  58. end
  59. if r.suck(1) == true then
  60. inv = inv+1
  61. end
  62. if inv == price[v] then
  63. r.select(v)
  64. r.drop(1)
  65. chat.say("Спасибо за покупку! если вам нужно ещё что-то то просто введите ID товара в чат")
  66. break
  67. end
  68. end
  69.  
  70. break
  71. end
  72. end
  73.  
  74. else chat.say("Возможно Вы ввели неправельный ID предмета. Попробуйте ещё раз.")
  75. end
  76. end
  77. name =""
  78. item =0
  79. inv = 0
  80. if red.getInput(3) == 0 then
  81. chat.say("Досвидания "..user[1].name)
  82. chat.say("Приходите ещё!")
  83. break
  84. end
  85.  
  86. end
  87. end
  88. end
Add Comment
Please, Sign In to add comment