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