Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Поехали!
- local players={}
- local io,c,e=require('io'),require("component"),require("event")
- local Dr_ID="4308 1 87"
- local computer,g,FS=c.computer,c.gpu,c.filesystem
- local d=c.debug
- local cB=101001
- local cY=0xFFFF00
- local cR=0x00FF00
- local upt=computer.uptime
- local time=0
- cont={}
- g.setResolution(30,15)
- --Маленькая граф.функция
- function ClS()
- g.setBackground(cB)
- g.fill(1,1,30,15," ")
- end
- --проверки
- function can(name)
- if not cont[name] then
- if FS.exists('../Count/'..name)==false then
- cont[name]=5
- file=io.open('/Count/'..name,'w')
- file:write(5)
- file:flush()
- file:close()
- else
- fle=io.open('/Count/'..name)
- cont[name]=fle:read()
- fle:close()
- end end
- cont[name]=tonumber(cont[name])
- if cont[name] then
- return cont[name]>0 and players[name]
- end end
- function buy(name,type) --z заявка dr дрон
- return true --Потом тут будет гет-запрос
- end
- --Экраны
- function GetDrone(name)
- if can(name) then
- if buy(name,'drone') then
- cont[name]=cont[name]-1
- d.runCommand('/give '..name..' '..Dr_ID)
- g.set(1,28,' Покупка успешна ')
- else g.set(1,1,'Недостаточно тугриков') end
- else g.set(1,1,'Нет доступных дронов')
- end
- end
- function PutBlank(name)
- if c.filesystem.exists('../Заявки/'..name)
- then g.set(1,1,'Заявка уже была подана')
- else local fle=io.open('../Заявки/'..name,'w')
- if buy(name,'z') then
- fle:write(name)
- fle:flush()
- fle:close()
- g.set(1,1,'Заявка успешно подана')
- else g.set(1,1,'Недостаточно тугриков') end
- end
- end
- function VievRules()
- ClS()
- g.setResolution(80,6)
- g.set(2,2,'Дроны-это интереснейший аппарат в OC')
- g.set(3,3,'Тем не менее,он так-же может быть')
- g.set(4,4,'гриф-тулзом,и поэтому их использование ограничено')
- os.sleep(5)
- g.setResolution(30,15)
- g.set(30,1,'X')
- end
- function MeScr(name) --Menu Screen
- ClS()
- if name=='Quant' or name=='Alex' then g.set(2,2,'E') end
- g.setBackground(cY)
- g.set(8,8,' Получить дрона ')
- g.set(8,6,' Подать заявку ')
- g.set(12,4,' Правила ')
- req2=true
- while req2 do
- _,_,x,y=e.pull(10,'touch')
- if x==2 and y==2 and (name=='Quant' or name=='Alex') then
- g.setResolution(80,25)
- local r,k=next(cont)
- while r do
- print(r,k)
- file=io.open('/Count/'..r,'w')
- file:write(k)
- file:flush()
- file:close()
- r,k=next(cont,r)
- end
- os.sleep(1)
- doing=false req2=false end
- if x>=8 and y==8 and x<=24 then GetDrone(name) req2=false end
- if x>=8 and y==6 and x<24 then PutBlank(name) req2=false end
- if x>=12 and y==4 and x<=21 then VievRules()req2=false end
- os.sleep(1)
- end
- end
- function LoginScreen()
- local name=''
- ClS()
- g.setBackground(cY)
- g.setForeground(cR)
- g.set(12,13," Логин ")
- g.setBackground(cB)
- g.set(2,2,[[ /=\ /---\ /--\ | | | |]])
- g.set(2,3,[[ | | | | | | |___| |\ |]])
- g.set(2,4,[[ | | |---/ | | | | | | |]])
- g.set(2,5,[[/===\ | \--/ | | |/ |]])
- req=true
- while req do
- _,_,x,y,_,name=e.pull(10,'touch')
- if x then if x>=12 and y==13 and x<=19 then can(name) MeScr(name) req=false
- end end
- end
- end
- doing=true
- while doing do
- file=io.open 'players'
- readed='l'
- while readed do
- readed=file:read()
- if readed then players[readed]=true end
- end
- file:close()
- LoginScreen()
- end
- os.sleep(1)
- g.setBackground(0)
- local t=require("term")
- t.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement