LuaRendering get ids of current scenario ("level")

Post Reply
Bilka
Factorio Staff
Factorio Staff
Posts: 3138
Joined: Sat Aug 13, 2016 9:20 am
Contact:

LuaRendering get ids of current scenario ("level")

Post by Bilka »

Split off suggestion from unrelated post
credomane wrote:
Thu Aug 06, 2020 2:15 am
It would be nice if there was a magic variable like __SCENARIO__ that would always refer to the scenario (be it freeplay, sandbox, campaign, or some other custom scenario). That way sound.get_all_ids(__SCENARIO__) would return only ids made by the scenario and not any created by a mod. If there is one what is it and where is it documented? Only way I've considered on how to do it with LuaRendering is the hardway:

Code: Select all

--Pseudo code
local allids=rendering.get_all_ids();
local allmodids={};
local scenarioids={};
for name, _ in pairs(game.active_mods) do
  local modids=rendering.get_all_ids(name);
  for _,v in pairs(modids) do
    allmodids[v]=true;
  end
end

for _,v in pairs(allids) do
  if type(allmodids[v]) == nil do
    table.insert(scenarioids,v);
  end
end

--scenarioids now only has ids that don't belong to mods. Assuming my psuedo code is correct.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaRendering get ids of current scenario ("level")

Post by Rseding91 »

I made the get-all-ids and clear() function accept an empty string to mean "level".
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Implemented mod requests”