-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogleME
128 lines (106 loc) · 3.5 KB
/
GoogleME
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
component = require("component")
term = require("term")
gpu = component.gpu
local width, height = gpu.getResolution()
serial=require("serialization")
local file=io.open("logme","r")
local text=file:read("*all")
tablo = serial.unserialize(text)
tabler = file
file:close()
linenumber = 1
aligner = function(text)
gpu.set(width / 2 - #text / 2, linenumber, text)
linenumber = linenumber+1
end
stringtofloat = function(numstr)
if #numstr <= 2 then
numstr = tostring(numstr..".0")
else
punktcheck = string.sub(numstr, #numstr-1, #numstr-1)
if punktcheck ~= "." then
numstr = tostring(numstr..".0")
end
end
return tonumber(numstr)
end
searchme = function(eingabe)
returncounter = 0
if string.find(eingabe, ":") then
searchparam = "name"
else if string.sub(eingabe,1 ,6) == "label=" then
eingabe = string.sub(eingabe, 7, #eingabe)
searchparam = "label"
else if string.sub(eingabe, 1, 5) == "size=" then
eingabe = stringtofloat(string.sub(eingabe, 6, #eingabe))
searchparam = "size"
else if string.sub(eingabe, 1, 7) == "damage=" then
eingabe = stringtofloat(string.sub(eingabe, 8, #eingabe))
searchparam = "damage"
else if string.sub(eingabe, 1, 10) == "maxDamage=" then
eingabe = stringtofloat(string.sub(eingabe, 11, #eingabe))
searchparam = "maxDamage"
else if string.sub(eingabe, 1, 7) == "hasTag=" then
eingabe = string.sub(eingabe, 8, #eingabe)
if eingabe == "true" then
eingabe = true
else
eingabe = false
end
searchparam = "hasTag"
else if string.sub(eingabe, 1, 12) == "isCraftable=" then
eingabe = string.sub(eingabe, 13, #eingabe)
if eingabe == "true" then
eingabe = true
else
eingabe = false
end
searchparam = "isCraftable"
else
searchparam = "find"
eingabe = eingabe
end
end
end
end
end
end
end
for anzahl,itemtab in pairs(tablo) do
if anzahl ~= "n" then
if searchparam == "find" then
for info, infodetail in pairs(itemtab) do
if string.find(tostring(infodetail),eingabe) then
returncounter = returncounter+1
print("["..returncounter.."]")
os.sleep(1.4)
itemtab["aspects"] = nil -------- will remove aspects from printing
for info2, infodetail2 in pairs(itemtab) do
print(" "..info2.." : "..tostring(infodetail2))
end
end
end
else
if itemtab[searchparam] == eingabe then
returncounter = returncounter+1
print("["..returncounter.."]")
os.sleep(1.4)
itemtab["aspects"] = nil -------- will remove aspects from printing
for info, infodetail in pairs(itemtab) do
print(" "..info.." : "..tostring(infodetail))
end
end
end
else
return returncounter
end
end
end
while true do
term.setCursor(width/2-9, height/2)
term.write("GoogleME : ")
inputbar = io.read()
print(searchme(tostring(inputbar)))
io.read()
term.clear()
end