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. :/
"magic" Variables
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: "magic" Variables
Apologies for the necro, but there's at least one more:
__CONTROL__ -- see viewtopic.php?p=200889#p200889
__CONTROL__ -- see viewtopic.php?p=200889#p200889
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.