1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 27 April 2014 - 04:17 AM
Alright, before I say anything, I want to tell you I
have tried looking at the default pastebin program but I could not make sense of it. I tried even replication its code but there was something I was missing.
Anyhow, basically I want to know how to implement paste bin's "run" feature into my program. How would I do this and could this be explained line-by-line?
Sorry for any mistakes, auto-correct on Mac OSX is annoying sometimes.
How to fix(for anyone who's searched here or found this looking for help)
First of all, you do
variable = http.get("
http://pastebin.com/raw.phpi=PASTEIDHERE")
then you do
variable = loadstring(variable)
Then
setfenv(variable, getfenv())
then run variable in any way you want and you will have all your global functions and variables inside it but not local variables.
Edited on 27 April 2014 - 04:28 AM
3057 posts
Location
United States of America
Posted 27 April 2014 - 04:20 AM
I usually use something like this
shell.run("pastebin get code")
if I need something from pastebin. I prefer not to run from pastebin, as that will require you to connect every time.
1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 27 April 2014 - 05:18 AM
I do not need this file except for one time in my application. I cannot use shell.run("pastebin blah blah blah") in my program. I need to replicate pastebin run's functionality WITHOUT using shell.run("pastebin blah blah blah") or creating any kind of temporary file.
62 posts
Posted 27 April 2014 - 05:39 AM
http.get to return the text in '
http://pastebin.com/raw.php?i=IDHERE' and with that, I believe you could just run the loadstring function
1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 27 April 2014 - 05:46 AM
http.get to return the text in '
http://pastebin.com/raw.php?i=IDHERE' and with that, I believe you could just run the loadstring function
Thank you! This really clears things up. With this, I might be able to release a public alpha of my my project tonight!
Edited on 27 April 2014 - 03:47 AM
1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 27 April 2014 - 06:00 AM
Wait. How do I get things like functions to work inside of this? I've defined a global function but it will not work inside of this!
If there's no way to get my global variables/functions in there, could I pass them into it like a normal function?
Edited on 27 April 2014 - 04:08 AM
62 posts
Posted 27 April 2014 - 06:04 AM
At the very bottom of your code (don't use local variables if you want to be able to access that variable) add:
return getfenv();
So you could assign the loadstring to a variable and you will now have a table of everything you need.
I forgot to add, if you are using an infinite loop then returning the environment is useless, since well you can't really do anything I guess.
Edited on 27 April 2014 - 04:10 AM
1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 27 April 2014 - 06:11 AM
At the very bottom of your code (don't use local variables if you want to be able to access that variable) add:
return getfenv();
So you could assign the loadstring to a variable and you will now have a table of everything you need.
I forgot to add, if you are using an infinite loop then returning the environment is useless, since well you can't really do anything I guess.
wait, I add this before launching the string, or before doing load string?
I am inside a function inside an infinite loop inside a function.
AHA: I think I figured it out
setfenv(stringfunction, getfenv())
stringfunction
Of course it's not called stringfunction, but you get the point.
Edited on 27 April 2014 - 04:24 AM
62 posts
Posted 27 April 2014 - 06:27 AM
I was thinking more of the lines like:
-pastebin code:
–etc code…
–return getfenv()
-CC code
–x = loadstring(pastebincrap)();
–x.functionInPB();
something like that
1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 27 April 2014 - 06:29 AM
what?
first of all nothing special can really be in the pastebin code– not stuff like that. I'll link you to the finished program when I upload it shortly
Uploading it now. Will be full of bugs, graphical glitches, pointless buttons, weird APIs, useless functions, and inefficient code. I need to fix it up but I will release it for developers.
Edited on 27 April 2014 - 04:31 AM
1029 posts
Location
Missouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension
Posted 27 April 2014 - 06:46 AM