This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
boudragon's profile picture

Pastebin Uploader/Downloader Lite

Started by boudragon, 03 July 2013 - 07:54 PM
boudragon #1
Posted 03 July 2013 - 09:54 PM
Ok so not sure if this has been made yet or not… probably has… but here is my version. It's basic and I know you could just type it all out to upload or download a pastebin file BUT… I think this is a bit easier plus you can add it to a menu to allow users to download programs to their system. Here it is… comments, questions and suggestions are ALL welcome. If you use this please give credit. If you modify it that is ok too just be sure to give credit for the original design.


	rep = 0
	rep2 = 0
	pog = 0
	
	pb = "rom/programs/http/pastebin"
	xfer = ""
	filep = ""
	fileg = ""
	pbID = ""
	
	while rep == 0 do
	   term.clear()
	   term.setCursorPos(1,1)
	   print("What would you like to do?")
	   print("1. Upload File   2. Download File")
	   print("")
	   write("Choice: ")
	   input = read()
	   if input == "1" then
		  xfer = " put "
		  rep = rep+1
		  pog = pog+1
	   elseif input == "2" then
		  xfer = " get "
		  rep = rep+1
		  pog = pog+2
	   else
		  print"Invalid entry."
		  sleep(2)
	   end
	end
	
	if pog == 1 then
	   while rep2 == 0 do
		  term.clear()
		  term.setCursorPos(1,1)
		  print("Please type the name of the file you")
		  print("would like to upload to pastebin.com")
		  print("")
		  write("File Name: ")
		  input = read()
		  if input == "" then
			 print("Invalid Entry.")
			 sleep(2)
		  else
			 term.clear()
			 term.setCursorPos(1,1)
			 filep = input
			 rep2 = rep2+1
			 shell.run(pb, xfer, filep)
		  end
	   end
	elseif pog == 2 then
	   while rep2 == 0 do
		  term.clear()
		  term.setCursorPos(1,1)
		  print("Input the pastebin ID code.")
		  print("")
		  write("Pastebin ID: ")
		  input = read()
		  if input == "" then
			 print("Invalid Entry")
			 sleep(2)
		  else
			 pbID = input
			 rep2 = rep2+1
			 pog = pog+1
		  end
	   end
	end
	
	if pog == 3 then
	   while rep2 == 1 do
		  term.clear()
		  term.setCursorPos(1,1)
		  print("Please type the name you want the")
		  print("file to be saved as.")
		  print("")
		  write("Save As: ")
		  input = read()
		  if input == "" then
			 print("Invalid Entry")
			 sleep(2)
		  else
			 term.clear()
			 term.setCursorPos(1,1)
			 fileg = input
			 rep2 = rep2+1
			 pog = pog+1
			 shell.run(pb, xfer, pbID, " ", fileg)
		  end
	   end
	else
	end

Dave-ee Jones #2
Posted 04 July 2013 - 03:47 AM
That is a LOT of code for a pastebin code fetcher/poster…Have a look at the pastebin program in /rom/programs/http/pastebin.

It helps.
boudragon #3
Posted 04 July 2013 - 09:40 AM
It's meant to ask simple questions and act as a universal upload / download client. Instead of typing:

pastebin put [File Name]

you type:

1
[File Name]

Or instead of typing:

pastebin get [Pastebin ID] [File Name]

your type:

2
[Pastebin ID]
[File Name]

It shortens the typing plus this program can easily be plugged into other programs to function as a file handler. It's meant to be for the all those people who ask "How do I use Pastebin!" :)/>
Tjakka5 #4
Posted 04 July 2013 - 09:48 AM
Actually…

[Program name]
-Enter-
[Pastebin ID]
-Enter-
[File Name]
-Enter-

Instead of just

pastebin get [Pastebin ID] [Filename]
-Enter-


Also, plugging it in to other programs doesnt make sense as you could just do shell.run("pastebin", "get", id, name)
boudragon #5
Posted 04 July 2013 - 09:51 AM
Heck I've used this and I think it's easier. Count the keystrokes… it IS less…

Using Pastebin function:

pastebin get daTg13eG test [Enter] = 27 keys pressed

Compaired to:

2 [Enter] daTg13eG [Enter] test [Enter] = 16 keys pressed

Pastebin function:

pastebin put test [Enter] = 18 keys pressed

Compaired to:

1 [Enter] test [Enter] = 6 keys pressed

Simple math guys come on LOL!

Not to mention… my first program!
boudragon #6
Posted 04 July 2013 - 03:02 PM
Jeesh… brutal crowd LOL! Even if it is pointless at least say "I wouldn't use this BUT good job on your first program." HAHA! Oh well… I tried…
UMayBleed #7
Posted 04 July 2013 - 03:31 PM
Who cares if it is useless or not, in the long run everyone is just getting practice, they will be able to make better and better programs if they start small first.
boudragon #8
Posted 04 July 2013 - 04:11 PM
:)/> Thank you… I appreciate that!
TeamDman #9
Posted 04 July 2013 - 04:59 PM
Good job on your first script!
boudragon #10
Posted 04 July 2013 - 05:13 PM
Thanx :)/> I found another pastebin script that was suppose to be a better way to upload files… and in a way it is but others it wasn't. The benefit was that you could log into your pastebin account through the computercraft terminal… the downfall was it still required a lot of typing. Maybe I will look further into it and come up the a system for it.
Lewisk3 #11
Posted 30 October 2013 - 04:06 AM
i thought pastebin stopped supporting computercraft?
boudragon #12
Posted 30 October 2013 - 05:02 AM
Used it just yesterday… works fine…
theHatedOne #13
Posted 03 November 2013 - 11:56 AM
No wonders why pastebin hates CC, they are receiving MASSIVE amounts of code-spam :P/>

If you want to take arguments from shell just do

local arguments = {...}
It will put all your args into table :)/>

Also pro tip: use local variables - faster, safer and no situations in witch you have "sup", "Sup", "SUP", "suP", "sup_", "_sup" and "_sup_". Keeping your code clean always helps :D/>