Mad-Faxtorio


Dubbed Mad-Faxtorio by Galdoc, This mod adds the SA-mauler (a tracked car inspired by MadMax, named by Stringweasel). Equipped with a machine gun and a flamethrower and a customizable grid. Stock looking sprites, my closest so far!

Content
4 days ago
1.1
106
Transportation

i Some observations

8 days ago
(updated 8 days ago)

Hi! Just downloaded your mod for checking compatibility with Autodrive. Some things I've noticed:

  • You've used the text "See setting name 8P." for the strings prefixed with "mauler-" in your mod-setting-description section. At first I thought "8P" was some placeholder you've forgotten to remove, then I understood that it is supposed to be a smiley (that would have been more obvious if the smiley was placed after the period). If my assumption is correct, why add a description for these settings at all?

  • Did you really mean to prefix setting names and descriptions with a space? In locale files, everything before '=' is part of the string name, and everything after it is part of the localized text -- this includes white space before/after the '='.

  • In data-final-fixes.lua, you set equipment_categories to a fixed list if Krastorio2 is active. Please keep in mind that there are other mods that may add equipment categories to grids (e.g., Autodrive will make sure that its equipment can be placed in existing grids). While I could easily work around this by adding an optional dependency on your mod and add my equipment category after your mod is done, it would be better for overall compatibility if you'd just add categories to the existing table instead of overwriting it.

  • In control.lua, you check for whodunit.name == "player". This will probably be OK most of the time, but you have no guarantee that there really are players on force "player" (think of multiplayer games with players on competing forces, mods that move each player to a separate force, etc.). Why don't you make this a bit more general and check whether whodunit really is a force with players? Something like this may work:

    local whodunit = event.force  -- event.force is optional, so it may be nil!
    local isplayerforce = whodunit and whodunit.valid and next(whodunit.players) and true
    […]
    -- As all inner tests check for damage_type and the force, it's more efficient to move those checks up
    if isplayerforce and entity and entity.valid and damage_type.name == "impact" then
      if entity.type == "unit-spawner" then
        […]
      elseif treeon and entity.type == "tree" then
        […]
      end
    end
    
  • You check for just the vanilla units, but mods may add variations of the default biters/spitters. I guess it would be inconvenient to check all unit names for substrings "biter" or "spitter", but there is another way to distinguish between them:

    -- Biter:
    if biteron and entity.type == "unit" and entity.prototype.attack_parameters.type == "projectile" then
      […]
    
    -- Spitter:
    elseif spitteron and entity.type == "unit"  and entity.prototype.attack_parameters.type == "stream" then
      […]
    end
    

By the way, my mod acts similar to yours: If a vehicle that's controlled by my mod collides with a tree, it may get healed completely (depends on setting). If it collides with trees, spawners, worms, or units and destroys them, it will accelerate for a short time -- or bounce off if the damaged entity survived. If it collides with an entity of the same force, it will restore full health to the damaged entity. I'll have to check if this will pose problems later (my WIP version is broken because I'm restructuring some tables again).

8 days ago
(updated 8 days ago)

So for your first point, I have a playfull side and because it was pointless to add a description I added a non descript message as it amused me.
In the locale I did not mean to leave spaces, Im not a seasoned coder so thanks for the optimization suggestions, im curious as to why the biters have projectiles being mele in nature I assume its just the way factorio handles the damage, im all for optimal code im just clueless as to what good looks like.

8 days ago
(updated 8 days ago)

All suggestions have been implemented also im now checking if the worm turret entitys ammo category is biological and type stream

4 days ago

Thank you! But I've noticed something else: You check for cause and cause.valid and cause.name == "SA-mauler" when a unit-spawner has been hit, but not when trees, units, or turrets were damaged. So if I'd crash into a tree with a vanilla car, the car would also be healed. This can be fixed by moving the check for cause up to line 19 (if isplayerforce and entity and entity.valid and damage_type.name == "impact" then), so that it applies to all damaged entity types.

New response