| parent | layout | nav_order | title |
|---|---|---|---|
API Docs! |
default |
3 |
Header API |
utf8- A global boolean that determines whether to usecp932(JP ver.) orUTF-8(International ver.). True by default.panic()- A function used to signal warnings - this is usually used by the API to signal errors, more can be found in the Error section.api- A global (and pre-defined) instance ofHeaderAPI.fileBuffer- decrypted save data used by the UI - stored as aUint8Array.playerOffsets- a global array containing the start pos' of each player block ([0x5390, 0x5418, 0x54A0]).encoder.encode()- a global alias forText.Encode(str).decoder.decode()- a global alias forText.Decode(str).async isDecrypted(fileBuffer)- Checks if ahead.yw/head.ywdis decrypted - returns true if decrypted, if encrypted or heavily corrupted returns false.async fullDecrypt()- Decrypts ahead.ywfromfileBuffer(mutates it) (head.yw->head.ywd). This also works on Yo-kai Watch 1 save files - although unintentional.async fullEncrypt()- Encrypts ahead.ywdfromfileBuffer(mutates it) (head.ywd->head.yw). This also works on Yo-kai Watch 1 save files - although unintentional.readUInt32(offset)- Takes an offset of typeNumberand returns aNumbercorresponding that point infileBufferread as a uint32 (unsigned 32-bit integer).readUInt16(offset)- Takes an offset of typeNumberand returns aNumbercorresponding that point infileBufferread as a uint16 (unsigned 16-bit integer).writeUInt32(offset, value)- Takes an offset of typeNumberand a value, it writes that value as auint32(unsigned 32-bit integer) and the offset infileBuffer.writeUInt16(offset, value)- Takes an offset of typeNumberand a value, it writes that value as auint16(unsigned 16-bit integer) and the offset infileBuffer.async download()- DownloadsfileBufferashead.ywd.async downloadEncrypted()- EncryptsfileBuffer, downloads it as ahead.ywand then decrypts it usingfullDecryptandfullEncryptrespectively.formatPlayTime(seconds)- Takes seconds in the form ofNumberand returns a string in formatHH:MM:SS(seconds, minutes and hours are 0 padded when needed to look good).getUTF8ByteLength(str)- Returns the amount of bytes a string takes up. Note: DESPITE THE NAME STATING UTF8 IT USES CP932 WHENutf8 == false!
playerIndex- A number from 0-2 where 0 is the 1st save file/player, 1 is the 2nd and 2 is the 3rd.rankVal- ANumberthat controls Rank -0= E,1= D, ...5= StimeBlock- An object structured like{ year: 0x7E9, month: 0x0A, day: 0x02, hour: 0xB, minute: 0x00 }.
- Constructor:
HeaderAPI(filebuf = fileBuffer)filebufis where the save data is stored in the API.
async refreshUI()- Refreshes/reloads the UI based on the API's save data.async grabChanges()- Saves the UI changes and sets the API's save data to the UI save data.exportSave()- Exports the API's save data as aUint8Array.getPlayers()- Exports a JSON snapshot of the API's save data in this format:[{ name, rank, playTime, year, month, day, hour, minute, party } /* player 1 */, { name, rank, playTime, year, month, day, hour, minute, party } /* player 2 */, { name, rank, playTime, year, month, day, hour, minute, party } /* player 3 */]
setPlayerName(index, newName)- Takes aplayerIndexandnameand sets that player's name to the input.setWatchRank(index, rankVal)- Takes aplayerIndexand arankValand sets that player's watch rank to that rank.setPlayTime(index, seconds)- Takes aplayerIndexand aNumber(seconds) and sets that player's play time to that time.setLastSaveDate(index, { year, month, day, hour, minute })- Takes aplayerIndexand atimeBlockand sets that player's last save date to that date.
static Encode(str, utf8 = window.utf8)- Encodes a string ->Uint8Array, ifutf8is true it'll use UTF-8 encoding otherwise cp932/Windows 31-J (UTF-8 is needed for INTL versions while cp932 for JP).static Decode(bytes, utf8 = window.utf8)- Decodes aUint8Array-> string, ifutf8is true it'll use UTF-8 encoding otherwise cp932/Windows 31-J (UTF-8 is needed for INTL versions while cp932 for JP).constructor() { throw new Error("Do NOT use the constructor.")}- Warning.