Skip to content
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
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Date: ????
- Fix a crash with Schall Machine Scaling
- Fixed a crash when cleaning up recycling recipes created by quality that had no results. Resolves https://github.com/pyanodon/pybugreports/issues/1284
- Added process to automatically set spoil level of spoilable items. Resolves https://github.com/pyanodon/pybugreports/issues/1260
- Added py.global_prerequisite_replacer
- Updated metas LuaLS
---------------------------------------------------------------------------------------------------
Version: 3.0.39
Date: 2025-09-15
Expand Down
28 changes: 28 additions & 0 deletions lib/data-stage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,34 @@ py.global_item_replacer = function(old, new, blackrecipe)
end
end

---replaces every instance of the old prerequesite with the new one. if the new one is omitted, removes the old prerequesite instead
---@param old string
---@param new? string
py.global_prerequisite_replacer = function(old, new)
if not data.raw.technology[old] then
log("WARNING @ py.global_prerequisite_replacer(): Technology " .. old .. " does not exist")
return
end
if new and not data.raw.technology[new] then
log("WARNING @ py.global_prerequisite_replacer(): Technology " .. new .. " does not exist")
return
end
if new then
for _, tech in pairs(data.raw.technology) do
for i, prereq in pairs(tech.prerequisites or {}) do
if prereq == old then
tech.prerequisites[i] = new
break
end
end
end
else -- no need to do fancy checks, just remove it
for tech in pairs(data.raw.technology) do
TECHNOLOGY(tech):remove_prereq(old)
end
end
end

---adds a small icon to the top right corner of a recipe
---@param recipe data.RecipePrototype
---@param corner table
Expand Down