Text string, supposed to be a file path to be preloaded. Max length: 259 characters (see Windows MAX_PATH).
It does two things:
- Try to read the file, if "Allow Local Files" is enabled then also searches in the game folder
- Append filename to preload buffer
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().
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
Game folder: Reforged:
Warcraft III\_retail_\somefile.txt, instead of
_retail_there's also a
_ptr_game version currently. Classic: ?
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:
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.
Also see the documentation for
Preloaderfor more info on the generated files.
- return type
- Source code
native Preload takes string filename returns nothing