-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartPaste.lua
1943 lines (1897 loc) · 92.3 KB
/
SmartPaste.lua
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--check Firewolf installation
local fWolf = false
if browserAgent then
if browserAgent:find("Firewolf") then
fWolf = true
end
else
fWolf = false
end
--check for HTTP API
if not http then
print("Please enable the HTTP API within the ComputerCraft configuration.")
return
end
local devKey = "3575e50cc6635311078014a550bc3f9f"
local userKey = ""
local username = "TEMP_USER"
local password = "TEMP_PASSWORD"
local logged = false
local syntaxTab = {
menuNames = {
'4CS', '6502 ACME Cross Assembler','6502 Kick Assembler', '6502 TASM/64TASS',
'ABAP', 'ActionScript', 'ActionScript 3', 'Ada',
'ALGOL 68', 'Apache Log', 'AppleScript', 'APT Sources',
'ARM', 'ASM (NASM)', 'ASP', 'Asymptote',
'autoconf', 'Autohotkey', 'AutoIt', 'Avisynth',
'Awk', 'BASCOM AVR', 'Bash', 'Basic4GL',
'BibTeX', 'Blitz Basic', 'BNF', 'BOO',
'BrainFuck', 'C', 'C for Macs', 'C Intermediate Language',
'C#', 'C++', 'C++ (with QT extensions)', 'C: Loadrunner',
'CAD DCL', 'CAD Lisp', 'CFDG', 'ChaiScript',
'Clojure', 'Clone C', 'Clone C++', 'CMake',
'COBOL', 'CoffeeScript', 'ColdFusion', 'CSS',
'Cuesheet', 'D', 'DCL', 'DCPU-16',
'DCS', 'Delphi', 'Delphi Prism (Oxygene)', 'Diff',
'DIV', 'DOS', 'DOT', 'E',
'ECMAScript', 'Eiffel', 'Email', 'EPC',
'Erlang', 'F#', 'Falcon', 'FO Language',
'Formula One', 'Fortran', 'FreeBasic', 'FreeSWITCH',
'GAMBAS', 'Game Maker', 'GDB', 'Genero',
'Genie', 'GetText', 'Go', 'Groovy',
'GwBasic', 'Haskell', 'Haxe', 'HicEst',
'HQ9 Plus', 'HTML', 'HTML 5', 'Icon',
'IDL', 'INI file', 'Inno Script', 'INTERCAL',
'IO', 'J', 'Java', 'Java 5',
'JavaScript', 'jQuery', 'KiXtart', 'Latex',
'LDIF', 'Liberty BASIC', 'Linden Scripting', 'Lisp',
'LLVM', 'Loco Basic', 'Logtalk', 'LOL Code',
'Lotus Formulas', 'Lotus Script', 'LScript', 'Lua',
'M68000 Assembler', 'MagikSF', 'Make', 'MapBasic',
'MatLab', 'mIRC', 'MIX Assembler', 'Modula 2',
'Modula 3', 'Motorola 68000 HiSoft Dev','MPASM', 'MXML',
'MySQL', 'Nagios', 'newLISP', 'None',
'NullSoft Installer', 'Oberon 2', 'Objeck Programming Langua','Objective C',
'OCalm Brief', 'OCaml', 'Octave', 'OpenBSD PACKET FILTER',
'OpenGL Shading', 'Openoffice BASIC', 'Oracle 11', 'Oracle 8',
'Oz', 'ParaSail', 'PARI/GP', 'Pascal',
'PAWN', 'PCRE', 'Per', 'Perl',
'Perl 6', 'PHP', 'PHP Brief', 'Pic 16',
'Pike', 'Pixel Bender', 'PL/SQL', 'PostgreSQL',
'POV-Ray', 'Power Shell', 'PowerBuilder', 'ProFTPd',
'Progress', 'Prolog', 'Properties', 'ProvideX',
'PureBasic', 'PyCon', 'Python', 'Python for S60',
'q/kdb+', 'QBasic', 'R', 'Rails',
'REBOL', 'REG', 'Rexx', 'Robots',
'RPM Spec', 'Ruby', 'Ruby Gnuplot', 'SAS',
'Scala', 'Scheme', 'Scilab', 'SdlBasic',
'Smalltalk', 'Smarty', 'SPARK', 'SPARQL',
'SQL', 'StoneScript', 'SystemVerilog', 'T-SQL',
'TCL', 'Tera Term', 'thinBasic', 'TypoScript',
'Unicon', 'UnrealScript', 'UPC', 'Urbi',
'Vala', 'VB.NET', 'Vedit', 'VeriLog',
'VHDL', 'VIM', 'Visual Pro Log', 'VisualBasic',
'VisualFoxPro', 'WhiteSpace', 'WHOIS', 'Winbatch',
'XBasic', 'XML', 'Xorg Config', 'XPP',
'YAML', 'Z80 Assembler', 'ZXBasic'
},
urlCodes = {
'4cs', '6502acme', '6502kickass', '6502tasm',
'abap', 'actionscript', 'actionscript3', 'ada',
'algol68', 'apache', 'applescript', 'apt_sources',
'arm', 'asm', 'asp', 'asymptote',
'autoconf', 'autohotkey', 'autoit', 'avisynth',
'awk', 'bascomavr', 'bash', 'basic4gl',
'bibtex', 'blitzbasic', 'bnf', 'boo',
'bf', 'c', 'c_mac', 'cil',
'csharp', 'cpp', 'cpp-qt', 'c_loadrunner',
'caddcl', 'cadlisp', 'cfdg', 'chaiscript',
'clojure', 'klonec', 'klonecpp', 'cmake',
'cobol', 'coffeescript', 'cfm', 'css',
'cuesheet', 'd', 'dcl', 'dcpu16',
'dcs', 'delphi', 'oxygene', 'diff',
'div', 'dos', 'dot', 'e',
'ecmascript', 'eiffel', 'email', 'epc',
'erlang', 'fsharp', 'falcon', 'fo',
'f1', 'fortran', 'freebasic', 'freeswitch',
'gambas', 'gml', 'gdb', 'genero',
'genie', 'gettext', 'go', 'groovy',
'gwbasic', 'haskell', 'haxe', 'hicest',
'hq9plus', 'html4strict', 'html5', 'icon',
'idl', 'ini', 'inno', 'intercal',
'io', 'j', 'java', 'java5',
'javascript', 'jquery', 'kixtart', 'latex',
'ldif', 'lb', 'lsl2', 'lisp',
'llvm', 'locobasic', 'logtalk', 'lolcode',
'lotusformulas', 'lotusscript', 'lscript', 'lua',
'm68k', 'magiksf', 'make', 'mapbasic',
'matlab', 'mirc', 'mmix', 'modula2',
'modula3', '68000devpac', 'mpasm', 'mxml',
'mysql', 'nagios', 'newlisp', 'text',
'nsis', 'oberon2', 'objeck', 'objc',
'ocaml-brief', 'ocaml', 'octave', 'pf',
'glsl', 'oobas', 'oracle11', 'oracle8',
'oz', 'parasail', 'parigp', 'pascal',
'pawn', 'pcre', 'per', 'perl',
'perl6', 'php', 'php-brief', 'pic16',
'pike', 'pixelbender', 'plsql', 'postgresql',
'povray', 'powershell', 'powerbuilder', 'proftpd',
'progress', 'prolog', 'properties', 'providex',
'purebasic', 'pycon', 'python', 'pys60',
'q', 'qbasic', 'rsplus', 'rails',
'rebol', 'reg', 'rexx', 'robots',
'rpmspec', 'ruby', 'gnuplot', 'sas',
'scala', 'scheme', 'scilab', 'sdlbasic',
'smalltalk', 'smarty', 'spark', 'sparql',
'sql', 'stonescript', 'systemverilog', 'tsql',
'tcl', 'teraterm', 'thinbasic', 'typoscript',
'unicon', 'uscript', 'ups', 'urbi',
'vala', 'vbnet', 'vedit', 'verilog',
'vhdl', 'vim', 'visualprolog', 'vb',
'visualfoxpro', 'whitespace', 'whois', 'winbatch',
'xbasic', 'xml', 'xorg_conf', 'xpp',
'yaml', 'z80', 'zxbasic'
}
}
local logo = {[1]={[1]=0,[2]=0,[3]=128,[4]=128,[5]=128,[6]=128,[7]=128,[8]=128,[9]=128,[10]=128,[11]=128,[12]=128,[13]=128,[14]=128,[15]=128,[16]=128,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[2]={[1]=0,[2]=128,[3]=1,[4]=1,[5]=1,[6]=1,[7]=1,[8]=1,[9]=1,[10]=1,[11]=1,[12]=1,[13]=1,[14]=1,[15]=1,[16]=1,[17]=128,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[3]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=8,[6]=8,[7]=8,[8]=1,[9]=1,[10]=1,[11]=1,[12]=1,[13]=32,[14]=1,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[4]={[1]=128,[2]=1,[3]=1,[4]=8,[5]=1,[6]=1,[7]=1,[8]=8,[9]=1,[10]=1,[11]=1,[12]=32,[13]=32,[14]=32,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[5]={[1]=128,[2]=1,[3]=1,[4]=8,[5]=1,[6]=1,[7]=1,[8]=1,[9]=1,[10]=1,[11]=32,[12]=32,[13]=32,[14]=32,[15]=32,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[6]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=8,[6]=8,[7]=8,[8]=1,[9]=1,[10]=1,[11]=1,[12]=1,[13]=32,[14]=1,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[7]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,[7]=1,[8]=8,[9]=1,[10]=1,[11]=1,[12]=1,[13]=32,[14]=1,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[8]={[1]=128,[2]=1,[3]=1,[4]=8,[5]=1,[6]=1,[7]=1,[8]=8,[9]=1,[10]=1,[11]=1,[12]=1,[13]=1,[14]=1,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[9]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=8,[6]=8,[7]=8,[8]=1,[9]=1,[10]=1,[11]=2048,[12]=2048,[13]=2048,[14]=2048,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[10]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=1,[6]=1,[7]=1,[8]=1,[9]=1,[10]=1,[11]=2048,[12]=1,[13]=1,[14]=1,[15]=2048,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[11]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=1,[6]=2,[7]=1,[8]=1,[9]=1,[10]=1,[11]=2048,[12]=1,[13]=1,[14]=1,[15]=2048,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[12]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=1,[6]=2,[7]=1,[8]=1,[9]=1,[10]=1,[11]=2048,[12]=2048,[13]=2048,[14]=2048,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[13]={[1]=128,[2]=1,[3]=1,[4]=2,[5]=2,[6]=2,[7]=2,[8]=2,[9]=1,[10]=1,[11]=2048,[12]=1,[13]=1,[14]=1,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[14]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=2,[6]=2,[7]=2,[8]=1,[9]=1,[10]=1,[11]=2048,[12]=1,[13]=1,[14]=1,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[15]={[1]=128,[2]=1,[3]=1,[4]=1,[5]=1,[6]=2,[7]=1,[8]=1,[9]=1,[10]=1,[11]=2048,[12]=1,[13]=1,[14]=1,[15]=1,[16]=1,[17]=1,[18]=128,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[16]={[1]=0,[2]=128,[3]=1,[4]=1,[5]=1,[6]=1,[7]=1,[8]=1,[9]=1,[10]=1,[11]=1,[12]=1,[13]=1,[14]=1,[15]=1,[16]=1,[17]=128,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,},[17]={[1]=0,[2]=0,[3]=128,[4]=128,[5]=128,[6]=128,[7]=128,[8]=128,[9]=128,[10]=128,[11]=128,[12]=128,[13]=128,[14]=128,[15]=128,[16]=128,},}
local codec = {[1]={[1]=128,[2]=128,[3]=128,[4]=128,[5]=128,[6]=128,[7]=128,[8]=128,[9]=128,[10]=128,[11]=128,[12]=128,[13]=128,[14]=128,[15]=128,[16]=128,[17]=128,[18]=128,[19]=128,[20]=128,[21]=128,[22]=128,[23]=128,[24]=128,[25]=128,[26]=128,[27]=128,[28]=128,[29]=128,[30]=128,[31]=128,[32]=128,[33]=128,[34]=128,[35]=128,[36]=128,[37]=128,[38]=128,[39]=128,[40]=128,[41]=128,[42]=128,[43]=128,[44]=128,[45]=128,[46]=128,[47]=128,[48]=128,[49]=128,[50]=128,[51]=128,},[2]={[1]=128,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=128,[13]=32768,[14]=8192,[15]=32768,[16]=8192,[17]=8192,[18]=8192,[19]=8192,[20]=8192,[21]=8192,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=128,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=128,},[3]={[1]=128,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=128,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=1,[24]=1,[25]=32768,[26]=1,[27]=32768,[28]=1,[29]=32768,[30]=1,[31]=1,[32]=32768,[33]=32768,[34]=1,[35]=1,[36]=32768,[37]=1,[38]=1,[39]=1,[40]=128,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=128,},[4]={[1]=128,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=128,[13]=32768,[14]=8192,[15]=32768,[16]=8192,[17]=8192,[18]=8192,[19]=8192,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=1,[25]=32768,[26]=1,[27]=32768,[28]=1,[29]=32768,[30]=32768,[31]=1,[32]=32768,[33]=32768,[34]=32768,[35]=1,[36]=32768,[37]=32768,[38]=32768,[39]=1,[40]=128,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=128,},[5]={[1]=128,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=128,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=1,[25]=32768,[26]=1,[27]=1,[28]=1,[29]=32768,[30]=32768,[31]=1,[32]=32768,[33]=32768,[34]=32768,[35]=1,[36]=32768,[37]=1,[38]=1,[39]=1,[40]=128,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=128,},[6]={[1]=128,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=128,[13]=32768,[14]=8192,[15]=32768,[16]=8192,[17]=8192,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=1,[25]=32768,[26]=32768,[27]=32768,[28]=1,[29]=32768,[30]=32768,[31]=1,[32]=32768,[33]=32768,[34]=32768,[35]=1,[36]=32768,[37]=1,[38]=32768,[39]=32768,[40]=128,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=128,},[7]={[1]=128,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=128,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=1,[25]=32768,[26]=32768,[27]=32768,[28]=1,[29]=32768,[30]=32768,[31]=1,[32]=32768,[33]=1,[34]=32768,[35]=1,[36]=32768,[37]=1,[38]=1,[39]=1,[40]=128,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=128,},[8]={[1]=128,[2]=128,[3]=128,[4]=128,[5]=128,[6]=128,[7]=128,[8]=128,[9]=128,[10]=128,[11]=128,[12]=128,[13]=128,[14]=128,[15]=128,[16]=128,[17]=128,[18]=128,[19]=128,[20]=128,[21]=128,[22]=128,[23]=128,[24]=128,[25]=128,[26]=128,[27]=128,[28]=128,[29]=128,[30]=128,[31]=128,[32]=128,[33]=128,[34]=128,[35]=128,[36]=128,[37]=128,[38]=128,[39]=128,[40]=128,[41]=128,[42]=128,[43]=128,[44]=128,[45]=128,[46]=128,[47]=128,[48]=128,[49]=128,[50]=128,[51]=128,},[9]={[1]=32768,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=32768,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=32768,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=32768,},[10]={[1]=32768,[2]=256,[3]=256,[4]=256,[5]=256,[6]=256,[7]=256,[8]=256,[9]=256,[10]=256,[11]=256,[12]=256,[13]=256,[14]=256,[15]=256,[16]=256,[17]=256,[18]=256,[19]=256,[20]=256,[21]=256,[22]=256,[23]=256,[24]=256,[25]=256,[26]=256,[27]=256,[28]=256,[29]=256,[30]=256,[31]=256,[32]=256,[33]=256,[34]=256,[35]=256,[36]=256,[37]=256,[38]=256,[39]=256,[40]=256,[41]=256,[42]=256,[43]=256,[44]=256,[45]=256,[46]=256,[47]=256,[48]=256,[49]=256,[50]=256,[51]=32768,},[11]={[1]=32768,[2]=256,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=32768,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=32768,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=256,[51]=32768,},[12]={[1]=32768,[2]=256,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=32768,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=32768,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=256,[51]=32768,},[13]={[1]=32768,[2]=256,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=32768,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=32768,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=256,[51]=32768,},[14]={[1]=32768,[2]=256,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=32768,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=32768,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=256,[51]=32768,},[15]={[1]=32768,[2]=256,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=32768,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=32768,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=256,[51]=32768,},[16]={[1]=32768,[2]=256,[3]=256,[4]=256,[5]=256,[6]=256,[7]=256,[8]=256,[9]=256,[10]=256,[11]=256,[12]=256,[13]=256,[14]=256,[15]=256,[16]=256,[17]=256,[18]=256,[19]=256,[20]=256,[21]=256,[22]=256,[23]=256,[24]=256,[25]=256,[26]=256,[27]=256,[28]=256,[29]=256,[30]=256,[31]=256,[32]=256,[33]=256,[34]=256,[35]=256,[36]=256,[37]=256,[38]=256,[39]=256,[40]=256,[41]=256,[42]=256,[43]=256,[44]=256,[45]=256,[46]=256,[47]=256,[48]=256,[49]=256,[50]=256,[51]=32768,},[17]={[1]=32768,[2]=32768,[3]=32768,[4]=32768,[5]=32768,[6]=32768,[7]=32768,[8]=32768,[9]=32768,[10]=32768,[11]=32768,[12]=32768,[13]=32768,[14]=32768,[15]=32768,[16]=32768,[17]=32768,[18]=32768,[19]=32768,[20]=32768,[21]=32768,[22]=32768,[23]=32768,[24]=32768,[25]=32768,[26]=32768,[27]=32768,[28]=32768,[29]=32768,[30]=32768,[31]=32768,[32]=32768,[33]=32768,[34]=32768,[35]=32768,[36]=32768,[37]=32768,[38]=32768,[39]=32768,[40]=32768,[41]=32768,[42]=32768,[43]=32768,[44]=32768,[45]=32768,[46]=32768,[47]=32768,[48]=32768,[49]=32768,[50]=32768,[51]=32768,},}
--check for arguments
local function usage()
print("Usage:")
print(shell.getRunningProgram().." <get> <pastebin code> <save file> [username]")
print(shell.getRunningProgram().." <put> <save file> [username]")
print("Required: < >")
print("Optional: [ ]")
end
local tArgs = {...}
if #tArgs >= 2 and #tArgs <= 4 then
if tArgs[1] == "get" then
print("Retrieving from url: http://pastebin.com/"..tArgs[2])
print("Saving to file: "..tArgs[3])
if #tArgs[2] > 8 or #tArgs[2] < 8 then
print("Invalid Pastebin code!")
return
else
print("Connecting to Pastebin...")
local site = http.get("http://pastebin.com/raw.php?i="..tArgs[2])
if not site then
print("Unable to connect to Pastebin!")
return
else
print("Connected! Reading url contents...")
local siteContent = site.readAll()
if not fs.exists(tArgs[3]) then
local file = fs.open(tArgs[3], "w")
file.write(siteContent)
file.close()
print("Download complete! Saved as '"..tArgs[3].."'")
return
else
print("File already exists!")
return
end
end
end
elseif tArgs[1] == "put" then
local badResponses = {
"Bad API request, IP blocked",
"Bad API request, api_paste_code was empty",
"Bad API request, maximum paste file size exceeded"
}
if not fs.exists(tArgs[2]) then
print("No file exists!")
return
else
if not tArgs[3] then
print("Reading file...")
local file = fs.open(tArgs[2], "r")
local postText = file.readAll()
file.close()
local postName = tArgs[2]
local response = http.post(
"http://pastebin.com/api/api_post.php",
"api_option=paste&"..
"api_dev_key="..devKey.."&"..
"api_paste_format=lua&"..
"api_paste_name="..textutils.urlEncode(postName).."&"..
"api_paste_code="..textutils.urlEncode(postText)
).readAll()
if response then
for i = 1, #badResponses do
if response == badResponses[i] then
print(badResponses[i])
return
else
print("Save successful! File stored at:\n"..response)
return
end
end
else
print("Unable to connect to Pastebin! Please try again.")
end
else
print("Using private authentication. Password required!")
write("Password: ")
local password = read("*")
local response = http.post(
"http://pastebin.com/api/api_login.php",
"api_dev_key="..devKey.."&"..
"api_user_name="..textutils.urlEncode(tArgs[3]).."&"..
"api_user_password="..textutils.urlEncode(password)
).readAll()
local badRequests = {
"Bad API request, invalid login",
"Bad API request, account not active"
}
if response == badRequests[1] then
print("Invalid login!")
return
elseif response == badRequests[2] then
print("Inactive account!")
return
else
local userKey = response
print("Reading file...")
local file = fs.open(tArgs[2], "r")
local postText = file.readAll()
file.close()
local postName = tArgs[2]
local response = http.post(
"http://pastebin.com/api/api_post.php",
"api_option=paste&"..
"api_dev_key="..devKey.."&"..
"api_user_key="..userKey.."&"..
"api_paste_format=lua&"..
"api_paste_private=0&"..
"api_paste_name="..textutils.urlEncode(postName).."&"..
"api_paste_code="..textutils.urlEncode(postText)
).readAll()
if response then
for i = 1, #badResponses do
if response == badResponses[i] then
print(badResponses[i])
return
else
print("Save successful! File stored at:\n"..response)
return
end
end
else
print("Unable to connect to Pastebin! Please try again.")
end
end
end
end
else
usage()
return
end
end
--Throw relevant errors
local x,y = term.getSize()
if turtle or not term.isColor() or x ~= 51 and y ~= 19 then
print("Please run this program from commandline prompts.")
usage()
return
end
local function checkCode()
local kCode = {200, 200, 208, 208, 203, 205, 203, 205, 48, 30, 28}
local extraCode = {200, 200, 208, 208, 203, 205, 203, 205, "b", "a", 28}
local eventTab = {"key", "key", "key", "key", "key", "key", "key", "key", "char", "char", "key"}
local code = false
local index = 1
while true do
local events = {os.pullEvent()}
--[[for i = 1, #events do
term.setCursorPos(20, 5 + i)
write(events[i].." / "..i.. " / "..index)
sleep(1)
end]]
sleep(0)
if index == #kCode then
code = true
term.setCursorPos(7,2)
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.red)
write("Code entry successful")
break
else
code = false
end
if events[1] == "char" then
if events[2] == kCode[index] or events[2] == extraCode[index] then
index = index + 1
else
code = false
break
end
elseif events[1] == "key" then
if events[2] == kCode[index] or events[2] == extraCode[index] then
index = index + 1
else
code = false
break
end
elseif events[1] ~= "key" and events[1] ~= "char" then
os.queueEvent(unpack(events))
break
end
end
return code
end
local function unlock()
paintutils.drawImage(codec, 1, 3)
for i = 3, 10 do
term.setTextColor(colors.lightGray)
term.setBackgroundColor(colors.black)
term.setCursorPos(1, i)
write("|")
term.setCursorPos(12, i)
write("|")
term.setCursorPos(40, i)
write("|")
term.setCursorPos(51, i)
write("|")
term.setCursorPos(1, i)
write(i == 3 and "+"..string.rep("-", 10).."+"..string.rep("-", 27).."+"..string.rep("-", 10).."+" or i == 10 and "+"..string.rep("-", 10).."+"..string.rep("-", 27).."+"..string.rep("-", 10).."+" or "")
end
for i = 12, 18 do
term.setTextColor(colors.lightGray)
term.setBackgroundColor(colors.black)
term.setCursorPos(2, i)
write(i == 12 and "+"..string.rep("-", 47).."+" or i == 18 and "+"..string.rep("-", 47).."+" or "|")
term.setCursorPos(50, i)
write("|")
end
local talking = true
local function static()
while talking do
local staticColors = {
colors.white,
colors.gray,
colors.black,
colors.lightGray}
for i = 2, 11 do
for k = 4, 9 do
local cx, cy = term.getCursorPos()
term.setCursorPos(i, k)
term.setBackgroundColor(staticColors[math.random(1,4)])
write(" ")
term.setCursorPos(cx, cy)
term.setBackgroundColor(colors.black)
end
end
for i = 41, 50 do
for k = 4, 9 do
local cx, cy = term.getCursorPos()
term.setCursorPos(i, k)
term.setBackgroundColor(staticColors[math.random(1,4)])
write(" ")
term.setCursorPos(cx, cy)
term.setBackgroundColor(colors.black)
end
end
sleep(.01)
end
end
local function writeText()
local chatTab = {
{"Unknown voice 1: The user has found the",
" backdoor. Shall I terminate the connection",
" to the server?"},
{"Unknown voice 2: No. Their diligence has paid",
" off. Give them more tests. Scatter them",
" throughout cyberspace. Let's see if they",
" can find all of the clues."},
{"Unknown voice 1: Understood sir."}
}
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
for i = 1, #chatTab do
for k = 1, #chatTab[i] do
term.setCursorPos(4, 12 + k)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
textutils.slowWrite(chatTab[i][k], 10)
end
sleep(2)
for v = 13, 17 do
paintutils.drawLine(3, v, 49, v, colors.black)
end
end
talking = false
end
parallel.waitForAll(static, writeText)
sleep(1)
background()
end
-- limit read function
local function limitRead(limX, rChar)
local origX, origY = term.getCursorPos()
term.setBackgroundColor(colors.white)
term.setTextColor(colors.blue)
term.setCursorPos(origX, origY)
term.setCursorBlink(true)
local returnString = ""
while true do
local xPos, yPos = term.getCursorPos()
local events = {os.pullEvent()}
if events[1] == "char" then
returnString = returnString..events[2]
if not rChar then
if not limX then
term.setTextColor(colors.blue)
write(events[2])
else
if string.len(returnString) >= limX then
term.setTextColor(colors.blue)
term.setCursorPos(origX, origY)
write(string.sub(returnString, (string.len(returnString)-limX)+1))
elseif string.len(returnString) < limX then
term.setTextColor(colors.blue)
write(events[2])
end
end
else
if not limX then
term.setTextColor(colors.blue)
write(rChar)
else
if string.len(returnString) >= limX then
term.setTextColor(colors.blue)
term.setCursorPos(origX, origY)
write(string.rep(rChar, limX))
elseif string.len(returnString) < limX then
term.setTextColor(colors.blue)
write(rChar)
end
end
end
elseif events[1] == "key" and events[2] == 14 then --backspace
returnString = string.sub(returnString, 1, (string.len(returnString))-1)
term.setCursorPos(xPos-1,yPos)
term.setTextColor(colors.blue)
write(" ")
term.setCursorPos(origX, origY)
if string.len(returnString) >= limX then
if not rChar then
term.setTextColor(colors.blue)
write(string.sub(returnString, (string.len(returnString)-limX)+1))
else
term.setTextColor(colors.blue)
write(string.rep(rChar,limX))
end
else
if not rChar then
term.setTextColor(colors.blue)
write(returnString)
else
term.setTextColor(colors.blue)
write(string.rep(rChar, string.len(returnString)))
end
end
elseif events[1] == "key" and events[2] == 28 then --enter
break
elseif events[1] == "mouse_click" and events[2] == 1 then
if events[3] >= 15 and events[3] <= 19 and events[4] == 13 and login == true then --"login"
break
elseif events[3] >= 30 and events[3] <= 35 and events[4] == 13 and login == true then --"cancel"
returnString = "EXIT LOGIN"
break
elseif events[3] >= 21 and events[3] <= 28 and events[4] == 11 and downloading == true then --download(not logged)
os.queueEvent(unpack(events))
break
elseif events[3] >= 1 and events[3] <= 5 and events[4] == 2 then
returnString = login and "EXIT LOGIN" or ""
os.queueEvent(unpack(events))
break
elseif events[3] >= 21 and events[3] <= 24 and events[4] == 2 then
returnString = login and "EXIT LOGIN" or ""
os.queueEvent(unpack(events))
break
elseif events[3] >= 28 and events[3] <= 31 and events[4] == 2 then
returnString = login and "EXIT LOGIN" or ""
os.queueEvent(unpack(events))
break
elseif events[3] >= 34 and events[3] <= 42 and events[4] == 2 then
returnString = login and "EXIT LOGIN" or ""
os.queueEvent(unpack(events))
break
elseif events[3] >= 45 and events[3] <= 49 and events[4] == 2 then
returnString = login and "EXIT LOGIN" or ""
os.queueEvent(unpack(events))
break
elseif events[3] == x and events[4] == 1 then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1,1)
print("Thank you for using SmartPaste!")
os.queueEvent("terminate")
returnString = "TERMINATE"
break
end
end
end
term.setCursorBlink(false)
return returnString
end
local function loginScript()
if not logged then
paintutils.drawLine(10,6,40,6, colors.blue)
term.setCursorPos(10, 6)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.blue)
write("Please login")
for i = 1, 8 do
paintutils.drawLine(10, 6 + i, 40, 6 + i, colors.lightGray)
end
local loginObjects = {
{name = "Username:",
nameX = 11,
nameY = 9,
color = colors.black,
BGcolor = colors.lightGray},
{name = "Username: ",
nameX = 21,
nameY = 9,
color = colors.white,
BGcolor = colors.white},
{name = "Password:",
nameX = 11,
nameY = 11,
color = colors.black,
BGcolor = colors.lightGray},
{name = "Password: ",
nameX = 21,
nameY = 11,
color = colors.white,
BGcolor = colors.white},
{name = "Login",
nameX = 15,
nameY = 13,
color = colors.white,
BGcolor = colors.green},
{name = "Cancel",
nameX = 30,
nameY = 13,
color = colors.white,
BGcolor = colors.red}
}
while true do
for i = 1, #loginObjects do
term.setCursorPos(loginObjects[i].nameX, loginObjects[i].nameY)
term.setTextColor(loginObjects[i].color)
term.setBackgroundColor(loginObjects[i].BGcolor)
write(loginObjects[i].name)
end
term.setCursorPos(22, 9)
login = true
username = limitRead(16)
if username ~= "EXIT LOGIN" and username ~= "TERMINATE" then
term.setCursorPos(22, 11)
password = limitRead(16, "*")
if password ~= "EXIT LOGIN" and username ~= "TERMINATE" then
local response = http.post(
"http://pastebin.com/api/api_login.php",
"api_dev_key="..devKey.."&"..
"api_user_name="..textutils.urlEncode(username).."&"..
"api_user_password="..textutils.urlEncode(password)
).readAll()
local badRequests = {
"Bad API request, invalid login",
"Bad API request, account not active"
}
if response then
if response == badRequests[1] then
term.setCursorPos(11,7)
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.red)
write("Invalid login!")
elseif response == badRequests[2] then
term.setCursorPos(11,7)
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.red)
write("Inactive account!")
else
userKey = response
logged = true
background()
break
end
end
elseif password == "TERMINATE" then
os.queueEvent("terminate")
break
elseif password == "EXIT LOGIN" then
password = "TEMP_PASSWORD"
background()
break
else
userKey = ""
logged = false
background()
break
end
elseif username == "TERMINATE" then
os.queueEvent("terminate")
break
elseif username == "EXIT LOGIN" then
username = "TEMP_USER"
background()
break
else
userKey = ""
logged = false
background()
break
end
end
login = false
else
logged = false
userKey = ""
background()
end
end
local function helpScreen()
for i = 3, y do
paintutils.drawLine(1,i,x,i,colors.lightBlue)
end
for i = 6, y-3 do
paintutils.drawLine(28,i,x-1,i,colors.white)
end
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.black)
term.setCursorPos(15,4)
write("SmartPaste Help Section")
term.setCursorPos(45,2)
term.setBackgroundColor(colors.red)
term.setTextColor(colors.black)
write("Help")
term.setCursorPos(1,6)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.lightBlue)
write([[ Please select from a
topic on the right.
Help information will
be displayed here.]])
local helpMenu = {
{topic = "How to login",
y = 7,
action = function()
for i = 6, y do
paintutils.drawLine(1,i,27,i,colors.lightBlue)
end
term.setCursorPos(8,6)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lightBlue)
print("How to login")
term.setTextColor(colors.white)
write([[
Select the "Login" option
at the top. You will enter
your personal login for
your pastebin account.
Rest assured, your account
information is not stored
anywhere. We use a user
key once we receive a
successful login from
Pastebin.]])
end},
{topic = "How to retrieve a post",
y = 8,
action = function()
for i = 6, y do
paintutils.drawLine(1,i,27,i,colors.lightBlue)
end
term.setCursorPos(3,6)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lightBlue)
print("How to retrieve a post")
term.setTextColor(colors.white)
write([[
Select "Download" from the
menu.
If you are logged in, you
willbe able to view your
own posts or download
directly from a paste
code.
Otherwise, you can just
download directly using a
paste code.]])
end},
{topic = "How to save a post",
y = 9,
action = function()
for i = 6, y do
paintutils.drawLine(1,i,27,i,colors.lightBlue)
end
term.setCursorPos(5,6)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lightBlue)
print("How to save a post")
term.setTextColor(colors.white)
write([[
Select 'New' from the main
menu at the top. From there
you can scroll through the
files you have on your
computer/turtle. Use the
Enter key to make your
selection.
You have the option of
changing the syntax
of your paste, expiration,
and if you are logged in,
even the exposure.]])
end},
{topic = "What's new",
y = 10,
action = function()
for i = 6, y do
paintutils.drawLine(1,i,27,i,colors.lightBlue)
end
term.setCursorPos(9,6)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lightBlue)
print("What's new")
term.setTextColor(colors.white)
write([[
-You are now able to select
the syntax highlighting
that is posted to Pastebin
as well as changing the
paste expiry date. You can
also change how the post
is published, to public,
private, or unlisted.
-Obvious graphic changes.
-Automatic integration with
Firewolf.
-A secret! Try to find it!!]])
end},
{topic = "Credits",
y = 11,
action = function()
for i = 6, y do
paintutils.drawLine(1,i,27,i,colors.lightBlue)
end
term.setCursorPos(12,6)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lightBlue)
print("Credits")
term.setTextColor(colors.white)
write([[
Code -- Cranium
Design -- Cranium
Logo -- Cranium
Firewolf -- 1Lann and
Gravityscore
Bug Fixing -- CC Forums
Logo Idea -- RunasSudo
Special thanks to 1Lann
and Gravityscore for giving
me the idea to redo the
whole thing, and making it
so much better.]])
end},
{topic = "About",
y = 12,
action = function()
for i = 6, y do
paintutils.drawLine(1,i,27,i,colors.lightBlue)
end
term.setCursorPos(12,6)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.lightBlue)
print("About")
term.setTextColor(colors.white)
write([[
-Version 2.0-
Written for ComputerCraft
ver. 1.48+
This awesome program was
written by Cranium, and use
of this program is granted
under these two conditions:
Any modifications must
be approved by the original
author and credit cannot be
claimed by the user.]])
end}
}
local help = true
while help do
for i = 1, 6 do
term.setCursorPos(29, 6 + i)
term.setTextColor(colors.blue)
term.setBackgroundColor(colors.white)
write(helpMenu[i].topic)
end
local events = {os.pullEvent()}
if events[1] == "mouse_click" and events[2] == 1 then
for i = 1, #helpMenu do
if events[3] >= 29 and events[3] <= x-1 then
if events[4] == helpMenu[i].y then
helpMenu[i].action()
end
end
end
if events[4] == 2 then
if events[3] >= 1 and events[3] <= 5 then
os.queueEvent(unpack(events))
break
elseif events[3] >= 21 and events[3] <= 24 then
os.queueEvent(unpack(events))
break
elseif events[3] >= 28 and events[3] <= 31 then
os.queueEvent(unpack(events))
break
elseif events[3] >= 34 and events[3] <= 42 then
os.queueEvent(unpack(events))
break
elseif events[3] >= 45 and events[3] <= 49 then
os.queueEvent(unpack(events))
break
end
elseif events[4] == 1 and events[3] == x then
os.queueEvent("terminate")
break
end
end
end
end
local function downloadPaste()
for i = 3, y do
paintutils.drawLine(1,i,x,i,colors.lightBlue)
end
if logged then
for i = 9, 12 do
paintutils.drawLine(10,i,40,i,colors.white)
end
term.setCursorPos(15,10)
term.setTextColor(colors.blue)
write("Retrieving posts for:")
local cX = (x/2)-(string.len(username)/2)
term.setCursorPos(cX,11)
term.setTextColor(colors.red)
write(username)
local response = http.post(
"http://pastebin.com/api/api_post.php",
"api_option=list&"..
"api_dev_key="..devKey.."&"..
"api_user_key="..userKey
).readAll()
if not response then
for i = 6,10 do
paintutils.drawLine(8,i,42,i,colors.lightGray)
end
paintutils.drawLine(9,8,41,8,colors.white)
term.setCursorPos(11,8)
term.setTextColor(colors.red)
write("Unable to connect to Pastebin!")
end
for i = 3, y do
paintutils.drawLine(1,i,x,i,colors.lightBlue)
end
local codeTable = {}
local titleTable = {}
local formatTable = {}
local privTable = {}
for code in string.gmatch(response, "<paste_key>(%w-)</paste_key>") do
table.insert(codeTable, code)
end
for title in string.gmatch(response, "<paste_title>(.-)</paste_title>") do
table.insert(titleTable, title)
end
for formatLong in string.gmatch(response, "<paste_format_long>(%w-)</paste_format_long>") do
table.insert(formatTable, formatLong)
end
for private in string.gmatch(response, "<paste_private>(%d-)</paste_private>") do
if private == "0" then
table.insert(privTable, "Public")
elseif private == "1" then
table.insert(privTable, "Unlisted")
elseif private == "2" then
table.insert(privTable, "Private")
end
end
if not codeTable[1] then
for i = 9, 12 do
paintutils.drawLine(10,i,40,i,colors.white)
end
term.setCursorPos(18, 10)
term.setTextColor(colors.red)
write("No pastes found!")
sleep(1)
return
end
term.setBackgroundColor(colors.lightBlue)
term.setCursorPos(2, 4)
term.setTextColor(colors.black)
write("Title")
term.setCursorPos(19, 4)
write("Syntax")
term.setCursorPos(30, 4)
write("Paste Type")
term.setCursorPos(2, 14)
term.setBackgroundColor(colors.lightBlue)
term.setTextColor(colors.black)
write("Selected Paste Info:")
for k = 15, y do
paintutils.drawLine(2,k,25,k,colors.lightGray)
end
term.setCursorPos(10, 18)
term.setBackgroundColor(colors.green)
write("Download")
for k = 15, y do
paintutils.drawLine(27,k,50,k,colors.lightGray)
end
term.setCursorPos(35, 18)
term.setBackgroundColor(colors.green)
write("Download")
term.setCursorPos(27, 14)
term.setBackgroundColor(colors.lightBlue)
write("Enter Pastebin Code:")
paintutils.drawLine(28,16,49,16,colors.white)
local scroll = 1
while true do
local function drawList(titleTable, formatTable, scroll)
if scroll <= 8 then
for i = 1, 8 do
if i > #titleTable then break end
if titleTable[1] == nil then break end
term.setBackgroundColor(colors.lightBlue)
term.setCursorPos(1, 4 + i)
term.setTextColor(colors.white)
if string.len(titleTable[i]) >= 17 then
write(" "..string.sub(titleTable[i], 1, 14).."...")
else
write(" "..titleTable[i])
end
local mX,mY = term.getCursorPos()
for i = 1, 19 - mX do
write(" ")
end
write(formatTable[i])
local mX,mY = term.getCursorPos()
for i = 1, 30 - mX do
write(" ")
end
write(privTable[i])
local mX,mY = term.getCursorPos()
for i = 1, 50 - mX do
write(" ")