Skip to content

Commit

Permalink
fix: populate feature_flags global in lua context
Browse files Browse the repository at this point in the history
  • Loading branch information
SWeini authored and shpaass committed Oct 23, 2024
1 parent 09fbe40 commit 01dd67d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Yafc.Parser/FactorioDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ internal partial class ModInfo : IDisposable {
private readonly List<(string mod, bool optional)> parsedDependencies = [];
private readonly List<string> incompatibilities = [];

public bool quality_required { get; set; }
public bool rail_bridges_required { get; set; }
public bool space_travel_required { get; set; }
public bool spoiling_required { get; set; }
public bool freezing_required { get; set; }
public bool segmented_units_required { get; set; }
public bool expansion_shaders_required { get; set; }

public ZipArchive? zipArchive;
public string folder;

Expand Down
11 changes: 11 additions & 0 deletions Yafc.Parser/LuaContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ public LuaContext() {

SetGlobal("mods", mods);

var featureFlags = NewTable();
featureFlags["quality"] = FactorioDataSource.allMods.Any(x => x.Value.quality_required);
featureFlags["rail_bridges"] = FactorioDataSource.allMods.Any(x => x.Value.rail_bridges_required);
featureFlags["space_travel"] = FactorioDataSource.allMods.Any(x => x.Value.space_travel_required);
featureFlags["spoiling"] = FactorioDataSource.allMods.Any(x => x.Value.spoiling_required);
featureFlags["freezing"] = FactorioDataSource.allMods.Any(x => x.Value.freezing_required);
featureFlags["segmented_units"] = FactorioDataSource.allMods.Any(x => x.Value.segmented_units_required);
featureFlags["expansion_shaders"] = FactorioDataSource.allMods.Any(x => x.Value.expansion_shaders_required);

SetGlobal("feature_flags", featureFlags);

LuaCFunction traceback = CreateErrorTraceback;
neverCollect.Add(traceback);
lua_pushcclosure(L, Marshal.GetFunctionPointerForDelegate(traceback), 0);
Expand Down

0 comments on commit 01dd67d

Please sign in to comment.