Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Erkigmo committed Dec 5, 2024
2 parents 1fd1cbf + b84b00b commit cd98002
Show file tree
Hide file tree
Showing 94 changed files with 5,306 additions and 9,122 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# format everything
5496100574ad3dafdcb31fc6768bd710cc493338
4 changes: 3 additions & 1 deletion .github/workflows/factoriotest-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request_target:
branches:
- main
- Frozen
paths-ignore:
- 'cached-configs/**'

Expand All @@ -13,8 +14,9 @@ permissions:
jobs:
test-pull-request:
name: PR
uses: pyanodon/pyanodontests/.github/workflows/pytest.yml@v1
uses: pyanodon/pyanodontests/.github/workflows/pytest.yml@v1.5.0
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.head.sha }}
test_branch: ${{ github.head_ref || github.ref_name }}
secrets: inherit
5 changes: 3 additions & 2 deletions .github/workflows/factoriotest-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- Frozen
paths-ignore:
- 'cached-configs/**'

Expand All @@ -13,9 +14,9 @@ permissions:
jobs:
test-push:
name: Push
uses: pyanodon/pyanodontests/.github/workflows/pytest.yml@v1
uses: pyanodon/pyanodontests/.github/workflows/pytest.yml@v1.5.0
with:
repository: ${{ github.repository }}
ref: ${{ github.sha }}
test_branch: ${{ github.head_ref || github.ref_name }}
secrets: inherit

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

/.vscode
50 changes: 39 additions & 11 deletions PyPP-Regen-New.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
[Boolean]$QuietMode = $false
)

# Here's how this script works and why:
function Print-PyExplanation{
Write-Host "Pyanodon's PostProcessing is a mod that changes a lot about the tech tree. In particular, it ensures that if you get a recipe from a tech, then you must already have a way to make all the ingredients for that recipe. It also does things like automatic tech scaling. However, it had two problems: 1) it was slow to start up, and 2) it also tried to edit techs from other mods, which often resulted in problems. The cache files solve both problems: this script loads a specific subset of the Py mods, applies the tech tree correction and stores the modifications made in a cache file. This cache file can then be loaded instead of recalculating the tech tree corrections from scratch. In particular, this is much faster, and if a player loads other mods, those mods won't have their tech trees modified."
Write-Host ""
Write-Host "This script will load Factorio from the command line, capture the tech tree changes and save them in a file. You can pick the mod sets that you want a cache file for. This is not limited to the Py mods: you can add your own mods on top of this, such as PyBlock, and generate a cache file. These cache files can then be registered with PyPostProcessing in the data-update stage of your mod, so that players using your mod will use your cache file, and not the preconfigured ones. You can check for example data-updates.lua in the dev version of PyCoalProcessing to see how to register a cache file."
Write-Host ""
Write-Host "This script has two main menus. The first menu allows you to set variables, in particular the Factorio paths. If you want to save time, you can also call this script with parameters like so:"
Write-Host ""
Write-Host "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file ""C:\Users\<username>\AppData\Roaming\Factorio\packs\PyanodonGit\pypostprocessing\PyPP-Regen-New.ps1"" -FactorioPath ""C:\Program Files (x86)\Steam\steamapps\common\Factorio\bin\x64\factorio.exe"" -FactorioDataPath ""C:\Users\<username>\AppData\Roaming\Factorio"" -FactorioModsPath ""C:\Users\<username>\AppData\Roaming\Factorio\packs\PyanodonGit"
Write-Host ""
Write-Host "On the way to the second menu, this script detects existing cache files. The second menu then allows you to configure what cache file should be (re)generated. The main tool for this is that you are able to enable and disable cache files using a regex. Only enabled cache files will be (re)generated. Since this is a regex, you have to escape backslashes in Windows paths! It's also nice to know that entering an empty value will enable or disable all mods (since they all match the empty regex)."
Write-Host ""
Write-Host "The second menu also allows you to add your own cache file. You will have to enter the folder it will end up in, and then you can select a 'base': a starting set of mods to be used for your new cache files, taken from the existing cache files. You can then add and remove any installed mods to this set."
Write-Host ""
}

class CacheFile{
[string[]]$Mods
[string]$Path
Expand Down Expand Up @@ -36,12 +52,6 @@ function Print-PySettings{
Write-Host "Quiet mode is $QuietMode"
}

function Print-PyExplanation{
Write-Host "Pyanodon's PostProcessing is a mod that changes a lot about the tech tree. In particular, it ensures that if you get a recipe from a tech, then you must already have a way to make all the ingredients for that recipe. It also does things like automatic tech scaling. However, it had two problems: 1) it was slow to start up, and 2) it also tried to edit techs from other mods, which often resulted in problems. The cache files solve both problems: this script loads a specific subset of the Py mods, applies the tech tree correction and stores the modifications made in a cache file. This cache file can then be loaded instead of recalculating the tech tree corrections from scratch. In particular, this is much faster, and if a player loads other mods, those mods won't have their tech trees modified."
Write-Host ""
Write-Host "This script will load Factorio from the command line, capture the tech tree changes and save them in a file. You can pick the mod sets that you want a cache file for. This is not limited to the Py mods: you can add your own mods on top of this, such as PyBlock, and generate a cache file. These cache files can then be registered with PyPostProcessing in the data-update stage of your mod, so that players using your mod will use your cache file, and not the preconfigured ones. You can check for example data-updates.lua in the dev version of PyCoalProcessing to see how to register a cache file."
}

function Choose-FactorioPath{
param(
[ref][string]$path,
Expand Down Expand Up @@ -71,7 +81,7 @@ function Choose-PySettingsMenu{
1 {Choose-FactorioPath ([ref]$FactorioDataPath) "data path"}
2 {Choose-FactorioPath ([ref]$FactorioModsPath) "mods path"}
3 {
$QuietMode = !$QuietMode
$Global:QuietMode = !$QuietMode
Write-Host "Toggled quiet mode, new value is $QuietMode"
}
4 {Print-PyExplanation}
Expand Down Expand Up @@ -223,25 +233,43 @@ function Choose-PyCacheFiles{
}
}

function Space-Mode{
$Regex = 'pystellarexpedition'
foreach ($CacheFileModList in $CacheFileModLists)
{
if ($CacheFileModList.Path -match $Regex){
$CacheFileModList.Enabled = $true
Write-Host "Matched $($CacheFileModList.Path)"
}else{
$CacheFileModList.Enabled = $false
}
}
}

function Choose-PyModSetMenu{
$change_sets = New-Object System.Management.Automation.Host.ChoiceDescription "&Change cache file sets", "Change what cache files to generate"
$print_sets = New-Object System.Management.Automation.Host.ChoiceDescription "&Print cache files", "Print all cache files that will get generated"
$print_settings = New-Object System.Management.Automation.Host.ChoiceDescription "Print &settings", "Print all current settings."
$print_settings = New-Object System.Management.Automation.Host.ChoiceDescription "P&rint settings", "Print all current settings."
$explain = New-Object System.Management.Automation.Host.ChoiceDescription "E&xplain", "Explain what this script is for."
$generate = New-Object System.Management.Automation.Host.ChoiceDescription "&Generate", "Begin cache file generation."
$space = New-Object System.Management.Automation.Host.ChoiceDescription "&Space Mode", "Quickly generate cache files just for pySE and pyAliens."
$exit = New-Object System.Management.Automation.Host.ChoiceDescription "&Exit", "Exit this script."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($change_sets, $print_sets, $print_settings, $explain, $generate, $exit)
$options = [System.Management.Automation.Host.ChoiceDescription[]]($change_sets, $print_sets, $print_settings, $explain, $space, $generate, $exit)

$done = $false
while (!$done){
$decision = $host.ui.PromptForChoice("Py cache file generation", "Pick an option", $options, 4)
$decision = $host.ui.PromptForChoice("Py cache file generation", "Pick an option", $options, 5)
switch ($decision)
{
0 {Choose-PyCacheFiles}
1 {Print-PyCacheFiles}
2 {Print-PySettings}
3 {Print-PyExplanation}
5 {
4 {
Space-Mode
$done = $true
}
6 {
Write-Host "Exiting early, bye!"
Exit
}
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# pY Post-processing
## Bug Reports and Feedback

Please use a dedicated repository [pybugreports](https://github.com/pyanodon/pybugreports) for bug reports and feedback.

## Contributing

When making a Pull Request, please also update `changelog.txt` with the summary of your changes.
If there is no upcoming version in the file, then the format is as follows:
```
---------------------------------------------------------------------------------------------------
Version: a.b.c
Date: ???
Changes:
- The summary of your changes
---------------------------------------------------------------------------------------------------
```
Loading

0 comments on commit cd98002

Please sign in to comment.