Jump to content

Luac rejects some files


rain_gloom

Recommended Posts

I'm trying to build a wrapper around luac.mtasa.com to automate builds, but I'm getting quite a few errors.

this is the current script:

--[[template from luac.mtasa.com/api: 
local FROM="example.lua" 
local TO="compiled.lua" 
fetchRemote( "http://luac.mtasa.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 ( 
        ( 'http://luac.mtasa.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 post

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 post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...