Jump to content




how do i hide a pastebin download?


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

#1 goldensecret

  • Members
  • 24 posts

Posted 17 March 2014 - 02:53 PM

yo, i am having troubble with my standard turtle startup method i always use, it looks ugly... i want to be able to hid the pastebin get that it does, i display a 'downloaded file' in the code, but i think the standard one just looks ugly, is there a way to get rid of that? heres a screen shot of what it looks like as of current, and the code.

http://pastebin.com/sdmtFLrF

Attached Thumbnails

  • Attached Image: 2014-03-17_14.44.10.png

Edited by goldensecret, 17 March 2014 - 02:55 PM.


#2 CometWolf

  • Members
  • 1,283 posts

Posted 17 March 2014 - 03:00 PM

You could be super lazy and just do
parallel.waitForAll(
  function()
	shell.run"pastebin get whatever derpderp"
  end,
  term.clear
)
However, that's quite a retarded and stupid way of doing it :P

The proper way, would require you to setup your own pastebin program. It's quite simple, as you can just copy the parts you need from the pastebin program itself really.
Spoiler

Edited by CometWolf, 17 March 2014 - 03:00 PM.


#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 17 March 2014 - 03:11 PM

You could just create your own pastebin function
--[[
	@description	"Downloads a file from pastebin"


@param	name,  string
@param	code,  string

@return   nil
--]]
function pastebin_get( name, code )
local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode(code))
if response then
   local file = fs.open(name,"w")
   local sCode = response.readAll()
   response.close()
   file.write(sCode)
   file.close()
else
   error("Error getting the file " .. name, 0)
end
end
And use it like this
print( "I'm downloading a file now! :D/>/>")
pastebin_get( "<Input filename>", "<Input pastebin code>" )
print( "Yay! Downloaded <Your file>! :D/>/>" )

Edited by Hellkid98, 17 March 2014 - 03:12 PM.


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 17 March 2014 - 04:52 PM

View PostCometWolf, on 17 March 2014 - 03:00 PM, said:

parallel.waitForAll(
  function()
	shell.run"pastebin get whatever derpderp"
  end,
  term.clear
)

This would clear anything printed before the download starts, but would leave intact the success/failure message.

#5 CometWolf

  • Members
  • 1,283 posts

Posted 17 March 2014 - 05:01 PM

Guess he could throw in a clear afterwards aswell, and or maybe use clearLine instead. I didn't put much thought into that idea, cause like i said, it's a stupid one.

#6 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 17 March 2014 - 06:32 PM

View PostCometWolf, on 17 March 2014 - 05:01 PM, said:

Guess he could throw in a clear afterwards aswell, and or maybe use clearLine instead. I didn't put much thought into that idea, cause like i said, it's a stupid one.
If it's stupid then why did you post it? It could be a problem if the OP decided to go with that( But I'm pretty sure he won't ) :P

#7 goldensecret

  • Members
  • 24 posts

Posted 18 March 2014 - 01:53 PM

View PostHellkid98, on 17 March 2014 - 03:11 PM, said:

You could just create your own pastebin function
--[[
	@description	"Downloads a file from pastebin"


@param	name,  string
@param	code,  string

@return   nil
--]]
function pastebin_get( name, code )
local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode(code))
if response then
   local file = fs.open(name,"w")
   local sCode = response.readAll()
   response.close()
   file.write(sCode)
   file.close()
else
   error("Error getting the file " .. name, 0)
end
end
And use it like this
print( "I'm downloading a file now! :D/>/>/>")
pastebin_get( "<Input filename>", "<Input pastebin code>" )
print( "Yay! Downloaded <Your file>! :D/>/>/>" )

sweet, this looks like the one ill use. now will the top code be in the install, or will i have to have it a separate file? im so confused. i have just started coding, so please eli5 ;)

#8 Anavrins

  • Members
  • 775 posts

Posted 18 March 2014 - 02:32 PM

Simply http.get() from pastebin's raw pages
Example:
local content = http.get("http://pastebin.com/raw.php?i=PaStEiD").readAll()

Edited by Anavrins, 24 March 2014 - 07:55 PM.


#9 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 18 March 2014 - 04:40 PM

View Postgoldensecret, on 18 March 2014 - 01:53 PM, said:

sweet, this looks like the one ill use. now will the top code be in the install, or will i have to have it a separate file? im so confused. i have just started coding, so please eli5 ;)
No it doesn't need to be in a separate file, If you would do that you would have to load it with os.loadAPI
--[[
    Let's say you've put the code in a file called
    potatoes, Then you would have to use it like
    this
--]]
os.loadAPI( "potatoes" ) -- Loading the API
potatoes.pastebin_get( "<Filename>", "<Code>" )
I mentioned above that it was a function, If you're unsure what that is I suggest you go and check out this site http://www.lua.org/p...ontents.html#P1 and learn what you need to learn
or you can just google it, Google is your best friend ;)
The code that I posted checks if the website is responding and if it isn't it will error with the error I inputted( Error getting the file <Filename> )

#10 goldensecret

  • Members
  • 24 posts

Posted 24 March 2014 - 06:05 PM

brilliant! worked a treat. thank you!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users