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

PLoad | A way to use pastebin in your code

Started by CLNinja, 24 February 2017 - 12:03 AM
CLNinja #1
Posted 24 February 2017 - 01:03 AM
PLoad

Ever needed to download or upload a file, or even just pastebin run code from your programs?

Well, now you can do so very easily! With, PLoad!

PLoad contains 3 functions:


Load: Pastebin run function


DLoad: Pastebin get function


ULoad: Pastebin put function


All documentation for the functions can be found in the top of the file on pastebin.



pastebin get KHPwnyHG
fishermedders #2
Posted 24 February 2017 - 11:36 PM
This seems clever but it would probably not be as useful as you'd think; iirc, pastebin will blacklist a server (or your computer if on emulator)'s IP if you make too many calls.

Imo it would just be easier to make a general-use api to include your functions in.
CLNinja #3
Posted 26 February 2017 - 05:00 PM
This seems clever but it would probably not be as useful as you'd think; iirc, pastebin will blacklist a server (or your computer if on emulator)'s IP if you make too many calls.

Imo it would just be easier to make a general-use api to include your functions in.

Yes but you could do the same thing without an API :P/>

shell.run("pastebin get code test")

you can spam that and achieve the same blacklist. The blacklist is a 24 hr blacklist though, so its not permanent.

Also what do you mean about the general-use api?
fishermedders #4
Posted 26 February 2017 - 07:16 PM
Also what do you mean about the general-use api?

Just like if you're gonna have a bunch of functions to use in a program, why not create an API that you can use over and over again (or just for this 1 program), that has all of the functions that you need in it, and download it once rather than spamming pastebin for it. Just my opinion.
Edited on 26 February 2017 - 06:17 PM
CLNinja #5
Posted 26 February 2017 - 08:53 PM
Also what do you mean about the general-use api?

Just like if you're gonna have a bunch of functions to use in a program, why not create an API that you can use over and over again (or just for this 1 program), that has all of the functions that you need in it, and download it once rather than spamming pastebin for it. Just my opinion.
I have no idea what you're talking about.
fishermedders #6
Posted 27 February 2017 - 02:24 AM
Also what do you mean about the general-use api?

Just like if you're gonna have a bunch of functions to use in a program, why not create an API that you can use over and over again (or just for this 1 program), that has all of the functions that you need in it, and download it once rather than spamming pastebin for it. Just my opinion.
I have no idea what you're talking about.
Basically, if you wanted to have all of your functions in a file, you'd do something like this:

myapi:

function centerPrint( sText, nY ) -- The text to center, the Y Line.
  tSize = { term.getSize() }
  term.setCursorPos( math.floor( tSize[1]/2 )-math.floor( #sText/2 ), nY )
  term.write( sText )
end

function sayHello()
  print( "Hello, world!" )
end

function foo()
  return "bar"
end

Then in another file, you would be able to do things like:
programusingapi:

bDidLoad= os.loadAPI("myapi")
if bDidLoad then
  myapicenterPrint( "Hello World!", 1 )

  myapi.sayHello()

  print( myapi.foo() )
end

I usually make APIs like this for functions that I use most often.
[Edit Reason: Wacky code formatting]
Edited on 27 February 2017 - 01:25 AM
CLNinja #7
Posted 27 February 2017 - 04:04 AM
Also what do you mean about the general-use api?

Just like if you're gonna have a bunch of functions to use in a program, why not create an API that you can use over and over again (or just for this 1 program), that has all of the functions that you need in it, and download it once rather than spamming pastebin for it. Just my opinion.
I have no idea what you're talking about.
Basically, if you wanted to have all of your functions in a file, you'd do something like this:

myapi:

function centerPrint( sText, nY ) -- The text to center, the Y Line.
  tSize = { term.getSize() }
  term.setCursorPos( math.floor( tSize[1]/2 )-math.floor( #sText/2 ), nY )
  term.write( sText )
end

function sayHello()
  print( "Hello, world!" )
end

function foo()
  return "bar"
end

Then in another file, you would be able to do things like:
programusingapi:

bDidLoad= os.loadAPI("myapi")
if bDidLoad then
  myapicenterPrint( "Hello World!", 1 )

  myapi.sayHello()

  print( myapi.foo() )
end

I usually make APIs like this for functions that I use most often.
[Edit Reason: Wacky code formatting]

…….

THIS IS AN API YOU NITWIT, YOU JUST EXPLAINED HOW TO USE THIS API.
fishermedders #8
Posted 27 February 2017 - 04:22 AM
…….

THIS IS AN API YOU NITWIT, YOU JUST EXPLAINED HOW TO USE THIS API.

lmao chill hombre, I'm just saying that instead of downloading the file every time and loadstring'ing it every time, it'd just be easier to download it once and maybe even check for newer versions. The whole point of my posts is my suggestion of that of the pastebin blacklist
CLNinja #9
Posted 28 February 2017 - 01:08 AM
…….

THIS IS AN API YOU NITWIT, YOU JUST EXPLAINED HOW TO USE THIS API.

lmao chill hombre, I'm just saying that instead of downloading the file every time and loadstring'ing it every time, it'd just be easier to download it once and maybe even check for newer versions. The whole point of my posts is my suggestion of that of the pastebin blacklist

This is literally an implementation of pastebin but instead of a program with arguments, its all function calls.