SHOW:
|
|
- or go back to the newest paste.
1 | - | --3.5 by Mr John Dowe Apr-30-2023 |
1 | + | --2.0 by Severino Aug-11-2015 |
2 | --based on the computercraft pastebin script. | |
3 | ||
4 | - | local setLabel = os.getComputerID() |
4 | + | |
5 | - | if not setLabel then |
5 | + | |
6 | - | shell.run("label set PC:"..tonumber(os.getComputerID())) |
6 | + | |
7 | function getSettings(file) | |
8 | local curSettings = file | |
9 | ||
10 | for i = 1, #curSettings do | |
11 | textutils.pagedPrint( tonumber( i ) .. " : " .. curSettings[i] ) | |
12 | end | |
13 | end | |
14 | ||
15 | ||
16 | local input = nil | |
17 | local start = 0 | |
18 | local stop = 0 | |
19 | ||
20 | function clear() | |
21 | term.clear() | |
22 | term.setCursorPos(1,1) | |
23 | end | |
24 | ||
25 | if not http then | |
26 | print( "Pastebin requires http API" ) | |
27 | print( "Set enableAPI_http to 1 in mod_ComputerCraft.cfg" ) | |
28 | return | |
29 | end | |
30 | ||
31 | clear() | |
32 | print("Enter the corresponding number from the list or enter 0 to get all\n") | |
33 | ||
34 | while input == nil do | |
35 | for i=1, #file do | |
36 | write(i..":"..file[i].." ") | |
37 | end | |
38 | -- for i = 1, #file do | |
39 | -- textutils.pagedPrint( tonumber( i ) .. " : " .. file[i] ) | |
40 | --end | |
41 | - | --for i=1, #file do |
41 | + | |
42 | - | -- write(i..":"..file[i].." ") |
42 | + | |
43 | - | --end |
43 | + | |
44 | - | for i = 1, #file do |
44 | + | |
45 | - | textutils.pagedPrint( tonumber( i ) .. " : " .. file[i] ) |
45 | + | |
46 | else | |
47 | start = input | |
48 | stop = input | |
49 | end | |
50 | if input == nil then | |
51 | clear() | |
52 | print("Try again, but this time enter the NUMBER, or enter 0 for all, or hold ctrl+t to exit.\n") | |
53 | end | |
54 | end | |
55 | ||
56 | for i=start, stop do | |
57 | -- Download a file from pastebin.com | |
58 | -- Determine file to download | |
59 | local sCode = code[i] | |
60 | local sFile = file[i] | |
61 | local sPath = shell.resolve( sFile ) | |
62 | if fs.exists( sPath ) then | |
63 | --this will delete a script of the same name you are downloading to make room. | |
64 | --Good for updating scripts you have edited on pastebin. | |
65 | fs.delete( sPath ) | |
66 | end | |
67 | ||
68 | -- GET the contents from pastebin | |
69 | write( "Connecting to pastebin.com... " ) | |
70 | local response = http.get( | |
71 | "http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode ) | |
72 | ) | |
73 | ||
74 | if response then | |
75 | print( "Success." ) | |
76 | ||
77 | local sResponse = response.readAll() | |
78 | response.close() | |
79 | ||
80 | local file = fs.open( sPath, "w" ) | |
81 | file.write( sResponse ) | |
82 | file.close() | |
83 | ||
84 | term.clear() | |
85 | term.setCursorPos(1,1) | |
86 | print( "Downloaded as "..sFile ) | |
87 | sleep(1) | |
88 | ||
89 | ||
90 | else | |
91 | print( "Failed." ) | |
92 | end | |
93 | ||
94 | print( "Thank you for using Mr John Dowe's programs, have fun!" ) | |
95 | sleep(1) | |
96 | shell.switchTab( shell.openTab(sFile) ) | |
97 | --shell.run( sFile ) | |
98 | end |