rain_gloom Posted August 29, 2015 Share Posted August 29, 2015 I'm trying to build a wrapper around luac.multitheftauto.com to automate builds, but I'm getting quite a few errors. this is the current script: --[[template from luac.multitheftauto.com/api: local FROM="example.lua" local TO="compiled.lua" fetchRemote( "https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=0", function(data) fileSave(TO,data) end, fileLoad(FROM), true ) ]] function compileString ( source, callback, compile, debug, obfuscate, attempts ) fetchRemote ( ( 'https://luac.multitheftauto.com/?compile=%d&debug=%d&obfuscate=%d' ):format ( compile and 1 or 0, debug and 1 or 0, obfuscate and 1 or 0 ), function ( response, errcode ) if response:match ( '^ERROR' ) then error ( ( "compilation failed with errorcode=%d and response=%s" ):format ( errcode, response ) ) else outputDebugString "compiled" callback ( response ) end end, attempts, true, source ) outputDebugString ( "compiling: " .. source ) end The function is exported btw. The error I get is "ERROR could not read file", I've tried compiling a few random scripts in my browser, but only one or two of them worked. Previously I could not even connect to the site. I've ran the function with simple things like "a=2" and "return 0" and some basic loops, but all of them returned the same error? What am I doing wrong? Link to comment
JR10 Posted August 29, 2015 Share Posted August 29, 2015 The order of the arguments in fetchRemote is wrong. The correct syntax: bool fetchRemote ( string URL[, int connectionAttempts = 10 ], callback callbackFunction, [ string postData = "", bool postIsBinary = false, [ arguments... ] ] ) The way you used it made it so, the postData equals attempts, postIsBinary gets true, and source is considered an argument. Link to comment
rain_gloom Posted August 31, 2015 Author Share Posted August 31, 2015 Ah. Thanks. It probably confused me that there is an optional argument between two mandatory ones. Link to comment
JR10 Posted August 31, 2015 Share Posted August 31, 2015 It was confusing to me at first as well. I think the way it works is by checking for the value's type. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now