• require() http link?
    4 replies, posted
Is it possible to use require() with http links, like requesting a lua file from an url, instead of path? Normal: require("somefolder/someluafile.lua") what i ask: require("http://someurl/somefolder/someluafile.lua") - If this isnt possible, is there a way to code it?
require( ) is for binary modules.. [editline]1st November 2014[/editline] I'm pretty sure you're looking for something like this, though. [lua]http.Fetch( "http://nitrogaming.org/stuff/example.txt" , function(a) pcall(CompileString(a, "l", false)) end, function() end)[/lua] Just replace my example with any other URL containing Lua code.
This is wrong [lua] pcall(CompileString(a, "l", false)) [/lua] Should be: [lua] pcall(CompileString, a, "l", false) [/lua]
[QUOTE=mijyuoon;46386537]This is wrong [lua] pcall(CompileString(a, "l", false)) [/lua] Should be: [lua] pcall(CompileString, a, "l", false) [/lua][/QUOTE] Nah, CompileString returns a function you want to call on success, which is then being passed to pcall. The code will still cause an error if the syntax of the document is wrong. Fun fact: The gmod *cough* worm used this method: [url]https://github.com/TheShockTop/The-Cough/blob/master/server_autorun.lua#L16[/url]
[QUOTE=Willox;46386586]Nah, CompileString returns a function you want to call on success, which is then being passed to pcall.[/QUOTE] Ah dammit, I'm idiot. I thought it was RunString(Ex) for some reason. :suicide:
Sorry, you need to Log In to post a reply to this thread.