HeroTurrets_Redux


Turrets are built using salvaged self-learning AI tech from your ship allowing them to get deadlier with practice. Extends turrets via ranking system based on kills. Turrets are generated and are not limited to vanilla turrets, identifiable by overlaid rank insignia. Rank buffs individual turrets.

Content
2 months ago
2.0
5.09K
Combat

b [Fixed] Conflict with Kuxynator's Slim-Inserters

2 months ago

Conflict with Kuxynator's Slim-Inserters. SA 2.0.55

Failed to load mods: __HeroTurretRedux__/prototypes/scripts/types.lua:1011: attempt to index field '?' (a nil value)
stack traceback:
    __HeroTurretRedux__/prototypes/scripts/types.lua:1011: in function 'local_create_turrets'
    __HeroTurretRedux__/prototypes/scripts/types.lua:1129: in main chunk
    [C]: in function 'require'
    __HeroTurretRedux__/data-final-fixes.lua:6: in main chunk

factorio-current.log

   0.793 Info ModManager.cpp:444: FeatureFlag expansion-shaders = true
   0.793 Info ModManager.cpp:444: FeatureFlag freezing = true
   0.793 Info ModManager.cpp:444: FeatureFlag quality = true
   0.793 Info ModManager.cpp:444: FeatureFlag rail-bridges = true
   0.793 Info ModManager.cpp:444: FeatureFlag segmented-units = true
   0.793 Info ModManager.cpp:444: FeatureFlag space-travel = true
   0.793 Info ModManager.cpp:444: FeatureFlag spoiling = true
   0.795 Loading mod settings HeroTurretRedux 1.0.26 (settings.lua)
   0.795 Loading mod settings Kux-CoreLib 3.17.8 (settings.lua)
   0.798 Loading mod settings Kux-SlimInserters 3.0.30 (settings.lua)
   0.802 Script @__Kux-CoreLib__/lib/String.lua:1: Loading KuxCoreLib.String.lua
   0.803 Script @__Kux-SlimInserters__/settings.lua:2: settings.lua mod.prefix=Kux-SlimInserters_
   0.803 Loading mod settings Kux-CoreLib 3.17.8 (settings-final-fixes.lua)
   0.805 Loading mod core 0.0.0 (data.lua)
   0.823 Loading mod base 2.0.55 (data.lua)
   0.982 Loading mod elevated-rails 2.0.55 (data.lua)
   1.007 Loading mod HeroTurretRedux 1.0.26 (data.lua)
   1.013 Loading mod Kux-CoreLib 3.17.8 (data.lua)
   1.020 Loading mod quality 2.0.55 (data.lua)
   1.036 Loading mod Kux-SlimInserters 3.0.30 (data.lua)
   1.043 Script @__Kux-CoreLib__/lib/String.lua:1: Loading KuxCoreLib.String.lua
   1.049 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for basic-slim-inserter
   1.049 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: inserter found in electronics add basic-slim-inserter too
   1.050 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for long-slim-inserter
   1.050 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: long-handed-inserter found in automation add long-slim-inserter too
   1.051 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for fast-slim-inserter
   1.051 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: fast-inserter found in fast-inserter add fast-slim-inserter too
   1.052 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for stack-slim-inserter
   1.052 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: bulk-inserter found in bulk-inserter add stack-slim-inserter too
   1.056 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for basic-double-slim-inserter
   1.056 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: inserter found in electronics add basic-double-slim-inserter too
   1.057 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for long-double-slim-inserter
   1.057 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: long-handed-inserter found in automation add long-double-slim-inserter too
   1.058 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for fast-double-slim-inserter
   1.058 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: fast-inserter found in fast-inserter add fast-double-slim-inserter too
   1.059 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for stack-double-slim-inserter
   1.059 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: bulk-inserter found in bulk-inserter add stack-double-slim-inserter too
   1.060 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for basic-loader-slim-inserter
   1.060 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: basic-slim-inserter found in electronics add basic-loader-slim-inserter too
   1.061 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for fast-loader-slim-inserter
   1.061 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: fast-slim-inserter found in fast-inserter add fast-loader-slim-inserter too
   1.062 Script @__Kux-SlimInserters__/modules/RecipeBuilder.lua:42: Created recipe for fast2-loader-slim-inserter
   1.062 Script @__Kux-SlimInserters__/modules/TechnologyBuilder.lua:33: add_to_tech: fast-slim-inserter found in fast-inserter add fast2-loader-slim-inserter too
   1.069 Loading mod space-age 2.0.55 (data.lua)
   1.384 Loading mod base 2.0.55 (data-updates.lua)
   1.397 Loading mod HeroTurretRedux 1.0.26 (data-updates.lua)
   1.407 Loading mod quality 2.0.55 (data-updates.lua)
   1.424 Loading mod Kux-SlimInserters 3.0.30 (data-updates.lua)
   1.425 Script @__Kux-SlimInserters__/data-updates.lua:8: shrink selection_box for most entities to not overlap with slim inserters. you can disable this in settings.
   1.425 Script @__Kux-SlimInserters__/data-updates.lua:83: shrink selection_box
   1.435 Loading mod space-age 2.0.55 (data-updates.lua)
   1.445 Loading mod HeroTurretRedux 1.0.26 (data-final-fixes.lua)
   1.447 Script @__HeroTurretRedux__/data-final-fixes.lua:3: Turrets via final fixes
   1.448 Script @__HeroTurretRedux__/prototypes/scripts/types.lua:2: Creating Types
   1.449 Script @__HeroTurretRedux__/prototypes/scripts/util.lua:1: Hero Turrets Util (Whipped up from Liborio utils)
   1.449 Error ModManager.cpp:1758: Failed to load mod "HeroTurretRedux": __HeroTurretRedux__/prototypes/scripts/types.lua:1011: attempt to index field '?' (a nil value)
stack traceback:
    __HeroTurretRedux__/prototypes/scripts/types.lua:1011: in function 'local_create_turrets'
    __HeroTurretRedux__/prototypes/scripts/types.lua:1129: in main chunk
    [C]: in function 'require'
    __HeroTurretRedux__/data-final-fixes.lua:6: in main chunk
   1.794 Loading mod core 0.0.0 (data.lua)
   1.834 Checksum for core: 2220362065
   1.857 Error ModManager.cpp:1758: Error in assignID: recipe-category with name 'recycling' does not exist.
2 months ago

Hey! I’ll take a look, thanks

2 months ago
(updated 2 months ago)

Hey Trainman! Sorry it took a bit to get back to you.

It seems that they are changing the default selection box named values to something completely different. I would reach out to them and see why they are doing that as that is something that is provided as base by the factorio api.

Thanks

2 months ago

Hey, thanks for the clarification. I'm just gonna forward this to Kuxynator, see if he knows more about it.

2 months ago
(updated 2 months ago)

i only shrink the values, e.g {{-2, -2}, {2, 2}} to {{-1.75, -1.75}, {1.75, 1.75}}

It seems that they are changing the default selection box named values to something completely different.

"something completely different" ?? this is the default short hand format.
https://lua-api.factorio.com/latest/prototypes/EntityPrototype.html#selection_box

[deleted message]
2 months ago
(updated 2 months ago)

Oh sorry kuxynator, I didn’t realize it was you and not the original author of the thread, I have massive respect for you for the amount of work you put into the modding community! Thanks for all you do.

When trying to access the selection box parameters for the flame thrower, it is giving me a table vs an array. I'm not very experienced in coding in LUA with this being my first foray into it so I apologize if I get any of the vernacular wrong as I come from the .NET world.

When I get back home I can attach screenshots of what is showing in the debugger.

I think it might have something to do with the data-updates.lua when the box variable is modified here as the error only occurs on fluid-turret types :

---@param entity data.EntityPrototype
local function modify(entity)
--[[TRACE]]--trace("modify", entity.name, tonumber(entity.tile_width), tonumber(entity.tile_height))
local min=math.min
local max=math.max
local v = 0.1
local box = entity.selection_box
if(not box) then return end

    --calcutate optimal selection box for tile-size
    local hv = get_tile_with(entity) /2
    local vv = get_tile_height(entity) /2
    local box2 = {{min(-hv+v,0), min(-vv+v,0)}, {max(hv-v,0), max(vv-v,0)}}
    --print("box", serpent.line(box))
    --print("box2", serpent.line(box2))
    --WTF?? most entities have no tile_width/tile_height
    --Default: calculated by the collision box width/height rounded up.

    -- use optimal selection box corner or original if it closer to center
    box = {
        left_top     = {max(box2[1][1], (box[1] or box.left_top    )[1]), max(box2[1][2],(box[1] or box.left_top    )[2])},
        right_bottom = {min(box2[2][1], (box[2] or box.right_bottom)[1]), min(box2[2][2],(box[2] or box.right_bottom)[2])},
    }
    entity.selection_box = box

end

Which would result in {left_top,right_bottom} for fluid turrets. This makes doing fluid_turret_Selection_Box[1][1] (or in the case of the code above, box2[1][1]) not accessible anymore.

2 months ago
(updated 2 months ago)

--WTF?? most entities have no tile_width/tile_height

LOL yes becasue this is the default (in data stage) is also in the docu

Unfortunately, this is the case with many concepts and you ALWAYS have to normalize first when reading, or take both cases into account. The API should therefore be more tolerant when setting, at the expense of reading. in the control stage you get allways the normalized format. but in data stage, you get what was set.

BTW
Lua is spelled “Lua”, not “LUA” because it is not an abbreviation ;-)

[deleted message]
2 months ago
(updated 2 months ago)

haha yeah that function was from your mod.

Ah okay, I see you are using an “or” there. I could use the same thing.

Well you taught me something new today. I'll get that added. Sorry about the confusion. I have literally never seen that happen before and have tested with 100's of different mods. I didn't know that BoundingBox's could be a struct or {MapPosition,MapPosition}.

Thanks!

2 months ago

a good developer would need an abstraction layer to catch all the “ evil” things of the Factorio API that unnecessarily make the code unreadable.
I have a lot of functions only to normalize API things. small ones like toPosition, toBoundingBox, etc, bigger ones like Array, Dictionary, Queue, to compensate for Lua's weaknesses: and huge ones for data:extend, and GuiElement.add.

2 months ago

Fixed. Thanks again Kuxynator :D

New response