View difference between Paste ID: 1Z0ayVSR and nCN4nL7A
SHOW: | | - or go back to the newest paste.
1
local version = "3.0 - Openperipheral relesase"
2
local function os_start()
3
if fs.exists("openperipheral.conf") then
4
glassc = fs.open("openperipheral.conf", "r")
5
gls = glassc.readLine()
6
glass = peripheral.wrap(gls)
7
glassc.close()
8
glass.clear()
9
else
10
asd = "iii"
11
end
12
--GUI
13
slc = 0
14
--tde-paint:
15
local function painter()
16
term.setBackgroundColor(colors.blue)
17
term.clear()
18
term.setBackgroundColor(colors.black)
19
term.setCursorPos(1,1)
20
write("   Painter                                          ")
21
term.setTextColor(colors.white)
22
term.setBackgroundColor(colors.blue)
23
--program
24
print("Choise slot for paint")
25
print("1")
26
print("2")
27
print("3")
28
print("4")
29
print("5 - desktop image")
30
write(">")
31-
              shell.run("tde-desktop")
31+
32
if var == "1" then
33
 shell.run("paint /tde/paint/1")
34
  elseif var == "2" then
35
    shell.run("paint /tde/paint/2")
36
     elseif var == "3" then
37
       shell.run("paint /tde/paint/3")
38
        elseif var == "4" then
39
         shell.run("paint /tde/paint/4")
40
          elseif var == "5" then
41
            shell.run("paint /wallpaper")
42
              os_start()
43
          else
44
           painter()
45
  end
46
end
47
--tde-redstone:
48
tBarC = 8
49
tBartC = 1
50
local function redsbskg()
51
backColor = colors.pink
52
term.setBackgroundColor(backColor)
53
term.clear()
54
end
55
function RedGui()
56
redsbskg()
57
redstonegui = paintutils.loadImage("/tde/redstone.png")
58
paintutils.drawImage(redstonegui, 0, 0)
59
term.setCursorPos(1, 19)
60
write("(C) tima_gt 2013-2014 GNU GPL project         ")
61
term.setCursorPos(1, 2)
62
write("Active redstone")
63
term.setCursorPos(1, 15)
64
write("DeActive redstone")
65
term.setCursorPos(50, 1)
66
write("X")
67
68
asd = true
69
while asd == true do
70
local event, button, X, Y = os.pullEventRaw()
71
  if slc == 0 then
72
    if event == "mouse_click" then
73
      if X >=1 and X <=17 and Y >=3 and Y <=5 and button ==1 then slc = 0
74
      redstone.setOutput("back", true)
75
       elseif X >=1 and X <=17 and Y >=14 and Y <=18 and button ==1 then slc = 0
76
      redstone.setOutput("back", false)
77
       elseif X ==50 and Y ==1 and button ==1 then slc = 0
78
        asd = false
79
         shell.run("tde-desktop")
80
        else
81
        RedGui()
82
    end
83
  end
84
end
85
end
86
end
87
--tde-terminal:
88-
write("   Terminal                                          ")
88+
89-
term.setTextColor(colors.black)
89+
 term.setTextColor(colors.white)
90
 term.setBackgroundColor(colors.black)
91
 term.clear()
92
end
93
local function tde_terminal()
94
term.setBackgroundColor(colors.black)
95
term.setTextColor(colors.white)
96
term.clear()
97
term.setCursorPos(1, 1)
98
write("For exit write exit")
99
trues = true
100
local xter yter = term.getCursorPos()
101
term.setCursorPos(1,3)
102
while trues == true do
103
if xter == 1 and yter == 1 then
104
term.setCursorPos(1, 2)
105
end 
106
write(">")
107
command = read()
108-
      term.setBackgroundColor(colors.white)
108+
109-
      term.setTextColor(colors.black)
109+
110-
      elseif command == "edit" then
110+
111
 term.setTextColor(colors.black)
112
 term.clear()
113
 trues = false
114-
   sleep(1)
114+
115-
   restoretext()
115+
116
    shell.run(command)
117
      elseif command == "luaide" then
118
        shell.run("pastebin run vyAZc6tJ")
119
  else
120
   shell.run(command)
121
    end
122
  end
123
end
124
--applications app:
125
local function app_color()
126
backColor = colors.white
127
term.setBackgroundColor(backColor)
128
term.clear()
129
end
130
--functions|
131
--         V
132
local function applicationslist()
133
if fs.exists("openperipheral.conf") then
134
glass.clear()
135
apps = glass.addBox(3, 3, 100, 10, 0x0, 0.7)
136
appstext = glass.addText(30, 3, "applications", 0xFFFFFF)
137
end
138
applist = paintutils.loadImage("/tde/program")
139
paintutils.drawImage(applist, 2, 2)
140
term.setCursorPos(4, 18)
141
write("   Back  ")
142
term.setCursorPos(3, 5)
143
write(">_")
144
end
145
146
--button-home-touch= [Y1=16 X1=1] [Y1=18 X2=14]
147
--terminal-touch= [Y1=1 X1=1] [Y2=5 X2=9]
148
--redstone-touch= [Y1=1 X1=11] [Y2=5 X2=20]
149
--pictures-touch= [Y1=1 X1=23] [Y2=5 X2=31]
150-
       shell.run("tde-desktop")
150+
151
local function whiletruedoapp()
152-
        shell.run("tde-desktop")
152+
153
local event, button, X, Y = os.pullEventRaw()
154
  if slc == 0 then
155-
           shell.run("tde-desktop")
155+
156
      if X >=1 and X <=14 and Y >=16 and Y <=19 and button ==1 then slc = 0
157
      shell.run("tde-desktop")
158-
              shell.run("tde-desktop")
158+
159
       tde_terminal()
160
       term.setTextColor(colors.white)
161
         elseif X >=12 and X <=21 and button == 1 and Y >=2 and Y <=6 then slc = 0
162
          RedGui()
163
            elseif X >=24 and X <=32 and button == 1 and Y >=2 and Y <=6 then slc = 0
164-
                    shell.run("tde-desktop")
164+
165
               --elseif X >=27 and X<=46 and button == 1 and Y >=2 and Y <=7 then slc = 0
166
                --shell.run("/ccYoutube") not working yet
167
                 shell.run("pastebin run nCN4nL7A")
168
                  elseif X >=2 and X <=14 and Y >=8 and Y <=14 and button == 1 then slc = 0
169
                   shell.run("pastebin run vyAZc6tJ")
170
                    vaa = read()
171
                    if vaa == "1" then
172
                    os.sleep(1)
173
                    end
174
        else
175
        applicationslist()
176
      end
177
    end
178
  end
179
 end
180
end
181
182
--tde-desktop
183
local function fixtext()
184
term.setTextColor(colors.white)
185
end
186
187
local function desktop()
188
--glass support
189
if fs.exists("openperipheral.conf") then
190
glass.clear()
191
menu = glass.addBox(2, 2, 40, 13, 0x000, 0.7)
192
menutext = glass.addText(12, 5, "[Menu]", 0xFFFFFF)
193
end
194
--image fixer
195
term.setBackgroundColor(colors.white)
196
term.clear()
197
--indicators
198
term.setBackgroundColor(colors.black)
199
term.setCursorPos(1, 1)
200
write("[   Menu   ]                                    ")
201
write("                                                   ")
202
--Desktop image
203
image = paintutils.loadImage("wallpaper")
204
paintutils.drawImage(image, 1, 2)
205
term.setCursorPos(1, 1)
206
end
207
208
209
function tmenu()
210
term.setBackgroundColor(colors.black)
211
term.setCursorPos(1,2)
212
print("Applications")
213
term.setCursorPos(1,3)
214
print("  Shutdown  ")
215
term.setCursorPos(1,4)
216
print("  Restart   ")
217
term.setCursorPos(1,5)
218
print("  Settings  ")
219
term.setCursorPos(1,6)
220
print("   LogOut   ")
221
end
222
223
fixtext()
224
desktop()
225-
app_color()
225+
226
local event, button, X, Y = os.pullEventRaw()
227-
whiletruedoapp()
227+
228
    if event == "mouse_click" then
229
      if X >=2 and X <=12 and Y==1 and button ==1 then
230
      slc = 1
231
      tmenu()
232
        elseif X>=2 and X <=12 and Y==1 and button ==1 then
233-
       shell.run("pastebin run CcHLkdUT")
233+
234
        else
235
        desktop()
236
      end
237
     end
238
   elseif slc == 1 then
239
     if X>=1 and X<=12 and Y==2 and button ==1 then slc = 0
240-
     end
240+
     app_color()
241
      applicationslist()
242
       whiletruedoapp()
243
      elseif X>=1 and X<=12 and Y==5 and button ==1 then slc = 0
244
      shell.run("setup")
245
      term.setTextColor(colors.white)
246
       elseif X >=1 and X <=12 and button == 1 and Y== 3 then slc = 0
247
       if fs.exists("openperipheral.conf") then
248
       glass.clear()
249
       end
250
       os.shutdown()
251
       elseif X>=1 and X<=12 and Y==4 and button ==1 then slc = 0
252
       if fs.exists("openperipheral.conf") then
253
       glass.clear()
254
       end
255
       os.reboot()
256
       elseif X>=1 and X<=12 and Y==6 and button ==1 then slc = 0
257
       if fs.exists("openperipheral.conf") then
258
       glass.clear()
259
       local time = os.time()
260
       time = textutils.formatTime(time, false)
261
       glass.addBox(3, 3, 200, 100, 0xfff, 0.5)
262
       glass.addText(4, 3, "computer is locked!", 0xFFFFFF)
263
       end
264
       term.setBackgroundColor(colors.blue)
265
 while true do
266
  local time = os.time()
267
  time = textutils.formatTime(time, false)
268
  term.clear()
269
  term.setCursorPos(1, 2)
270
  print("locked at ",time, ", press any key to unlock")
271
  local sEvent, param= os.pullEvent("key")
272
  if sEvent == "key" then
273
   break
274
  end
275
 end
276
       elseif X>=1 and X<=12 and Y==6 and button ==1 and fs.exists(".user") then slc = 0
277
       if fs.exists("openperipheral.conf") then
278
       glass.clear()
279
       local time = os.time()
280
       time = textutils.formatTime(time, false)
281
       glass.addBox(3, 3, 200, 100, 0xfff, 0.5)
282
       glass.addText(4, 3, "computer is locked!", 0xFFFFFF)
283
       end
284
       shell.run("tde-register")
285
       else
286
       slc = 0
287
       desktop()
288
       end
289
       shell.run("tde-register")
290
291
        end
292
     end
293
end
294
if fs.exists("/.tde-root") then
295
openconf = fs.open("/.tde-root", "r")
296
configtext = openconf.readLine()
297
openconf.close()
298
if configtext == "nouser" then
299
os_start()
300
elseif configtext == "user" then
301
shell.run("tde-register")
302
os_start()
303
else
304
shell.run("rm /.tde-root")
305
term.setTextColor(colors.red)
306
print("Error: Out of free ram, reboot the PC!")
307
end
308
else
309
print("Hello, user, this is TDE ", version, "!")
310
print("do you want to register user?")
311
print("Y/n?")
312
write(">")
313
rootconf = read()
314
if (rootconf == "") or (rootconf == "y") or (rootconf == "Y") then
315
writeconfa = fs.open("/.tde-root", "w")
316
writeconfa.writeLine("user")
317
writeconfa.close()
318
shell.run("tde-register")
319
os_start()
320
elseif rootconf == "n" then
321
writeconf = fs.open("/.tde-root", "w")
322
writeconf.writeLine("nouser")
323
os_start()
324
else
325
os.sleep(1)
326
end
327
end