Jump to content




Pastebin Uploader/Downloader Lite


  • You cannot reply to this topic
12 replies to this topic

#1 boudragon

  • Members
  • 107 posts

Posted 03 July 2013 - 08: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



#2 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 04 July 2013 - 02: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.

#3 boudragon

  • Members
  • 107 posts

Posted 04 July 2013 - 08: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!" :)

#4 Tjakka5

  • Members
  • 256 posts

Posted 04 July 2013 - 08: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)

#5 boudragon

  • Members
  • 107 posts

Posted 04 July 2013 - 08: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!

#6 boudragon

  • Members
  • 107 posts

Posted 04 July 2013 - 02: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...

#7 computercraftprogrammer

  • Members
  • 122 posts
  • Location$house->Earth->MilkyWay->Universe;

Posted 04 July 2013 - 02: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.

#8 boudragon

  • Members
  • 107 posts

Posted 04 July 2013 - 03:11 PM

:) Thank you... I appreciate that!

#9 TeamDman

  • Members
  • 13 posts
  • LocationCanada

Posted 04 July 2013 - 03:59 PM

Good job on your first script!

#10 boudragon

  • Members
  • 107 posts

Posted 04 July 2013 - 04: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.

#11 Lewisk3

  • Members
  • 150 posts

Posted 30 October 2013 - 04:06 AM

i thought pastebin stopped supporting computercraft?

#12 boudragon

  • Members
  • 107 posts

Posted 30 October 2013 - 05:02 AM

Used it just yesterday... works fine...

#13 theHatedOne

  • Members
  • 7 posts
  • LocationEurope

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users