Advertisement
Quant

Untitled

Nov 14th, 2015
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. --Поехали!
  2. local players={}
  3. local io,c,e=require('io'),require("component"),require("event")
  4. local Dr_ID="4308 1 87"
  5. local computer,g,FS=c.computer,c.gpu,c.filesystem
  6. local d=c.debug
  7. local cB=101001
  8. local cY=0xFFFF00
  9. local cR=0x00FF00
  10. local upt=computer.uptime
  11. local time=0
  12. cont={}
  13. g.setResolution(30,15)
  14. --Маленькая граф.функция
  15. function ClS()
  16. g.setBackground(cB)
  17. g.fill(1,1,30,15," ")
  18. end
  19. --проверки
  20. function can(name)
  21. if not cont[name] then
  22. if FS.exists('../Count/'..name)==false then
  23. cont[name]=5
  24. file=io.open('/Count/'..name,'w')
  25. file:write(5)
  26. file:flush()
  27. file:close()
  28. else
  29. fle=io.open('/Count/'..name)
  30. cont[name]=fle:read()
  31. fle:close()
  32. end end
  33. cont[name]=tonumber(cont[name])
  34. if cont[name] then
  35. return cont[name]>0 and players[name]
  36. end end
  37. function buy(name,type) --z заявка dr дрон
  38.  
  39. return true --Потом тут будет гет-запрос
  40.  
  41. end
  42. --Экраны
  43.  
  44. function GetDrone(name)
  45. if can(name) then
  46. if buy(name,'drone') then
  47. cont[name]=cont[name]-1
  48. d.runCommand('/give '..name..' '..Dr_ID)
  49. g.set(1,28,' Покупка успешна ')
  50. else g.set(1,1,'Недостаточно тугриков') end
  51. else g.set(1,1,'Нет доступных дронов')
  52. end
  53. end
  54. function PutBlank(name)
  55. if c.filesystem.exists('../Заявки/'..name)
  56. then g.set(1,1,'Заявка уже была подана')
  57. else local fle=io.open('../Заявки/'..name,'w')
  58. if buy(name,'z') then
  59. fle:write(name)
  60. fle:flush()
  61. fle:close()
  62. g.set(1,1,'Заявка успешно подана')
  63. else g.set(1,1,'Недостаточно тугриков') end
  64. end
  65. end
  66. function VievRules()
  67. ClS()
  68. g.setResolution(80,6)
  69. g.set(2,2,'Дроны-это интереснейший аппарат в OC')
  70. g.set(3,3,'Тем не менее,он так-же может быть')
  71. g.set(4,4,'гриф-тулзом,и поэтому их использование ограничено')
  72. os.sleep(5)
  73. g.setResolution(30,15)
  74. g.set(30,1,'X')
  75. end
  76. function MeScr(name) --Menu Screen
  77. ClS()
  78. if name=='Quant' or name=='Alex' then g.set(2,2,'E') end
  79. g.setBackground(cY)
  80. g.set(8,8,' Получить дрона ')
  81. g.set(8,6,' Подать заявку ')
  82. g.set(12,4,' Правила ')
  83. req2=true
  84. while req2 do
  85. _,_,x,y=e.pull(10,'touch')
  86. if x==2 and y==2 and (name=='Quant' or name=='Alex') then
  87. g.setResolution(80,25)
  88. local r,k=next(cont)
  89. while r do
  90. print(r,k)
  91. file=io.open('/Count/'..r,'w')
  92. file:write(k)
  93. file:flush()
  94. file:close()
  95. r,k=next(cont,r)
  96.  
  97. end
  98. os.sleep(1)
  99.  
  100. doing=false req2=false end
  101. if x>=8 and y==8 and x<=24 then GetDrone(name) req2=false end
  102. if x>=8 and y==6 and x<24 then PutBlank(name) req2=false end
  103. if x>=12 and y==4 and x<=21 then VievRules()req2=false end
  104.  
  105. os.sleep(1)
  106. end
  107. end
  108. function LoginScreen()
  109. local name=''
  110. ClS()
  111. g.setBackground(cY)
  112. g.setForeground(cR)
  113. g.set(12,13," Логин ")
  114. g.setBackground(cB)
  115. g.set(2,2,[[ /=\ /---\ /--\ | | | |]])
  116. g.set(2,3,[[ | | | | | | |___| |\ |]])
  117. g.set(2,4,[[ | | |---/ | | | | | | |]])
  118. g.set(2,5,[[/===\ | \--/ | | |/ |]])
  119. req=true
  120. while req do
  121. _,_,x,y,_,name=e.pull(10,'touch')
  122. if x then if x>=12 and y==13 and x<=19 then can(name) MeScr(name) req=false
  123. end end
  124. end
  125. end
  126. doing=true
  127. while doing do
  128. file=io.open 'players'
  129. readed='l'
  130. while readed do
  131. readed=file:read()
  132. if readed then players[readed]=true end
  133. end
  134. file:close()
  135. LoginScreen()
  136. end
  137. os.sleep(1)
  138.  
  139. g.setBackground(0)
  140. local t=require("term")
  141. t.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement