// Detect It Easy: detection rule file
// Author: LinXP

meta("format", "Lua Bytecode (.LUAC)");

function detect() {
    if (Binary.getSize() >= 8) {
        if (Binary.compare("1B'Lua'..00")) {
            bDetected = true;
            switch (Binary.read_uint8(0x04)) {
                case 0x50: sVersion = "v5.0"; break;
                case 0x51: sVersion = "v5.1"; break;
                case 0x52: sVersion = "v5.2"; break;
                case 0x53: sVersion = "v5.3"; break;
                case 0x54: sVersion = "v5.4"; break;
                default: return;
            }
            if (Binary.isVerbose()) {
                switch (Binary.read_uint8(0x06)) {
                    case 0: sOption("BigEndian"); break;
                    case 1: sOption("LittleEndian"); break;
                    default: return;
                }
            }
        }
    }

    sLang = "Lua";

    return result();
}