Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local com = require("component")
- local eve = require("event")
- local mod = com.modem
- local gpu = com.gpu
- local scr = com.screen
- local X, Y
- local B, F
- local port = 3341
- local hide = false
- local keycode = {
- [49] = true, --1
- [50] = true, --2
- [51] = true, --3
- [113] = true, --Q
- [119] = true, --W
- [101] = true, --E
- [97] = true, --A
- [115] = true, --S
- [100] = true, --D
- [122] = true, --Z
- [120] = true, --X
- [99] = true --C
- }
- local keychar = {
- [49] = "1",
- [50] = "2",
- [51] = "3",
- [113] = "Q",
- [119] = "W",
- [101] = "E",
- [97] = "A",
- [115] = "S",
- [100] = "D",
- [122] = "Z",
- [120] = "X",
- [99] = "C"
- }
- function clrscr()
- gpu.fill(1,1,X,Y," ")
- end
- function sysInit()
- gpu.bind(scr.address)
- X,Y = gpu.maxResolution()
- B = gpu.getBackground()
- F = gpu.getForeground()
- gpu.setBackground(0xBBBBFF)
- gpu.setForeground(0xAA22AA)
- clrscr()
- end
- function sysDeinit()
- gpu.setBackground(B)
- gpu.setForeground(F)
- clrscr()
- end
- function printInfo()
- gpu.set(3,2,"Управление движением:")
- gpu.set(3,3,"---------------------")
- gpu.set(3,4,"W - вперед")
- gpu.set(3,5,"S - назад")
- gpu.set(3,6,"A - влево")
- gpu.set(3,7,"D - вправо")
- gpu.set(3,8,"Q - вниз")
- gpu.set(3,9,"E - вверх")
- gpu.set(3,12,"Действия:")
- gpu.set(3,13,"-----------------------------")
- gpu.set(3,14,"1 - выбор стороны (Вкл\\Выкл)")
- gpu.set(3,15,"2 - стырить")
- gpu.set(3,16,"3 - [не назначено]")
- gpu.set(40,2,"Функции (Вкл/Выкл):")
- gpu.set(40,3,"------------------------")
- gpu.set(40,4,"Z - вернуться назад")
- gpu.set(40,5,"X - пройти путь повторно")
- gpu.set(40,6,"C - [не назначено]")
- gpu.set(40,12,"Прочее:")
- gpu.set(40,13,"------------------------------")
- gpu.set(40,14,"Space - управление экраном")
- gpu.set(40,15,"Backspace - выход")
- end
- sysInit()
- printInfo()
- while true do
- local _,_,key,_,name = eve.pull("key_down")
- if (keycode[key]==true) then
- mod.broadcast(port,keychar[key])
- gpu.set(70,24,keychar[key])
- end
- if (key==32) then
- if (hide==true) then
- gpu.setResolution(X,Y)
- os.sleep(0.2)
- printInfo()
- hide = false
- else
- gpu.setResolution(1,1)
- os.sleep(0.2)
- hide = true
- end
- end
- if (key==8) then break end
- end
- sysDeinit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement