• It does two things:

    1. Try to read the file, if "Allow Local Files" is enabled then also searches in the game folder
    2. Append filename to preload buffer

    Parameters

    • filename: string

      Text string, supposed to be a file path to be preloaded. Max length: 259 characters (see Windows MAX_PATH).

    Returns void

    Note

    The game only reads these files, does not load them. The reading is done in a separate thread and does not freeze the game. One file is not read twice, no matter how often you call Preload().

    Note

    Trick: It does not escape double-quotes " on purpose (approved not a bug, it's a feature). It is possible to inject custom code in Preload files this way (Lua):

    PreloadGenClear()
    PreloadGenStart()
    Preload(' ")\ncall otherFunction("123")\n//')
    PreloadGenEnd("its-a-feature.txt")

    Results in the following preload file code (Jass):

    function PreloadFiles takes nothing returns nothing

    call PreloadStart()
    call Preload( " ")
    call otherFunction("123")
    //" )
    call PreloadEnd( 754.6 )

    endfunction

    Note

    Game folder: Reforged: Warcraft III\_retail_\somefile.txt, instead of _retail_ there's also a _ptr_ game version currently. Classic: ?

    Note

    Mini tutorial:

    What are Preload files?

    Preload files instruct the game to pre-read a file/resources to avoid freezes/stutter during gameplay. It's done to move the file into OS cache. Blizzard used preload files to load all required files at map init. See blizzard.j or campaign maps.

    Create a preload file (Lua)

    PreloadGenClear()
    PreloadGenStart()
    -- call Preload("filename.ext") as often as you need, one call per file you add
    Preload("Textures\\Knight.blp")
    PreloadGenEnd("MyPreloadFile.txt")

    How to run a preload file

    This must be done manually:

    Preloader("MyPreloadFile.txt")
    

    Lua code in preload files?

    It is possible although in a very hacky way, described here. You need to use "//! beginusercode" to start a section containing Lua code and end it using "//! endusercode". It works because the code is compiled on the fly with Jass2Lua.

    Note

    See: PreloadEnd, PreloadStart, PreloadRefresh, PreloadEndEx, PreloadGenClear, PreloadGenStart, PreloadGenEnd, Preloader.

    Note

    Also see the documentation for Preloader for more info on the generated files.

Generated using TypeDoc