Adds options to change many stack sizes (and fluid capacities). Fork of ReStack to improve compatibility with other mods and add new features

2 years ago
0.17 - 1.1


Version: 2021.10.2201
    - Yuoki (intermediates and raw-materials)
    - 5dim_core (renamed subgroups like GEARS and WIRES and SULFUR OR SOMETHING)
    - results vs result detection (e.g. minable.results vs minable.result)
    - YYYY.MM.DDSS - subversions for more than 1 in a day
    - probably introduced some more bugs
    - structure to expand existing search patterns
    - one-of-many inclusive, besides the existing not-among-these exclusive
    - removed some code that wasn't needed any more
    - search_dictionary.lua file for the improved search flexibility
Version: 2021.02.06
    - changed version format to YYYY.MM.DD
  Bug Fixes:
    - not-stackable flag is checked, right before assignment, and prints a log message
    - dig() can now handle names with +
Version: 1.1.1
Date: 2020-11-23
    - Factorio 1.1 release
    - lazy and releasing new 1.0.1 at the same time
    - 1.0.0 was not published
    - some Angels, Bobs, and Mobile_Factory stack increases. Checkboxes near bottom
Version: 1.0.0
Date: 2020-11-23
    - remove seldom used old code (wasn't dead!) while digging for a value (thanks waltermundt)
  Bug Fixes:
    - 500 or less capacity/barrel triggers the recipe change, not 499 or less
Version: 0.18.36
Date: 2020-04-20
    - Added setting for logging the changes... should've been added a long time ago. (default false for now)
  Bug Fixes:
    - Don't set stack *smaller* than what's there (needed for Merging Chests compatibility)
        (might make a setting that defaults to true - I could see some people liking a smaller-stack challenge)
Version: 0.18.35
Date: 2020-01-24
  Bug Fixes:
    - loader-1x1's now caught
    - don't stack vehicles with equipment grids
Version: 0.18.34
Date: 2020-01-24
  Bug Fixes:
    - fuel values for barrelable fuels (no error now)
Version: 0.18.33
Date: 2020-01-24
  Bug Fixes:
    - dig() now supports whitespace characters
          (ran into a name with a space)

    - change solar panels and accumulators so only the name is used.
        a mod added an iron plate as the mining result. again.

    - .18 version uploaded. Good luck if it works.
        versions will now go X.MAJOR.UPDATES -> 0, 0.18, version 33

    - update gallery images

    - removed dectorio optional dependency. If this breaks it, please post to discussions.
Version: 0.0.32
Date: 2019-11-27
    - improve safety of dig for "invalid" characters - may change to support anything
         that is not . or []

    - battery stack size option. it is a raw-material and not intermediate product
              user request
              (near bottom, above multipliers)
Version: 0.0.31
Date: 2019-11-27
  Bug Fixes:
    - AddFromTable didn't support a table of names, so wire stack size was failing
Version: 0.0.30
Date: 2019-11-27
  Bug Fixes:
    - dig() now catches semicolons. Compatibility tweak for Cursed Filter Mining Drill
                    (thanks jamiech1 for reporting)
Version: 0.0.29
Date: 2019-11-25
  Bug Fixes:
    - Added unique-value function to SearchByCategory (function itself in undepend.lua)
            modifies a table to only have unique values (in this case, item paths)

      warptorio2 adds multiple "storage tanks", so my capacity changer
            was exponentiating the capacity of the base storage tank (the mining result)

      leaves some "dead" code which ignored a stack change from the same place
            (the same item was repeated in the search results -
              which hopefully doesn't happen now)

      also affects subitems, so they're not repeated either
        I don't remember doing any matching of items and subitems in case there was an item
        found which didn't have a subitem (it would mis-match the indices)

      this should fix any search which results in the same items (mining_result
           being the most relevant, another mod had new fuel cells that burnt into
           the normal uranium burnt cells, which caused a repeated message before)

           specifically, warptorio storage tanks, and it may also be warptorio's fuel cells
           Merging Chests may be silently affected, since each chest mines a steel chest
Version: 0.0.28
Date: 2019-11-24
  Bug Fixes:
    - #idon'tknowhowluaworks, fixing last fix
Version: 0.0.27
Date: 2019-11-24
  Bug Fixes:
    - launch products weren't being excluded. My science packs were set to 500. Ow.
Version: 0.0.26
Date: 2019-11-21
  Bug Fixes:
    - barrel capacity was only changing if the stack size was assigned
        optera's barrel code changes barrels needed for recipe
        not sure what the minimum stack size is for capacity changes (mine did 10 barrels)
Version: 0.0.25
Date: 2019-11-12
    - beneath intermediate-products, an option to restore stack size of satellites to 1
            (recommended if you care about balance, default true)

  Bug Fixes:
    - stacks of satellites return too much science for the rocket silo to hold
        not sure how to fix other than increasing rocket silo inventory,
        restricting satellite size, or stacking space science to high amounts

        if satellite stack size isn't 1 (and force option is false),
              silo gets more result slots.
        matches the stack size of satellites (hack solution)

        bug caused by changing intermediate-product size

        hope you all didn't waste too many satellites

    - fix previous changelog version so it loads in game
Version: 0.0.24
Date: 2019-11-07
    - solar panels and accumulators in a single option. found by category
               have fun, megabasers

    - I think ModMash fills loot crates in proportion to the stack size of an item.
              Changing the stack size makes a lot of loot.
Version: 0.0.23
Date: 2019-11-07
  Bug Fixes:
    - wagons and car stacks were broken

    - need to stop rushing bug fixes, I keep forgetting to change the version number or
             other little things
Version: 0.0.22
Date: 2019-11-06
  Bug Fixes:
    - I think the auto-barrel conditions were wrong for capacities. Nobody reported anything,
         but I'm making it explicit so I stop confusing myself

    - re-upload: military.lua was completely broken! tell me these things please!

    - change capacity setting text in log for tanks and wagons.
               was changing capacity correctly, just printing wrong
Version: 0.0.21
Date: 2019-11-06
  Bug Fixes:
    - priority yielding was wrong - didn't have things correct for all cases

    - user.lua. I'll never use it, can copy in custom changes
           has a skeleton for item searching (better to compare entries in other files)

    - modules\softchanges.lua. Moved the soft changes from data-final-fixes.lua to there

    - raw-resource setting. Soft. I have a few items I'm playing with that
           aren't caught in other changes. not recommended to use.
               finds: ores, fish, wood, but also some mod items that otherwise go unchanged

    - changed readme_advanced.txt because I've made changes since it was last edited.
           small changes to readme.txt as well

    - removed a lot of commented sections of old code

    - recently changed inserters to exclude miniloader-inserters
          (what does the moving)
          loaders are caught by name and -loader is removed,
              if we can't find the item on first try
              (catches the name mini-loader-loader by name, as the mining result is WOOD)

    - changed containers to exclude the mining result if the subgroup isn't "container"
            (a mod I'm using has a custom chest which mined up an iron-plate)

    - if two changes have the same stack size (not evaluating set vs multiply)
          then the existing change is preferred (it short-circuits the "conflict")

    - two negative priorities don't produce a conflict (right now). the first
           is explicitly preferred. thinking of having resolution choice in options
                   (conflict, prefer first, last, greatest, least)

           not to be confused with a negative stack size, which assigns a high priority

    - intermediate products now have "from" as intermediate-product, instead of intermediate

    - if an "ore" comes from a secondary source (turning one ore into another),
          it won't have come from mining, and won't be changed by ores

    - the raw-resource category includes mined ores, raw-fish, wood,
         and from a mod I'm using, spawners, alien ore/artifacts, and titanium-ore.
      since multiplying raw-materials is passive and last by default, it can be used with
         other categories (wood, ores, fish, in order of place in settings)
Version: 0.0.20
Date: 2019-11-04
    - Changed license in recipe.lua. Technically I was in violation of the MIT License.
          removed version .19 for download.
Version: 0.0.19
Date: 2019-11-04
    - Accidentally left in recipes.lua (plural). Removed.

    - in examples, that specific example finds recipes, not ingredients
         I don't have an example for finding the ingredient paths, but that's "experimental"
                i.e. maybe broken, and definitely easily breakable
Version: 0.0.18
Date: 2019-11-04
    - examples.txt for unconventional things. Might include normal stuff.

    - testing.lua for me testing things (should be empty after I upload).
            Might include a separate override.lua that I never use,
            so people can copy-in customizations from one version to another

    - modules\recipe.lua because lib was getting polluted
        might move other stuff around, because some stuff is more for pathing

    - Added ability to find recipes that have a specific ingredient
            looks in ingredient_name and only returns recipe if it matches

    - Yikes! added ability to change one specific ingredient to another
          have to do so safely because Factorio has a fit for duplicate ingredients

          by default, if a duplicate ingredient is detected, it just adds
              the amount of the ingredient to change to the existing ingredient

          see examples.txt for details

    - as always, if something isn't behaving as expected or you get errors, please report

    - in a recent version, I switched the requirement for a property and property_value
        to just a property. If there's no property_value, it's all-inclusive (must exist)

    - moved build_category (in BuildThingPath) from the search side
                    to the "table to dig in" side.
        if it was nil, I'll get returned nil anyway. This is so I don't dump data.raw
                10000x if I want to see where dig started each digging pass

    - "ammo_type.category" is the property that descibes what
           kind of ammunition something is (not ammo.category)
           Don't EVER use anything directly from this changelog
Version: 0.0.17
Date: 2019-11-02
    - moved core_table definition to lib. Someone trying to use my lib would
         get an error since I use it all over the place
Version: 0.0.16
Date: 2019-11-02
    - Passing a second (anything) argument to SelectItemsByRecipeResult will return two tables:
        First table is table of recipes (table of paths)
        Second is table of results

    - Can do the same thing for SelectItemsByRecipeInput too.

          See intermediates.lua for examples on how to use

    - Fix previous changelog version number... again
Version: 0.0.15
Date: 2019-11-02
    - path.lua file
        contains a 'dig' function which takes a (table, "string") argument
            (the second argument can be a few other things, see function)

        having annoying ? field errors? use dig!
        if string looks like a path i.e. "mining.result" it will try to go into table.mining.result
        if the path doesn't exist along the way, returns nil instead having an error
        returns the value, which can be anything (table, string, number, etc).
            your responsibility to check it

        parses brackets and stuff to, but watch for un-escaped quotes if you're typing directly:
           "["mining"]["result"]" would cause errors. need "[\"mining\"][\"result\"]"

        pure numbers get treated as array elements, not strings.
            neat side effect: dig(table, "ingredients.1.1") looks for table.ingredients[1][1]
            dig(table, "ingredients[1][1]") still acts like a normal array-indexed path

        it also grabs hyphens and underscores. Hyphens aren't valid in normal paths.
                Don't care.

        commented out digdig(), which can use two strings from the global level
              (it's not really safe, but was easy enough to implement)

        because of the above two (2) additions, I could do digdig("data.raw", "rail-planner")
            I should be in the rail-planner category.

        some safety functions: if you go looking for a string, table, or number,
                but you run into nil, no fear!

            s_safe: returns the string or an empty string if it was nil
            t_safe: returns the table or an empty table if it was nil
            na_safe: returns the number or 0 (number is safe for adding/subtracting)
            nm_safe: returns the number or 1 (number is safe for multiplying/dividing)

        s_escape and s_unescape: escape a string and unescape it, for patterns
        unescape properly catches intentional percents
        they're small and should work fine, didn't test the functions (only the patterns)

        path.lua is anti-copywritten, and you can use it in your own projects freely

    - used dig, so now I can remove the subproperty field:
        search_property = "minable.result"
        or search_property = "ammo.category"

        removed subproperty in a bunch of places, and changed properties to be "thing.whatever"

    - nothing should be changed on the outside from this release, these are just code changes

    - if you have a mod like Merging Chests, steel-chest might come up a ton of times
          not an error, code was working correctly

    - if change for an item is coming from the same 'from' change, ignore it
                   (code ignore, not you)
Version: 0.0.14
Date: 2019-10-31
  Bug Fixes:
    - fix the broken recipes code
Version: 0.0.13
Date: 2019-10-31
  Bug Fixes:
    - there was an error in assigning priorities. Think I got it

    - might've fixed an error in an error message. Was changing a bunch of things
            and I don't care to check what the original line was

    - Fix version number of previous changelog

    - Filter can now act on search_* property, subproperty,
        and property_value if it has a second argument.
          this is so the item from the search can have a different filter than
                  the item found (I was doing weird stuff before)

          Needed for ores.
              Ores now match by a resource found, that's minable, with a result.
                   these are search_* keys and their value

          The resulting ore item is checked
            the subgroup cannot be missing, raw-material, or intermediate-product
              (All Minable adds resources that are plates, circuits, plastic bars, etc)

          previously ores only matched by name of the resource
                  (this was probably sufficient)

    - Updating search method and filter required a bunch of changes to definitions:
            property and property_value refer to the item

            search_property and search_value refer to what we're filtering
                 during the search

            these are strictly separated. There is no property_category anymore.
               I do not intend to support an explicit thing to get properties from.
               Search for the item, or search for another thing and retrieve an item.

            *property and *property_values are not strictly necessary
                if there's no property and no property value an item passes the filter
                one but not other doesn't make exact sense, so it will fail

            how we find ores is a good example of what to do for double-filtering

            changed recipe search method so now they use the general search methods.
            will break recipe changes defined previously. no support for specific recipe.
            how to search recipe (or any) name
                 search_category = "recipe",
                 search_property = "name",
                 search_property_value = "whatever-name"

    - I probably added some bugs. Report bugs. Sorry.

    - property_category was removed. unnecessary/refused at this point

    - stack_data.recipe was removed (see near end of Additions)

    - AddSingleItemWithoutFiltering.
            Items without filters are passed by filter.
            Items that match themselves pass.

            Results in redundant checks, but simplifies the code.

    - Commented some dead code in filter, will remove if everything's as predicted

    - cleaned category definitions. Should catch more items. Don't need name hacking.

    - Currently recipe searches do not filter their found ingredients
            would be a simple enough change
            could return list of recipes and ingredients for
                       explicit modifications (useful for barrels)
            new mod idea? custom recipe costs, and/or scale specific ingredients

    - Will probably rewrite SearchByCategory so it doesn't modify stack sizes by default.
          won't necessarily require changing previous calls, since I can
               disregard the second argument

    - mytable = { type = "string" } does not result in type getting evaluated
         my editor highlights it as a function. bugger.
         I don't plan to use functions that create a key for a table like that,
              but it's something for which I should watch
        apologies to anyone I told otherwise

    - rewrite property value digging so instead of a one-deep subproperty,
          I can use a recursive key-table, with key of string or table at the end

          wouldn't need subproperty anymore, could go arbitrary depths
          would look like
             property = {first_key = { second_key = {last_key}}}

          the last key would have it's value compared against the property_value

          would also want the search to find arbitrary-depth subitems, for consistency
            {"burnt_result"} --->val is string, key = burnt_result
            {["mineable" = {"result"}} --->val is table, use key of table to find...
Version: 0.0.12
Date: 2019-10-30
    - Changed label and tooltip of fish multiplier in options as it may affect more things

    - Change soft multiplier checks and ranges (for settings).
        If negative, they become firm options
        I want people to expect this to be a "remaining items" change, with no conflict

    - Modified subitem search to include a key-value table.
                     Now I can do thing.minable.result

    - added BuildThingPath function, which can go from a name and category back
         to a table.
             should be able to re-use above to simply other item searches and functions

    - fish don't need name-matching hacks anymore. subitem = { ["minable"] = "result" }
            (will probably use this for ores or something)

    - Edited readme_advanced for clarity about what is needed and what happens with values.
Version: 0.0.11
Date: 2019-10-30

    - Fish Multiplier should now search fish-name or raw-fish-name (in order) that are items.
           there are no others in vanilla (raw-fish is a "capsule", not "item")

           fish must be in the fish category (presumably these are the fish on the map)
                  others won't be detected

    - fix changelog labels of previous two changelog entries (Bug Fix -> Bug Fixes)
    - adding a note here that there are readme files:
                                readme and a readme_advanced for code help

    - Added comments in data-final-fixes
        the soft multipliers found in settings need multiple changes to be like normal ones

    - changed "raw-material" tooltip to mention it catches things like plates

    - Correction to previous Notes - a 0 is detected on final assignment, and is only used
            for validating if a stack size of 0 was intentional
Version: 0.0.10
Date: 2019-10-30

  Bug Fixes:
    - Forgot to remove some bits from the priority refactor (thanks jamiech1 for reporting)

    - changed fish option name and description. I thought it was funny

    - A priority of 0 is reserved for default stack size only.
          triggers conflict resolution code, though is undetected on final assignment
Version: 0.0.9
Date: 2019-10-30
  Bug Fixes:
    - fill-barrel stack check matches new priority method
    - Change settings so barrels can't have a negative capacity
    - multiplier printing in log wasn't right
    - broke reactor fuels. Fixed. (double checked everything else for the same mistake)

    - Storage tank(s) stack size and capacity multiplier. Separate assignments
    - Fluid wagon(s) capacity

    - Removed property-category search and folded it into general category search

    - SearchByCategory now returns table of items and
       table of subitems -  return items, subitems.
       returns nil, nil on error or {}, {} for success searching but nothing found
       (a burn result can only be found in original fuel
           - it's an subitem of "burnt_result")

    - searching by category can now return just the items found.
            Will probably refactor code to de-intermingle stack size changes
               and other functions, so I can do it all separately/explicitly
Version: 0.0.8
Date: 2019-10-30
  Bug Fixes:
    - Accidentally referred to a global instead of a table property in KeepItem
    - multipliers didn't actually work. Duh.

    - some comments here and there. changed a log message to be more informative (KeepItem)
    - typo in readme tooltip
Version: 0.0.7
Date: 2019-10-29
    - rework priority system to use numbers. Negative stack sizes protect against further changes.
         order matters, so reserved groups are protected by option or conflict

         -1 means protect default stack size from further changes, over-write any existing change

         this code is always hit! report bugs if something goes wrong!

    - option to prefer a negative number (overrides all other changes) or default values (-1)
          matching items from two negative groups should still conflict, because I can't
            specify infinite override orders

    - general readme.txt and readme_advanced.txt for anyone looking to make further tweaks

    - new install settings default to 0 - no changes. turn on only what you want
    - "readme" tooltip at the top. cleans up other options tooltips. the checkbox does nothing
    - stacks in options should have negative ranges now
          intermediate-products, raw-materials, and fish are forced to be soft changes - only positive range

    - tile priority option removed, since it can now be set with a negative number
          be careful with smelter-results (brick is in both)

  Bug Fixes:
    - broke name matching for miniloaders. Fixed.
    - all the other 50000 ones I introduced making the priority overhaul
Version: 0.0.6
Date: 2019-10-29
  Bug Fixes:
    - stricter rejections when stack size == 0

    - change tooltip for smelting results, since it wasn't accurate
    - edit thumbnail.png so it's not cropped
    - change multipliers position in options
    - fix format of previous changelog entry (I was in a rush)
Version: 0.0.5
Date: 2019-10-29
  Bug Fixes:
    - Check stack size > 0 before adding barrels of fluids.
Version: 0.0.4
Date: 2019-10-29
    - sorting option for logging changes:
      inserted by mod order(and in groups), name. default: name

    - can add something to the front or back of names* (needed for fish->raw-fish)
    - fish multiplier (fish)

    - multiplier for intermediate-products not otherwise changed (silently fails on conflict)
    - multiplier for raw-material not otherwise changed (silently fails on conflict)
    - these multipliers can effect a lot of items (even satellites), which is why I made it a multiplier.
          use with caution

    - multipliers do ceiling on the result, so things are at least 1 and round evenly

    - option to silently fail or override during a conflict (internally)
          overriding is only when the overriding group hits an existing change (tiles priority)
          any further change triggers normal conflict (the awareness of an override isn't persistent)

    - more dumping functions, moved to dump.lua
    - filter can now more easily match if a property/value must exist or not exist, even for tables
          if any table of property exists true, if it must not exist false. vice-versa for pure exclude.
          used for tiles. they all have a place-as-tile table, I don't care what's in it

  Bug Fixes:
    - forgot to change folder number version
            forgot to change, shame on me
            wasn't an error, shame on Factorio

    - changed explicit data.raw to implicit under core_table variable, same with table for changes
    - changed representation of items in change_table
           changing item representation simplifies validating stuff before we add it
    - tile search and override method changed. Hopefully it behaves the same
    - was able to remove a function (related to looking in a category)
    - (re-uploaded and edited changelog, sorry!)
  Future wants:
    - Thinking of making it so a negative stack size option is a defense against stack changes, and forces that option
            would do math like normal when it came to applying the change (obviously). Open to feedback.
            a -1 could be used to "purely defend" some items, so we can set a protected stack size without actually changing anything
Version: 0.0.3
Date: 2019-10-28
  Bug Fixes:
    - removed unreachable code and improved stack size checking for ItemIsSafeToChange

    - change previous changelog entries slightly so it looks better in game
           (will avoid changing previous logs in the future)
Version: 0.0.2
Date: 2019-10-28
    - format changelog.txt so it shows in-game 

    - to clarify on some "features", they're all internal. nothing fancy is exposed to the user, unfortunately
      (these are for my sake, for fine-tuning things)
Version: 0.0.1
Date: 2019-10-28
    - fork of ReStack 0.5.8 (no affiliation, 2018 (c) Optera),
        many internal additions and features, removed dependency for an
          external function by adding internal function

    - detect if an item's stack size is being changed twice and act on it:
        workaround for Oceanus having coal as a product of algae smelting and not
          complete removing recipes in other modes
                          (ores and smelters modify coal if enabled)

        can log and ignore, ignore, update to "new" value, use least, use greatest

    - can exclude specific properties of items so not everything matching
        category has stacked changed (created compatibility with AllMinable)

    - can include if property exists, exclude if it doesn't

    - so many log messages and change-tracking! useful for debugging/seeing
        compatibility. probably should add options to limit what gets
        shown and add some of the extremely verbose logging as an option

    - option to suppress barrel messages. there's a lot of them (default on)

    - don't try to change stack at all if we set it to 0 - prevents overwriting
        other internal stack sizes (still gets detected as a conflict if > 0 and
        something else set the stack)

    - fixed Lua mistake when 'type' is a key in a table: { type = "string" }
        (type is a function pointer, should have ["type"] as a string)

    - internal name changes for settings/whatever

    - added some name slicing capability so miniloaders work with my code

    - almost always does "smart" searching, which can miss mods that aren't 100%
        vanilla-like (miniloaders are called miniloader-loaders in ["items"])

  Future wants:
    - Rewrite filtering mechanism so it's more versatile
    - Rewrite barrel.lua so changes are propagated like stack size
    - Add fluid wagon capacity, since barrels are change-able?
    - Why not storage tanks, too