levshx

TrapXataold

Oct 15th, 2020 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.18 KB | None | 0 0
  1. ------- SOFT PRIVATED -------
  2. -- Do not use this code --
  3. ---------by levshx-----------
  4.  
  5. local text = require("Text")
  6. local internet = require("Internet")
  7. local json = require("JSON")
  8. local fs = require("Filesystem")
  9. local bigLetters = require("bigLetters")
  10. local screen = require("Screen")
  11. local image = require("Image")
  12. local GUI = require("GUI")
  13. local system = require("System")
  14. local paths = require("Paths")
  15. local event = require("Event")
  16.  
  17. chatEnabled = true
  18.  
  19. local chatbox = component.get("chat_box")
  20. local meController = component.get("me_controller")
  21. local meInterface = component.get("me_interface")
  22. local glasses = component.get("openperipheral_bridge")
  23. chatbox.setName("L] §f[§aTrap§dХата§f")
  24.  
  25. -- Тестовый полигон
  26.  
  27. -- конец полигона
  28.  
  29. function getCountOfItemME(name)
  30. local filter = {}
  31. filter["name"] = name
  32. local itemTable = meController.getItemsInNetwork(filter)
  33. if itemTable["n"] > 0 then
  34. return itemTable[1].size -- name, size, label
  35. else
  36. return 0
  37. end
  38. end
  39.  
  40. function startAutocraftME(name, count)
  41. local fingerprint = {}
  42. local itemTable = meInterface.getAvailableItems()
  43. for i = 1, #itemTable do
  44. if itemTable[i].fingerprint.id == name then
  45. if itemTable[i].is_craftable then
  46. fingerprint = itemTable[i].fingerprint
  47.  
  48. meInterface.requestCrafting(fingerprint, count, nil)
  49. chatbox.say("§3Автокрафт: §f"..name.." "..count.. " шт. запрос отправлен")
  50. break
  51. else
  52. chatbox.say("§fПредмет §3"..name.." §fнайден, но автокрафт отсутствует")
  53. end
  54. end
  55. if ((i==#itemTable) and (fingerprint=={})) then
  56. chatbox.say("§fПредмет §3"..name.." §fне найден, его автокрафт тоже")
  57. end
  58. end
  59. end
  60.  
  61.  
  62. event.interruptingEnabled = false
  63.  
  64. local peopleChat = {
  65. levshx = true,
  66. bng = true,
  67. Ians = true,
  68. Sky_jump = true,
  69. ziabl = true,
  70. Sun40 = true,
  71. Dev1lroot = true
  72. }
  73.  
  74.  
  75. local currentScriptDirectory = fs.path(system.getCurrentScript())
  76. local version = 2
  77. local systemPassword = "девиллох"
  78.  
  79.  
  80. local peoples = fs.readTable(paths.user.applicationData.."TrapHata/Owners.txt")
  81.  
  82. -- Fucking minecraft
  83. ---------------------------------------------------------------------------------
  84. -- workspace
  85. local workspace = GUI.workspace()
  86. workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))
  87.  
  88. -- Create horizontally oriented list
  89. local horizontalList = workspace:addChild(GUI.list(20, 2, workspace.width-40, 3, 2, 0, 0xE1E1E1, 0x4B4B4B, 0xE1E1E1, 0x4B4B4B, 0x696969, 0xFFFFFF, true))
  90. horizontalList:setDirection(GUI.DIRECTION_HORIZONTAL)
  91. horizontalList:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
  92.  
  93. horizontalList:addItem("Trap-Хата").onTouch = function()
  94. containerAbout.hidden = false
  95. containerPeoples.hidden = true
  96. containerResources.hidden = true
  97. containerSystem.hidden = true
  98.  
  99.  
  100. workspace:draw()
  101. end
  102.  
  103. horizontalList:addItem("Ресурсы").onTouch = function()
  104. containerAbout.hidden = true
  105. containerPeoples.hidden = true
  106. containerResources.hidden = false
  107. containerSystem.hidden = true
  108.  
  109.  
  110. workspace:draw()
  111. end
  112.  
  113. horizontalList:addItem("Общество").onTouch = function()
  114. containerAbout.hidden = true
  115. containerPeoples.hidden = false
  116. containerResources.hidden = true
  117. containerSystem.hidden = true
  118.  
  119. workspace:draw()
  120. end
  121.  
  122. horizontalList:addItem("Система").onTouch = function()
  123. containerAbout.hidden = true
  124. containerPeoples.hidden = true
  125. containerResources.hidden = true
  126. containerSystem.hidden = false
  127.  
  128. workspace:draw()
  129. end
  130.  
  131.  
  132.  
  133. --------------------------------------------------------------------------------
  134. -- about TRAP HATA
  135. -- container with information about TRAP HATA
  136. containerAbout = workspace:addChild(GUI.container(1, 7, workspace.width-2, workspace.height-9))
  137. containerAbout:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))
  138.  
  139. containerAbout:addChild(GUI.image(24, 2, image.load(currentScriptDirectory.."Icons/banner.pic")))
  140. containerAbout:addChild(GUI.text(34, 20, 0xFFFFFF, "Версия TrapХата: "..version))
  141.  
  142. containerAbout:addChild(GUI.text(34, 22, 0xFFFFFF, "ЧатБот: "))
  143. aw
  144. local switchChatBot = containerAbout:addChild(GUI.switch(45, 22, 8, 0x66DB80, 0x1D1D1D, 0xEEEEEE, true))
  145.  
  146. --------------------------------------------------------------------------------
  147. -- Resources
  148.  
  149. containerResources = workspace:addChild(GUI.container(15, 7, workspace.width-30, workspace.height-9))
  150. containerResources:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))
  151.  
  152. containerResources:addChild(GUI.image(25, 1, image.load(currentScriptDirectory.."Icons/MainResources.pic")))
  153.  
  154. local IngotCount = containerResources:addChild(GUI.text(48, 4, 0xFFFFFF, "Железо: "..getCountOfItemME("minecraft:iron_ingot")))
  155. local MatterCount = containerResources:addChild(GUI.text(48, 14, 0xFFFFFF, "Материя: "..getCountOfItemME("dwcity:Materia")))
  156.  
  157. containerResources:addChild(GUI.text(25, 20, 0xFFFFFF, "Список ресурсов МЭ синхронизирован"))
  158. containerResources:addChild(GUI.text(25, 21, 0xFFFFFF, "с логгером и сервером"))
  159.  
  160. -- тут ещё дохуя дел так-то по факту разобраться в МЭ API ёбаном
  161.  
  162. --------------------------------------------------------------------------------
  163. -- Peoples
  164. containerPeoples = workspace:addChild(GUI.container(15, 7, workspace.width-30, workspace.height-9))
  165. containerPeoples:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x0a00ff))
  166.  
  167. -- Как сохранять и куда сохранять списки Людей и что это даёт и для чего))
  168.  
  169. --------------------------------------------------------------------------------
  170. -- System
  171. containerSystem = workspace:addChild(GUI.container(15, 7, workspace.width-30, workspace.height-9))
  172. containerSystem:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0xff00ff))
  173.  
  174. containerResources.hidden = true
  175. containerPeoples.hidden = true
  176. containerSystem.hidden = true
  177.  
  178. --системная хуита типа закрыть приложение и всё такое, чтобы не ибать мозгу
  179.  
  180.  
  181.  
  182.  
  183. local statHandler = event.addHandler(function()
  184. -- Do someting every 10
  185. local result, reason = internet.request("https://levshx.000webhostapp.com/loader.php?option=stat")
  186. if (result and result~="") then
  187. result = json.decode(result)
  188.  
  189. if result.request == "good" then
  190. if result.msgs > 0 then
  191. local resultMSG, reasonMSG = internet.request("https://levshx.000webhostapp.com/loader.php?option=getMSG")
  192. if (resultMSG and resultMSG~="") then
  193. resultMSG = json.decode(resultMSG)
  194. chatbox.say("§b"..resultMSG.nick..": §f"..resultMSG.msg)
  195. end
  196. end
  197.  
  198. if result.autocraft > 0 then
  199. local resultAutocraft, reasonAutocraft = internet.request("https://levshx.000webhostapp.com/loader.php?option=getAutocraft")
  200. if (resultAutocraft and resultAutocraft~="") then
  201. resultAutocraft = json.decode(resultAutocraft)
  202. startAutocraftME(resultAutocraft.item, resultAutocraft.count)
  203. end
  204. end
  205.  
  206. -- mds 3d
  207. else
  208. chatbox.say("§bFUCK§c > §aInternet")
  209. end
  210. else
  211. chatbox.say("§bFUCK§c > §aInternet")
  212. end
  213. end, 10)
  214.  
  215. local chatBotHandler = event.addHandler(function(e1, e2, e3, e4) --e2=uuid, e3=senderNick, e4=msg
  216. if e1 == "chat_message" then
  217. if peopleChat[e3]==true and switchChatBot.state==true then -- проверка на наличие в таблице чата
  218.  
  219. -- Do someting every Return key press
  220. msgBot = {
  221. ["ask"] = internet.encode(e4),
  222. ["userid"] = text.limit(e3.."1234", 12, "right"),
  223. ["key"] = ""
  224. }
  225. local result, reason = internet.request("https://aiproject.ru/api/", "query="..json.encode(msgBot))
  226. if (result and result~="") then
  227. result = json.decode(result)
  228. if result.aiml then
  229. chatbox.setName("L] §f[§aTrap§dХата §bБот§f")
  230. chatbox.say("§f"..result.aiml)
  231. chatbox.setName("L] §f[§aTrap§dХата§f")
  232. end
  233. end
  234.  
  235. end
  236. end
  237. end)
  238.  
  239.  
  240. local resourceHandler = event.addHandler(function()
  241. IngotCount.text = "Железо: "..getCountOfItemME("minecraft:iron_ingot")
  242. MatterCount.text = "Материя: "..getCountOfItemME("dwcity:Materia")
  243. workspace:draw()
  244. end, 10)
  245.  
  246.  
  247. local function time()
  248. local f = fs.open("/Temporary/TF","w")
  249. f:write("test")
  250. f:close()
  251. return(fs.lastModified("/Temporary/TF"))
  252. end
  253.  
  254.  
  255. local glassesHandler = event.addHandler(function()
  256.  
  257. glasses.clear()
  258. glasses.addBox(4,23 , 100 , 250, 0x000000,0.3)
  259. glasses.addText(5,25,"§aTrap§dХата §fProject")
  260. glasses.addText(5,36,"§aInfoPanel")
  261.  
  262. glasses.sync()
  263.  
  264. end, 10)
  265. ------------------------------------------------
  266.  
  267. -- Draw changes on screen after customizing your window
  268.  
  269. workspace:draw()
  270. workspace:start()
Add Comment
Please, Sign In to add comment