Skip to content

Advanced consumption - #2295

Open
ineveraskedforthis wants to merge 3 commits into
schombert:mainfrom
ineveraskedforthis:advanced-consumption
Open

Advanced consumption#2295
ineveraskedforthis wants to merge 3 commits into
schombert:mainfrom
ineveraskedforthis:advanced-consumption

Conversation

@ineveraskedforthis

Copy link
Copy Markdown
Contributor

Adds alternative way to define population needs via consumption categories defined with lua.
Allows to implement substitution in mods.
Calls specific lua function during the start of scenario creation to allow intervention into the process of building the scenario. Currently could be used for creation and setting properties of commodities, factories and consumption categories. Example is provided in comments in related lua file.

ankerl::unordered_dense::map<std::string, dcon::commodity_id> map_of_commodity_names;
ankerl::unordered_dense::map<std::string, dcon::factory_type_id> map_of_production_types;
ankerl::unordered_dense::map<std::string, dcon::factory_type_id> map_of_factory_names;
bool lua_factories;

@schombert schombert Aug 18, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be moved down to the both booleans below. It also probably needs to be given an initial value.

Edit: ah, I see that it gets set unconditionally, so it not having an initial value isn't a correctness issue.

} else if(consumption.category == 2) {
modifier = text::produce_simple_string(state, "alice_pop_details_lx_short");
} else {
modifier = std::to_string(consumption.category - 3);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it possible for people to give names to the additional categories, maybe something like text::produce_simple_string(state, "alice_pop_details_cat" + std::to_string(consumption.category - 3) + "_short"); assuming that the category ids are stable and predictable. Otherwise, a category id to string name map could be stored at creation time and this name could be inserted instead of the number to form a localization key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants