Advertisement
Rijen

main.lua

May 11th, 2023 (edited)
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.00 KB | None | 0 0
  1. unicode = require('unicode')
  2.  
  3. component = require('component')
  4. gpu = component.gpu
  5. gpu.setResolution(100,40)
  6. local GUI = require('GUI')
  7. local event=require("event")
  8. ------------------
  9.  
  10.  
  11. local items = {
  12.     { name = "Древние обломки", qty = 27 },
  13.     { name = "Сигнальный факел", qty = 48 },
  14.     { name = "Тыква с вырезанным лицом", qty = 6 },
  15.     { name = "Алмазная кирка", qty = 14 },
  16.     { name = "Зачарованное золотое яблоко", qty = 52 },
  17.     { name = "Бродячая паутина", qty = 61 },
  18.     { name = "Бутылка", qty = 42 },
  19.     { name = "Блок медового сота", qty = 22 },
  20.     { name = "Железный нагрудник", qty = 29 },
  21.     { name = "Фонарь из тыквы", qty = 35 },
  22.     { name = "Водоросли", qty = 63 },
  23.     { name = "Лестница", qty = 7 },
  24.     { name = "Блок магмы", qty = 52 },
  25.     { name = "Кирка из нефрита", qty = 14 },
  26.     { name = "Обсидиан", qty = 54 },
  27.     { name = "Отполированный чернокамень", qty = 45 },
  28.     { name = "Кварцевый столб", qty = 48 },
  29.     { name = "Редстоун-повторитель", qty = 15 },
  30.     { name = "Песок душ", qty = 11 },
  31.     { name = "Череп черепахи", qty = 24 },
  32.     { name = "Мембрана векса", qty = 28 },
  33.     { name = "Яйцо спауна скитающегося торговца", qty = 8 },
  34.     { name = "Бутылка опыта", qty = 16 },
  35.     { name = "Желтая шерсть", qty = 44 },
  36.     { name = "Яйцо спауна свинолюда", qty = 57 },
  37.     { name = "Яйцо спауна старших стражей", qty = 62 },
  38.     { name = "Предмет платежей маяка", qty = 61 },
  39.     { name = "Морковь на палочке", qty = 60 },
  40.     { name = "Алмазные ботинки", qty = 3 },
  41.     { name = "Зачарованная книга", qty = 21 },
  42.     { name = "Падение с высоты", qty = 46 },
  43.     { name = "Стеклянная панель", qty = 10 },
  44.     { name = "Люк", qty = 20 },
  45.     { name = "Музыкальный блок", qty = 51 },
  46. }
  47.  
  48.  
  49.  
  50. local WIDTH,HEIGHT = gpu.getResolution()
  51.  
  52. local defBG, defFG = gpu.getBackground(),gpu.getForeground()
  53. local gui = GUI:new()
  54.                 :setBackground(0x262626)
  55.                 :setForeground(0xCCCCCC)
  56.                 :clear()
  57.  
  58. -- gui:printBySymbol('Проснись, Нео!',10,9)
  59. -- os.sleep(1)
  60.  
  61. gui:clear()
  62.  
  63. local frame = gui:create(GUI.components.frame)
  64.         :new()
  65.         -- :new(WIDTH-10,HEIGHT-4, 5, 2)
  66.         :draw():drawTitle('Title 2')
  67. frame:drawTitle('"Hello World" by Rijen','bottom')
  68.  
  69.  
  70. local actions = {
  71.     function()
  72.         gpu.fill(3,5,WIDTH-21,1,' ')
  73.         gui:printBySymbol('Ай!',3,5)
  74.     end,
  75.     function()
  76.         gpu.fill(3,5,WIDTH-21,1,' ')
  77.         gui:printBySymbol('Ой!',3,5)
  78.     end,
  79.     function()
  80.         gpu.fill(3,5,WIDTH-21,1,' ')
  81.         gui:printBySymbol('Перестань!',3,5)
  82.     end,
  83. }
  84.  
  85.  
  86. gui:create(GUI.components.smallButton)
  87.         :new('Кнопочка 1', 2, 38):draw()
  88.         :on('touch',actions[1])
  89. gui:create(GUI.components.button)
  90.         :new('Кнопочка 2', 2, 1, 18):draw()
  91.         :on('touch',actions[2])
  92. gui:create(GUI.components.button)
  93.         :new('Кнопочка 3', 22, 1, 18):draw()
  94.         :on('touch',actions[3])
  95.  
  96. -- gpu.fill(2,2,WIDTH-21,1,' ')
  97. -- gui:printBySymbol('Следуй за белым кроликом...',2,2)
  98.  
  99. gui:create(GUI.components.table)
  100.     :new(35,20,2,6)
  101.     -- :draw()
  102.     :setRows(items)
  103.     :drawRows()
  104.  
  105. itemSel = gui:create(GUI.components.itemSelector)
  106.     :new(37, 6, 39, 6)
  107.     :draw()
  108.  
  109.     -- gpu.set(3, 30, '₪ - Доступна переработка')
  110.     -- gpu.set(3, 31, '$ - Доступна продажа')
  111. local preventDefault = false
  112. function handleEvent(eventID,...)
  113.     local args = {...}
  114.     if eventID == 'touch'
  115.         or eventID == 'scroll' then
  116.         local action = gui.eventMatrix[args[2]][args[3]][eventID]
  117.         if action then
  118.             action(...)
  119.             preventDefault = true
  120.             return true
  121.         end
  122.        
  123.     elseif eventID == 'interrupted' then
  124.         gui:setBackground(defBG)
  125.             :setForeground(defFG)
  126.             :clear()
  127.        
  128.         os.exit()
  129.         return true
  130.    
  131.     elseif eventID == 'gui.table.select' then
  132.         itemSel.itemName = items[args[1]].name
  133.         itemSel:draw()
  134.    
  135.     elseif eventID == 'gui.table.deselect' then
  136.         itemSel.itemName = 'Выберите предмет из списка'
  137.         itemSel:draw()
  138.     end
  139.     -- print(eventID,...)
  140. end
  141.  
  142.  
  143. while 1 do
  144.     preventDefault = false
  145.     handleEvent(event.pull())
  146.  
  147.     -- if preventDefault==false then
  148.     --     gpu.fill(3,5,WIDTH-21,1,' ')
  149.     --     gui:printBySymbol('Следуй за белым кроликом...',3,5,true)
  150.     -- end
  151. end
  152.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement