Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require('component')
- local gpu=component.gpu
- local rs=component.redstone
- local computer = require('computer')
- local event=require('event')
- local pull_e = event.pull
- local W, H = gpu.getResolution()
- b_color, f_color = gpu.getBackground(), gpu.getForeground()
- local timeout=30
- log_nickname="TEST"
- local status='.'
- try_count = 0
- local gift_toggle=false
- local me_if = component.proxy("6d7f0c13-a813-4b67-be66-3e922a22222c")
- local me_gift=component.proxy("c5256e66-ae19-4bb6-a798-a9e86b33b251")
- gift_list={
- {
- "dwcity:Powder11",
- "IC2:itemOreIridium",
- "DraconicEvolution:draconicIngot",
- "GraviSuite:advNanoChestPlate",
- "CompactSolars:CompactSolarBlock"
- },
- {
- "DraconicEvolution:wevernCore",
- "minecraft:nether_star",
- "IC2:itemArmorQuantumHelmet",
- "IC2:itemArmorQuantumChestplate",
- "IC2:itemArmorQuantumLegs",
- "IC2:itemArmorQuantumBoots",
- "CompactSolars:CompactSolarBlock"
- },
- {
- "GraviSuite:graviChestPlate",
- "CompactSolar:CompactSolarBlock"
- }
- }
- function event.shouldInterrupt()
- return false
- end
- function check_timeout()
- if timeout<=0 then
- logOut()
- return false
- end
- timeout=timeout-1;
- set_str_timeout()
- end
- background_color=0x000040
- function drawItem_Heart(x,y)
- gpu.setBackground(0)
- gpu.setForeground(0)
- gpu.fill(x,y,4,1,'x'); gpu.fill(x+7,y,4,1,'x')
- gpu.fill(x-1,y+1,1,1,'x'); gpu.fill(x+4,y+1,1,1,'x'); gpu.fill(x+6,y+1,1,1,'x'); gpu.fill(x+11,y+1,1,1,'x')
- gpu.fill(x-2,y+2,1,2,'x'); gpu.fill(x+4,y+2,1,1,'x'); gpu.fill(x+12,y+2,1,2,'x');
- gpu.fill(x-1,y+4,1,1,'x'); gpu.fill(x+11,y+4,1,1,'x')
- gpu.fill(x,y+5,1,1,'x'); gpu.fill(x+10,y+5,1,1,'x')
- gpu.fill(x+1,y+6,1,1,'x'); gpu.fill(x+9,y+6,1,1,'x')
- gpu.fill(x+2,y+7,1,1,'x'); gpu.fill(x+8,y+7,1,1,'x')
- gpu.fill(x+3,y+8,1,1,'x'); gpu.fill(x+7,y+8,1,1,'x')
- gpu.fill(x+4,y+9,1,1,'x'); gpu.fill(x+6,y+9,1,1,'x')
- gpu.setBackground(0xFF0040);
- gpu.setForeground(0xFF0040);
- gpu.fill(x,y+1,4,1,'x'); gpu.fill(x+7,y+1,4,1,'x')
- gpu.fill(x-1,y+2,13,2,'x')
- gpu.fill(x,y+4,11,1,'x')
- gpu.fill(x+1,y+5,9,1,'x')
- gpu.fill(x+2,y+6,7,1,'x')
- gpu.fill(x+3,y+7,5,1,'x')
- gpu.fill(x+4,y+8,3,1,'x')
- gpu.fill(x+5,y+9,1,1,'x')
- gpu.setBackground(0xFFFFFF)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(x,y+2,3,1,'x')
- gpu.fill(x,y+3,1,1,'x')
- gpu.setBackground(0x003340)
- gpu.setForeground(0x003340)
- gpu.fill(x+11,y+5,1,1,'x')
- gpu.fill(x+10,y+6,1,1,'x')
- gpu.fill(x+9,y+7,1,1,'x')
- gpu.fill(x+8,y+8,1,1,'x')
- gpu.fill(x+7,y+9,1,1,'x')
- gpu.fill(x+6,y+10,1,1,'x')
- end
- function drawItem_Diamond(x,y)
- gpu.setBackground(0);
- gpu.setForeground(0);
- gpu.fill(x,y,6,1,'x')
- gpu.fill(x-1,y+1,1,1,'x'); gpu.fill(x+6,y+1,1,1,'x')
- gpu.fill(x-2,y+2,1,1,'x'); gpu.fill(x+7,y+2,1,1,'x')
- gpu.fill(x-3,y+3,1,2,'x'); gpu.fill(x+8,y+3,1,2,'x')
- gpu.fill(x-4,y+5,1,2,'x'); gpu.fill(x+9,y+5,1,2,'x')
- gpu.fill(x-3,y+7,1,1,'x'); gpu.fill(x+8,y+7,1,1,'x')
- gpu.fill(x-2,y+8,1,1,'x'); gpu.fill(x+7,y+8,1,1,'x')
- gpu.fill(x-1,y+9,8,1,'x')
- gpu.setBackground(0xFFFFFF)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(x,y+1,6,1,'x')
- gpu.fill(x-1,y+2,1,1,'x'); gpu.fill(x+3,y+3,2,1,'x')
- gpu.fill(x-2,y+4,1,1,'x'); gpu.fill(x+1,y+4,1,1,'x')
- gpu.fill(x-3,y+5,1,2,'x')
- gpu.setBackground(0x00B6FF)
- gpu.setForeground(0x00B6FF)
- gpu.fill(x,y+2,7,1,'x')
- gpu.fill(x-2,y+3,5,1,'x'); gpu.fill(x+5,y+3,3,1,'x')
- gpu.fill(x-1,y+4,2,1,'x'); gpu.fill(x+2,y+4,6,1,'x')
- gpu.fill(x-2,y+5,11,2,'x')
- gpu.fill(x-2,y+7,10,1,'x')
- gpu.fill(x-1,y+8,8,1,'x')
- gpu.setBackground(0x336D80)
- gpu.setForeground(0x336D80)
- gpu.fill(x+6,y+4,2,1,'x')
- gpu.fill(x,y+6,6,1,'x')
- gpu.fill(x-1,y+7,1,1,'x'); gpu.fill(x+6,y+7,1,1,'x')
- gpu.setBackground(0x33B5C0)
- gpu.setForeground(0x33B6C0)
- gpu.fill(x+5,y+4,1,2,'x')
- end
- function drawItem_Apple(x,y)
- gpu.setBackground(0)
- gpu.setForeground(0)
- gpu.fill(x+5,y,1,2,'x')
- gpu.fill(x+4,y+2,1,1,'x')
- gpu.fill(x+1,y+3,6,1,'x')
- gpu.fill(x-1,y+4,2,1,'x'); gpu.fill(x+7,y+4,2,1,'x')
- gpu.fill(x-2,y+5,1,1,'x'); gpu.fill(x+9,y+5,1,1,'x')
- gpu.fill(x-3,y+6,1,2,'x'); gpu.fill(x+10,y+6,1,2,'x')
- gpu.fill(x-2,y+8,1,1,'x'); gpu.fill(x+9,y+8,1,1,'x')
- gpu.fill(x-1,y+9,1,1,'x'); gpu.fill(x+8,y+9,1,1,'x')
- gpu.fill(x,y+10,3,1,'x'); gpu.fill(x+5,y+10,3,1,'x')
- gpu.setBackground(0xFFDB00)
- gpu.setForeground(0xFFDB00)
- gpu.fill(x+1,y+4,6,1,'x')
- gpu.fill(x-1,y+5,10,1,'x')
- gpu.fill(x-2,y+6,12,2,'x')
- gpu.fill(x-1,y+8,10,1,'x')
- gpu.fill(x,y+9,8,1,'x')
- gpu.setBackground(0xFFB600)
- gpu.setForeground(0xFFB600)
- gpu.fill(x+6,y+5,3,1,'x')
- gpu.fill(x+8,y+6,2,2,'x')
- gpu.fill(x-2,y+7,1,1,'x'); gpu.fill(x+7,y+8,2,1,'x')
- gpu.fill(x,y+9,3,1,'x'); gpu.fill(x+5,y+9,3,1,'x')
- gpu.setBackground(0xFFFFFF)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(x+1,y+5,3,1,'x')
- gpu.fill(x,y+6,2,1,'x')
- gpu.setBackground(0x996D00)
- gpu.setForeground(0x996D00)
- gpu.fill(x+3,y+4,2,1,'x')
- gpu.fill(x+3,y+9,2,1,'x')
- end
- function drawItem_Cake(x,y)
- gpu.setForeground(0xFF9240)
- gpu.setBackground(0xFF9240)
- gpu.fill(x+3,y,5,1,'x')
- gpu.fill(x-2,y+1,12,1,'x')
- gpu.fill(x-4,y+2,16,1,'x')
- gpu.fill(x-5,y+3,18,2,'x')
- gpu.fill(x-4,y+5,16,1,'x')
- gpu.fill(x-3,y+6,15,1,'x')
- gpu.fill(x-2,y+7,13,1,'x')
- gpu.setForeground(0x994900)
- gpu.setBackground(0x994900)
- gpu.fill(x,y,3,1,'x')
- gpu.fill(x+6,y+1,2,1,'x')
- gpu.fill(x-4,y+2,1,1,'x')
- gpu.fill(x+1,y+3,2,2,'x'); gpu.fill(x+6,y+3,3,1,'x')
- gpu.fill(x-5,y+5,1,1,'x'); gpu.fill(x+11,y+5,2,1,'x')
- gpu.fill(x-4,y+6,1,1,'x'); gpu.fill(x+11,y+6,1,1,'x'); gpu.fill(x+5,y+6,3,1,'x')
- gpu.fill(x+10,y+7,1,1,'x')
- gpu.fill(x,y+8,9,1,'x')
- end
- function clear_log()
- gpu.setBackground(background_color)
- gpu.setForeground(background_color)
- gpu.fill(10,19,25,3,' ')
- end
- function charg_img(id, x, y)
- if id==1 then
- x=x-2
- drawItem_Heart(x,y)
- elseif id==2 then
- x=x-3
- y=y-1
- drawItem_Diamond(x,y)
- elseif id==3 then
- x=x-3
- y=y-1
- drawItem_Apple(x,y)
- elseif id==4 then
- x=x-3
- drawItem_Cake(x,y)
- end
- end
- function play()
- gpu.setBackground(background_color)
- gpu.setForeground(background_color)
- gpu.fill(68,28,80,20,' ')
- local mass={1,2,3}
- local gift_toggle={0,0,0}
- if try_count>0 then
- try_count=try_count-1
- imgX=0
- imgY=30
- for a=1,3 do
- if a==1 then imgX=75
- elseif a==2 then imgX=105
- else imgX=132
- end
- for b=1,3 do
- mass[a]=math.floor( math.random(1,50) )
- gpu.setBackground(background_color)
- gpu.setForeground(background_color)
- local fillX = imgX - 9
- local fillY = imgY - 3
- gpu.fill(fillX,fillY,22,15,' ')
- if mass[a]%2==0 then charg_img(1,imgX,imgY); gift_toggle[a]=1
- elseif mass[a]%5==0 then charg_img(3,imgX,imgY); gift_toggle[a]=3
- elseif mass[a]%3==0 then charg_img(2,imgX,imgY); gift_toggle[a]=2
- else
- charg_img(4,imgX,imgY)
- gift_toggle[a]=4
- end
- os.sleep(0.5)
- end
- set_str_trycount()
- end
- if gift_toggle[1]==gift_toggle[2] and gift_toggle[1]==gift_toggle[3] then
- local var_rnd=0
- if gift_toggle[1]==2 then
- var_rnd=tonumber(math.floor(math.random(1,2)))
- if var_rnd==2 then me_gift.exportItem({id=gift_list[3][2], damage=2},"EAST",1)
- else me_gift.exportItem({id=gift_list[3][var_rnd]},"EAST",1)
- end
- elseif gift_toggle[1]==3 then
- var_rnd=tonumber(math.floor(math.random(1,5)))
- if var_rnd==5 then me_gift.exportItem({id=gift_list[2][5], damage=1},"EAST",1)
- else me_gift.exportItem({id=gift_list[2][var_rnd]},"EAST",1)
- end
- elseif gift_toggle[1]==4 then
- var_rnd=nonumber(math.floor(math.random(1,5)))
- if var_rnd==5 then me_gift.exportItem({id=gift_list[1][5], damage=0},"EAST",1)
- else me_gift.exportItem({id=gift_list[1][var_rnd]},"EAST",1)
- end
- elseif gift_toggle[1]==1 then
- me_gift.exportItem({id="dwcity:Materia"},"EAST",2)
- end
- end
- gift_toggle[1]=0
- gift_toggle[2]=0
- gift_toggle[3]=0
- else
- gpu.setForeground(0xFF0000)
- gpu.set(85,28,"ПОСТАЛОСЬ 0 ПОПЫТОК")
- end
- end
- tButtons = {
- {
- visible = true,
- X = W-5,
- Y = 2,
- W = 4,
- H = 1,
- color = 0xff0000,
- textColor = 0xffffff,
- text = 'X',
- action = function()
- gpu.setBackground(b_color)
- gpu.setForeground(f_color)
- gpu.fill(1, 1, W, H, ' ')
- os.exit()
- end
- },
- {
- visible = true,
- X = 12.5,
- Y = 35,
- W = 15,
- H = 3,
- color = 0x3324FF,
- textColor = 0xFFFFFF,
- text = 'PLAY',
- action = function()
- computer.beep()
- event.cancel(1)
- timeout=30
- set_str_timeout()
- play()
- event.timer(1, function() check_timeout() end, 31)
- end
- },
- {
- visible=true,
- X=12.5,
- Y=40,
- W=15,
- H=3,
- color= 0x3324FF,
- textColor=0xFFFFFF,
- text = 'Login',
- action = function()
- computer.beep()
- clear_log()
- gpu.setForeground(0xFFFFFF)
- gpu.set(12.5,20,log_nickname)
- toggleVisible(3)
- toggleVisible(2)
- toggleVisible(4)
- toggleVisible(5)
- status = computer.addUser(log_nickname)
- set_str_trycount()
- event.timer(1,function() check_timeout() end, 31)
- end
- },
- {
- visible=true,
- X=12.5,
- Y=40,
- W=15,
- H=3,
- color=0x3324FF,
- textColor=0xFFFFFF,
- text='Unlogin',
- action = function()
- computer.beep()
- logOut()
- end
- },
- {
- visible=true,
- X=30,
- Y=23,
- W=7,
- H=1,
- color=0x3324FF,
- textColor=0xFFFFFF,
- text='Reload',
- action=function()
- event.cancel(1)
- timeout=30
- set_str_timeout()
- set_str_trycount()
- event.timer(1, function() check_timeout() end, 31)
- end
- }
- }
- function logOut()
- event.cancel(1)
- timeout=30
- clear_log()
- status=computer.removeUser(log_nickname)
- log_nickname=" "
- trycount=0
- toggleVisible(4)
- toggleVisible(3)
- toggleVisible(2)
- toggleVisible(5)
- end
- function check_giftPosition()
- end
- function set_str_timeout()
- gpu.fill(30,45,5,1,' ')
- gpu.setForeground(0xFFFFFF)
- gpu.set(30,45,tostring(timeout))
- end
- function set_str_trycount()
- for i=1,25 do
- local inv_item=me_if.getItemsInNetwork()[i]
- if inv_item==nil then
- break
- end
- if inv_item.name=="minecraft:iron_block" then
- try_count = try_count + math.floor(tonumber(inv_item.size)/5)
- local slot=me_if.getAvailableItems()[i]
- me_if.exportItem(slot.fingerprint,'SOUTH',inv_item.size)
- end
- end
- gpu.setBackground(background_color)
- gpu.fill(23,23,3,1,' ')
- gpu.setForeground(0xFFFFFF)
- gpu.set(23,23,tostring(try_count))
- end
- function drawButton(n) -- функция рисования кнопки
- gpu.setBackground(tButtons[n].color) -- задаем цвет кнопки
- gpu.setForeground(tButtons[n].textColor) -- задаем цвет текста
- gpu.fill(tButtons[n].X, tButtons[n].Y, tButtons[n].W, tButtons[n].H, ' ') -- заливаем область
- gpu.set(tButtons[n].X+(tButtons[n].W/2)-(#tButtons[n].text/2), tButtons[n].Y+(tButtons[n].H/2), tButtons[n].text) -- пишем текст по центру
- end
- function toggleVisible(n) -- переключение видимости кнопки
- if tButtons[n].visible then -- если кнопка видима
- tButtons[n].visible = false -- отключаем
- gpu.setBackground(background_color) -- берем цвет фона, полученный при старте программы
- gpu.fill(tButtons[n].X, tButtons[n].Y, tButtons[n].W, tButtons[n].H, ' ') -- стираем кнопку
- else -- если кнопка не активна
- tButtons[n].visible = true -- активируем
- drawButton(n) -- запускаем отрисовку
- end
- end
- local function blink(n) -- мигание кнопки
- tButtons[n].color, tButtons[n].textColor = tButtons[n].textColor, tButtons[n].color -- меняем местами цвета фона и текста
- drawButton(n) -- отрисовываем кнопку
- os.sleep(0.09) -- делаем задержку
- tButtons[n].color, tButtons[n].textColor = tButtons[n].textColor, tButtons[n].color -- меняем цвета обратно
- drawButton(n) -- перерисовываем кнопку
- end
- gpu.setBackground(background_color)
- gpu.setForeground(background_color)
- gpu.fill(1, 1, W, H, ' ') -- очищаем экран
- for i = 1, #tButtons do
- toggleVisible(i) -- активируем каждую кнопку
- end
- toggleVisible(3)
- gpu.setBackground(background_color)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(1,1,W,1,'=') --горизонтальные черты
- gpu.fill(1,H,W,1,'=')
- gpu.set(W-30,H,"|-edited by SanyaRamzik-|") --подпись
- gpu.set(13,1,'|Warp LEGEND|')
- --Инфа боковая панель--
- gpu.setForeground(0x66B6FF)
- gpu.set(10,5,'Ресы не возвращаются')
- gpu.set(4,8,'1 попытка - 5 железных блоков')
- gpu.set(5,45,'Таймаут, выход через: ')
- set_str_timeout()
- gpu.set(7,23,'Кол-во попыток: ')
- for i=1,H do
- gpu.set(40,i,"|") --вертикальная черта
- end
- --Призы--
- gpu.setForeground(0xFFB600)
- gpu.set(50,10,'Солнечная панель 4ур')
- gpu.set(50,12,'Гравитационный жилет')
- gpu.setForeground(0xCC0040)
- gpu.set(85,10,'Часть квант сета')
- gpu.set(85,12,'Ядро Виверны')
- gpu.set(85,14,'Адская звезда')
- gpu.set(85,16,'Солнечная панель 3ур')
- gpu.setForeground(0x3300FF)
- gpu.set(120,10,'Сжатый камень')
- gpu.set(120,12,'Иридий')
- gpu.set(120,14,'Пробужденный драк. слиток')
- gpu.set(120,16,'Улучш. нано жилет')
- gpu.set(120,18,'Солнечная панель 2ур')
- while true do
- local tEvent = {pull_e('touch')} -- ждем клика
- for i = 1, #tButtons do -- перебираем все кнопки
- if tButtons[i].visible then -- если кнопка активна
- if tEvent[3] >= tButtons[i].X and tEvent[3] <= tButtons[i].X+tButtons[i].W and tEvent[4] >= tButtons[i].Y and tEvent[4] <= tButtons[i].Y+tButtons[i].H then -- если клик произведен в пределах кнопки
- local usr={computer.users()}
- log_nickname=tostring(tEvent[6])
- if log_nickname==tostring(usr[1]) and tButtons[3].visible==false then
- blink(i) -- мигнуть кнопкой
- tButtons[i].action() -- выполнить назначенный код
- break
- elseif tButtons[3].visible==true then
- blink(i)
- tButtons[i].action()
- break
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement