"magic" Variables

Place to get help with not working mods / modding interface.
credomane
Filter Inserter
Filter Inserter
Posts: 321
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

"magic" Variables

Post by credomane »

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. :/
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: "magic" Variables

Post by aubergine18 »

Apologies for the necro, but there's at least one more:

__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.
Post Reply

Return to “Modding help”