Short Description: A modding utility to access raw prototype data from data.raw within control.lua. Prototypes are only loaded as required, cached to the save game for as long as the mods state is unchanged, and the cache is shared across all mods. To use: remote.call("data-raw", "prototype", "car", "tank"). See readme for more details.
Name: data-raw-prototypes
Factorio Version: 0.14
Mod State: Beta
Dependencies: Base
Author: Earendel
Downloads: Mod Portal
Licence: See below
Long Description
The mod uses loadstring() to load parts of data.raw that are available to data.lua files. The data is saved in a way that allows loading of specific prototypes instead of needing to load the entire data.raw in one go. This means that if you only need to load a single car type entity, or only need to load a few types of ammo it won’t cause the game to hang for a long time. This mod also uses a cache that lasts as long as prototypes are unchanged, so even if you load the same prototype multiple times (even across different save/load sessions) then the load call will only be performed once. Additionally, this mod provides interfaces for other mods to access the same cache, so even if multiple mods request the same prototype, that prototype will only be loaded once.
Instructions
Access a raw prototype
Code: Select all
remote.call("data-raw", "prototype", "car", "tank")
-- returns the raw prototype from data.raw.car.tank
-- replace "car" with the desired prototype type and "tank" with the desired prototype name.
Code: Select all
remote.call("data-raw", "prototypes_of_type", "car")
-- returns the raw prototype dictionary from data.raw.car -- e.g: {car = {car_prototype...}, tank = {tank_prototype...}, ...}
-- replace "car" with the desired prototype type.
Code: Select all
remote.call("data-raw", "prototypes_list")
-- returns a dictionary of prototype types, each containing a list of prototype names of that type -- e.g: {car = {"car", "tank", ...}, gun = {"shotgun", ...}, ...}
The 'game' variable must have loaded in order to access the prototypes, see the http://lua-api.factorio.com/latest/Data-Lifecycle.html for more details.
Avoid using data-final-fixes.lua to alter prototypes, use data-updates.lua instead, otherwise if your mod is processed after this mod then any changes will not be loaded.