Changes between Version 17 and Version 18 of Random_Map_Generator_Internals
- Timestamp:
- 05/28/24 21:35:39 (3 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Random_Map_Generator_Internals
v17 v18 55 55 == Engine-script interface == 56 56 57 The CMapGenerator provides a minimal interface to the random map scripts. One is a global variable `g_MapSettings` which specifies all the map settings as created by game setup. CMapGenerator also exposes some JavaScript functions: 57 After the script file is run the engine calls `GenerateMap`. `GenerateMap` is searched in the global object. The argument to `GenerateMap` is an object containing the map settings. The map settings are created by the game setup. 58 When `GenerateMap` `yield`s a it's progress (an integer from 1 to 100) the progress bar is updated accordingly. 59 The (final) `return`ed map eitherhas to be of the format described below or have a function `MakeExportable` which returns an object of that format. This is done so that libraris can do some cleanup in `MakeExportable`. 60 61 The engine exposes some !JavaScript functions: 58 62 * `Engine.LoadLibrary(name)` - load a library, choosing the API to which a random map script will have access, e.g. "rmgen". 59 * `Engine.ExportMap(data)` - export generated map data from the scripts to the engine.60 * `Engine.SetProgress(percent)` - set the map generation progress percentage, so the loading screen progress bar can be updated. Percentage must be an integer 1-100.61 63 * `Engine.GetCivData()` - returns an array of civilization data from {{{/civs/*.json}}}, which is useful for determining civ-specific units and structures. 62 64 * `Engine.GetTemplate(templateName)` - returns an array containing the data of the requested template. 63 65 * `Engine.MaybeGC()` - possibly run the garbage collector. 66 67 The use of this functions is deprecated. The generator based interface described above should be used. 68 * `Engine.ExportMap(data)` - export generated map data from the scripts to the engine. 69 * `Engine.SetProgress(percent)` - set the map generation progress percentage, so the loading screen progress bar can be updated. Percentage must be an integer 1-100. 70 There is also a global `g_MapSettings` which is also deprecated. 71 64 72 65 73 == Data format ==