-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.lua
More file actions
78 lines (65 loc) · 2.6 KB
/
Copy pathMain.lua
File metadata and controls
78 lines (65 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
local GUI = require("GUI")
local system = require("System")
local component = require("component")
local modem = component.modem
local PORT = 1234
modem.open(PORT)
-- Получение размеров экрана
local screenWidth, screenHeight = component.gpu.getResolution()
-- Создание окна
local workspace, window = system.addWindow(GUI.titledWindow(1, 1, screenWidth, screenHeight, "Отправка талона"))
window.width, window.height = screenWidth, screenHeight
window.actionButtons.close.onTouch = function()
window:close()
end
-- Центровка
local inputWidth = math.floor(screenWidth * 0.6)
local centerX = math.floor((screenWidth - inputWidth) / 2)
local lineHeight = 3
local spacing = 2
local startY = 2
-- Поле "Причина" (визуально, не участвует в логике)
window:addChild(GUI.label(centerX, startY, inputWidth, 1, 0x000000, "Причина:"))
window:addChild(GUI.input(
centerX, startY + lineHeight, inputWidth, lineHeight,
0xCCCCCC, 0x000000, 0x000000, 0xCCCCCC, 0x2D2D2D, "",
"Получить / Отправить"
))
-- Поле "Талон"
window:addChild(GUI.label(centerX, startY + 2 * (lineHeight + spacing), inputWidth, 1, 0x000000, "Талон:"))
local ticketInput = window:addChild(GUI.input(
centerX, startY + 3 * (lineHeight + spacing) - spacing, inputWidth, lineHeight,
0xCCCCCC, 0x000000, 0x000000, 0xCCCCCC, 0x2D2D2D, "", "123"
))
-- Поле "Окно"
window:addChild(GUI.label(centerX, startY + 4 * (lineHeight + spacing), inputWidth, 1, 0x000000, "Окно:"))
local windowInput = window:addChild(GUI.input(
centerX, startY + 5 * (lineHeight + spacing) - spacing, inputWidth, lineHeight,
0xCCCCCC, 0x000000, 0x000000, 0xCCCCCC, 0x2D2D2D, "", "1"
))
-- Кнопка "Отправить"
local button = window:addChild(GUI.button(
centerX, startY + 6 * (lineHeight + spacing), inputWidth, lineHeight + 1,
0x4CAF50, 0xFFFFFF, 0x3E8E41, 0xFFFFFF, "Отправить"
))
-- Статус
local status = window:addChild(GUI.label(
centerX, startY + 7 * (lineHeight + spacing) + 1, inputWidth, 1,
0x00FF00, "Ожидание ввода..."
))
-- Обработка кнопки
button.onTouch = function()
local ticket = ticketInput.text
local win = windowInput.text
if ticket ~= "" and win ~= "" then
local message = ticket .. " " .. win
modem.broadcast(PORT, message)
status.text = "Отправлено: " .. message
status.colors.text = 0x00FF00
else
status.text = "Ошибка: заполните оба поля"
status.colors.text = 0xFF0000
end
workspace:draw()
end
workspace:draw()