Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate feature_flags global in lua context #324

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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