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

Backport tool charge helpers #391

Open
wants to merge 2 commits into
base: 1.2.x
Choose a base branch
from
Open

Backport tool charge helpers #391

wants to merge 2 commits into from

Conversation

S-S-X
Copy link
Member

@S-S-X S-S-X commented Jan 2, 2025

Base branch 1.2.x is selected just for sane comparison.

This PR backports following features from (atow) master branch to current 1.2.2 stable release:

  • technic.get_RE_charge(itemstack)
    • Returns current charge level of tool.
  • technic.set_RE_charge(itemstack, charge)
    • Sets tool charge level.
  • technic.use_RE_charge(itemstack, charge)
    • Attempt to use charge and return true/false indicating success.
    • Always succeeds without checking charge level if creative is enabled.

Aliases that are not in Technic Plus Beta but lately added to original Technic, happily had same interface as above stuff:

  • technic.get_charge
  • technic.set_charge

Tool definition:

  • <tooldef>.technic_get_charge(stack).
  • <tooldef>.technic_set_charge(stack, charge).

Additions

But why?

Mostly because following PR shows that we're bit too far behind with 1.2.x and 2.x would be a fairly big leap forward, there's version specific code for three versions (and this change would allow dropping one of those):

Not included simple things that could be easily have been backported for compatibility would be at least following tool def functions (just copypasta from master docs):

  • For tool charger mods it is recommended to use <tooldef>.technic_get_charge(stack) instead.
  • For tool charger mods it is recommended to use <tooldef>.technic_set_charge(stack, charge) instead.

This probably should not be merged but instead

in case this gets approved it should make a new release branch, tag and cdb release.
Though in case someone argues this is a bug fix then yeah, 1.2.3 would be fine too.

@S-S-X S-S-X added the Compatibility Aims to improve compatibility with something. label Jan 2, 2025
@S-S-X
Copy link
Member Author

S-S-X commented Jan 2, 2025

For test failures: integration tests probably shouldn't be touched and can't really be fixed, not worth it.
Pending luacheck... well that has not been even added yet (at this point it is still lint, not luacheck), or more like not yet renamed.
Simple mineunit checks and 1.2 luacheck passes. Though neither will actually test this stuff as here it is just for mod compatibility.

@S-S-X S-S-X added the Maintenance Stable version maintenance tasks, not for master branch label Jan 4, 2025
@OgelGames
Copy link
Contributor

Sounds good 👍 I'd be fine with bumping the version to 1.3.x for this, it's much more than a bug fix.

@S-S-X
Copy link
Member Author

S-S-X commented Jan 25, 2025

Added:

  • <tooldef>.technic_get_charge(stack).
  • <tooldef>.technic_set_charge(stack, charge).
  • technic.use_charge alias.

Updated PR description to reflect these additions.

edit. Rebasing to keep test / workflow changes separated from actual functionality and documentation.

S-S-X added 2 commits January 25, 2025 16:40
Tests for power tools

Basic tests for technic_get_charge, technic_set_charge
set_charge/get_charge from other Technic mod

Battery box technic_get_charge / technic_set_charge
Copy link

Click for detailed source code test coverage report

Test coverage report for technic 52.77% in 97/98 files:

File                                      Hits Missed Coverage
--------------------------------------------------------------
max_lag.lua                               12   0      100.00%
machines/register/init.lua                22   0      100.00%
machines/register/grinder.lua             6    0      100.00%
machines/register/freezer_recipes.lua     13   0      100.00%
machines/register/freezer.lua             6    0      100.00%
machines/register/extractor.lua           6    0      100.00%
machines/register/electric_furnace.lua    6    0      100.00%
machines/register/compressor.lua          6    0      100.00%
machines/register/centrifuge.lua          6    0      100.00%
machines/MV/solar_array.lua               9    0      100.00%
machines/MV/init.lua                      17   0      100.00%
machines/MV/grinder.lua                   8    0      100.00%
machines/MV/generator.lua                 9    0      100.00%
machines/MV/freezer.lua                   8    0      100.00%
machines/MV/extractor.lua                 8    0      100.00%
machines/MV/electric_furnace.lua          8    0      100.00%
machines/MV/compressor.lua                8    0      100.00%
machines/MV/centrifuge.lua                14   0      100.00%
machines/MV/battery_box.lua               17   0      100.00%
machines/MV/alloy_furnace.lua             8    0      100.00%
machines/LV/solar_array.lua               8    0      100.00%
machines/LV/init.lua                      16   0      100.00%
machines/LV/grinder.lua                   9    0      100.00%
machines/LV/generator.lua                 9    0      100.00%
machines/LV/extractor.lua                 9    0      100.00%
machines/LV/electric_furnace.lua          8    0      100.00%
machines/LV/compressor.lua                13   0      100.00%
machines/LV/battery_box.lua               15   0      100.00%
machines/LV/alloy_furnace.lua             8    0      100.00%
machines/HV/solar_array.lua               8    0      100.00%
machines/HV/init.lua                      12   0      100.00%
machines/HV/grinder.lua                   8    0      100.00%
machines/HV/generator.lua                 9    0      100.00%
machines/HV/electric_furnace.lua          8    0      100.00%
machines/HV/compressor.lua                8    0      100.00%
machines/HV/battery_box.lua               17   0      100.00%
legacy.lua                                33   0      100.00%
config.lua                                25   0      100.00%
items.lua                                 125  2      98.43%
machines/register/compressor_recipes.lua  36   1      97.30%
machines/register/solar_array.lua         40   2      95.24%
machines/MV/cables.lua                    32   2      94.12%
machines/LV/cables.lua                    32   2      94.12%
machines/HV/cables.lua                    31   2      93.94%
tools/init.lua                            14   1      93.33%
crafts.lua                                117  10     92.13%
machines/register/alloy_recipes.lua       27   3      90.00%
machines/register/grindings.lua           42   5      89.36%
init.lua                                  29   4      87.88%
machines/other/init.lua                   7    1      87.50%
machines/register/grinder_recipes.lua     104  16     86.67%
machines/register/battery_box.lua         250  42     85.62%
machines/register/cables.lua              180  41     81.45%
tools/flashlight.lua                      69   17     80.23%
machines/network.lua                      264  67     79.76%
register.lua                              30   10     75.00%
machines/register/centrifuge_recipes.lua  21   7      75.00%
radiation.lua                             257  93     73.43%
machines/switching_station.lua            77   28     73.33%
machines/LV/lamp.lua                      133  52     71.89%
effects.lua                               5    2      71.43%
machines/other/coal_furnace.lua           2    1      66.67%
machines/switching_station_globalstep.lua 39   22     63.93%
machines/MV/wind_mill.lua                 43   25     63.24%
machines/LV/solar_panel.lua               26   18     59.09%
machines/MV/hydro_turbine.lua             40   29     57.97%
machines/LV/water_mill.lua                40   32     55.56%
machines/MV/tool_workshop.lua             49   41     54.44%
machines/supply_converter.lua             76   67     53.15%
tools/cans.lua                            53   48     52.48%
machines/register/recipes.lua             32   30     51.61%
tools/mining_lasers.lua                   39   40     49.37%
machines/LV/geothermal.lua                38   39     49.35%
machines/register/machine_base.lua        98   103    48.76%
tools/vacuum.lua                          19   21     47.50%
tools/tree_tap.lua                        24   27     47.06%
machines/power_monitor.lua                37   42     46.84%
machines/other/coal_alloy_furnace.lua     56   70     44.44%
machines/register/generator.lua           91   114    44.39%
machines/init.lua                         42   53     44.21%
machines/other/injector.lua               45   62     42.06%
helpers.lua                               55   85     39.29%
machines/other/constructor.lua            50   84     37.31%
machines/register/alloy_furnace.lua       10   20     33.33%
tools/chainsaw.lua                        40   83     32.52%
tools/sonic_screwdriver.lua               18   40     31.03%
machines/register/common.lua              38   87     30.40%
machines/HV/forcefield.lua                79   181    30.38%
machines/HV/nuclear_reactor.lua           90   235    27.69%
util/throttle.lua                         3    8      27.27%
tools/mining_drill.lua                    76   226    25.17%
machines/HV/quarry.lua                    69   218    24.04%
machines/LV/music_player.lua              22   70     23.91%
machines/other/anchor.lua                 14   74     15.91%
machines/compat/digtron.lua               2    11     15.38%
tools/prospector.lua                      16   92     14.81%
machines/register/extractor_recipes.lua   6    57     9.52%
machines/other/frames.lua                 0    553    0.00%

Raw test runner output for geeks:

++ Executing suite spec/building_spec.lua
++ Executing suite spec/network_spec.lua
++ Executing suite spec/supply_converter_spec.lua◌
++ Executing suite spec/tools_spec.lua
62 successes / 0 failures / 0 errors / 1 pending : 10.972292 seconds

Pending → spec/supply_converter_spec.lua @ 99
Supply converter building overloads network
spec/supply_converter_spec.lua:99: overload does not work with supply converter

@S-S-X
Copy link
Member Author

S-S-X commented Jan 25, 2025

@S-S-X S-S-X requested a review from OgelGames January 25, 2025 14:59
@S-S-X
Copy link
Member Author

S-S-X commented Jan 25, 2025

I think this should be ready for release.

For review, as I imported test fixtures and other test stuff from master and updated workflows there many test related changes.
For clean view it is possible to select just "Backport tool charge helpers" commit, that one contains all the mod related changes and excludes test related updates.

For failing luacheck, failure is completely unrelated to these changes and I really don't want to include fix in this change set. Also don't want to hide that failure, in my opinion better just keep it as is for now and let it report failure.

For failing integration tests, should those be disabled, left as is (ignored) or is there easy way to fix them for 1.x branch? I guess @BuckarooBanzay might know the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compatibility Aims to improve compatibility with something. Maintenance Stable version maintenance tasks, not for master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants