"magic" Variables
Posted: Tue Jul 19, 2016 12:23 pm
What magic variables does Factorio provide?
The 2 Magic variables that I know of are
__X__ = used in locale.cfg as parameters, where X is a number.
__name__ = Mostly used in data.lua and includes to locate resources, where name is the name of a mod. Example __core__, __base__, __ModNameFromInfo.json__
Are there any others? Is there any for retrieving info from info.json of the current mod?
examples:
__info_name__ returns the name from info.json of the current mod.
__info_version__ returns the version
__info_title__ returns the title
__info_*__ = where * is and of the named fields in info.json
If they don't exists then can they be added?
I, personally, have a use case for the __info_name__ and __info_version__. Would be nice maintain a special MODNAME and MODVERSION variables just to hold a copy of the name and version fields from info.json. Would be extremely hand for use by 3rd party libraries that mod authors include to help in creating mods.
A logging library could automagically know the name of the addon using it without being told so it can automatically add it to log outputs. Plus a whole host of other things I suddenly can't think of now that I put myself on the spot. :/
The 2 Magic variables that I know of are
__X__ = used in locale.cfg as parameters, where X is a number.
__name__ = Mostly used in data.lua and includes to locate resources, where name is the name of a mod. Example __core__, __base__, __ModNameFromInfo.json__
Are there any others? Is there any for retrieving info from info.json of the current mod?
examples:
__info_name__ returns the name from info.json of the current mod.
__info_version__ returns the version
__info_title__ returns the title
__info_*__ = where * is and of the named fields in info.json
If they don't exists then can they be added?
I, personally, have a use case for the __info_name__ and __info_version__. Would be nice maintain a special MODNAME and MODVERSION variables just to hold a copy of the name and version fields from info.json. Would be extremely hand for use by 3rd party libraries that mod authors include to help in creating mods.
A logging library could automagically know the name of the addon using it without being told so it can automatically add it to log outputs. Plus a whole host of other things I suddenly can't think of now that I put myself on the spot. :/