// DIE's signature file
// Author: LinXP

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

function detect(bShowType,bShowVersion,bShowOptions)
{
    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  : bDetected=false;
            }
            if(Binary.isVerbose())
            {
                switch(Binary.read_uint8(0x06))
                {
                    case  0: sOption("BigEndian");     break;
                    case  1: sOption("LittleEndian");  break;
                    default: bDetected=false;
                }
            }
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
