TechHog8984 / luau_beautifier

7 stars 1 forks source link

I am getting bunch of "unknown expression type" on every var assignment #1

Open SolsticeSpectrum opened 1 month ago

SolsticeSpectrum commented 1 month ago

It breaks the script by replacing all assignments and epxressions with --[[ error: unknown expression type! ]] Heere is the file in question script2.txt

It would be nice if it solved all expressions in this obfuscation and maybe even evaluate stuff like

    local function v(v)
        print(M[v + 38867])
        return M[v + 38867];
    end

    F = v(-38849);
    W = v(-38851);
    k = M[v(-38858)];
    d = M[v(-38857)];

so it gets rid of the v function and just adds the correct offsets maybe it could also get rid of hoops like

F = 1
M = F + 2
C = M * 5

and just turn it into single variable It should also probably convert long varialbe and function names into shorter ones

With these additions, it could get rid of all arithmetics that exist solely to annoy you and don't contribute in any way

TechHog8984 commented 1 month ago

The unknown expression type appears to be because of that script utilizing type expressions, which are entirely unsupported due to my unfamiliarity with them. Type expressions are not planned, but if the ones in your script are simple enough, I'll look into them.

As for the Prometheus constant wrap function, sure. I'll try to implement that and add a flag to not intrude.

Unfortunately, I do not want to attempt simplifying "hoops", as I don't have an immediate solution to all the caveats that come with it (I can't inline F if it's used in an if expression below the assignment to C, it might be used nested deep in a proto, and most importantly, if the script does constant/upvalue/stack manipulation, which is easily done with a proficient Roblox executor, things could break). I'm willing to discuss any solutions you may have.

I have no intention on renaming anything. Feel free to implement that yourself in a fork if you are able, but I personally do not desire such functionality.

I apologize for shutting most of your requests down, but my goal with the beautifier is to preserve as much information as possible.

I will follow up later with progress on the simplifying wrap function calls and type expressions.

TechHog8984 commented 3 weeks ago

@SolsticeSpectrum I apologize for getting back so late.

I have added very minimal support for type annotations, and the script you provided is simple enough to work fine.

Here is your new script script2.beautified.txt

I once again apologize for the lack of work done with the previously stated wrap function calls.