Ammo Loader+


More than just a turret loader. Auto load everything from turrets to artillery wagons to furnaces and even the player themselves. Auto upgrade ammo and fuel without tedious manual replacement. Infinite range and compatible with Factorissimo2.

Content
23 days ago
0.14 - 2.0
25.1K
Logistics

i Would it be possible to add patch to make it work with warptorio2?

5 years ago

error:
The mod Warptorio2 caused a non-recoverable error.
Please report this error to the mod author.

Error while running event warptorio2::on_tick (ID 0)
The mod Ammo Loader+ caused a non-recoverable error.
Please report this error to the mod author.

Error while running event ammo-loader::script_raised_destroy (ID 78)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
ammo-loader/lib/HiddenInserter.lua:146: in function 'force'
ammo-loader/lib/HiddenInserter.lua:288: in function 'destroy'
ammo-loader/lib/TrackedSlot.lua:349: in function 'destroy'
ammo-loader/lib/Handlers.lua:73: in function <ammo-loader/lib/Handlers.lua:47>
stack traceback:
[C]: in function 'index'
__ammo-loader
/lib/HiddenInserter.lua:146: in function 'force'
ammo-loader/lib/HiddenInserter.lua:288: in function 'destroy'
ammo-loader/lib/TrackedSlot.lua:349: in function 'destroy'
ammo-loader/lib/Handlers.lua:73: in function <ammo-loader/lib/Handlers.lua:47>
stack traceback:
warptorio2/control.lua:1794: in function 'Warpout'
warptorio2/control.lua:1463: in function 'v'
warptorio2/control.lua:2200: in function <warptorio2/control.lua:2200>
stack traceback:
[C]: in function 'destroy'
warptorio2/control.lua:1794: in function 'Warpout'
warptorio2/control.lua:1463: in function 'v'
warptorio2/control.lua:2200: in function <warptorio2/control.lua:2200>

5 years ago
(updated 5 years ago)

I just uploaded 0.17.64 which should make it compatible. Let me know if you still have trouble after updating.

5 years ago

Thank You!

5 years ago

error occurred during the third warp.
error will occur even if all MOD settings are unchecked.

Error while running event ammo-loader::script_raised_destroy (ID 78)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
ammo-loader/lib/TrackedSlot.lua:686: in function 'returnItems'
ammo-loader/lib/Handlers.lua:77: in function <ammo-loader/lib/Handlers.lua:51>
stack traceback:
[C]: in function 'index'
__ammo-loader
/lib/TrackedSlot.lua:686: in function 'returnItems'
ammo-loader/lib/Handlers.lua:77: in function <ammo-loader/lib/Handlers.lua:51>
stack traceback:
warptorio2/control.lua:1878: in function 'Warpout'
warptorio2/control.lua:1555: in function 'v'
warptorio2/control.lua:2285: in function <warptorio2/control.lua:2285>
stack traceback:
[C]: in function 'destroy'
warptorio2/control.lua:1878: in function 'Warpout'
warptorio2/control.lua:1555: in function 'v'
warptorio2/control.lua:2285: in function <warptorio2/control.lua:2285>

5 years ago

Warptorio2 Version: 1.0.0
no longer gives an error
thx silentcrim & PyroFire

5 years ago

I patched my mod as well just now (0.17.65) with a potential fix for this bug. Let me know if you get any more errors after updating.

5 years ago

Hi, thanks for your attempted fixes.
Looks like you were trying to destroy entities which have already been destroyed in your script_raised_destroy hook.
You simply need to check .valid first.

Please note : this is not a compatibility issue with warptorio specifically.
This is a compatibility issue with any other mod on the mod portal that makes calls to script_raised_destroy which may affect your entities (which warptorio does).

While you're at it, you may also want to ensure you have https://lua-api.factorio.com/latest/events.html#on_entity_cloned hooked as well if you hook on_built_entity, as this is a common compatibility problem specifically with warptorio.

5 years ago

This issue is already fixed actually.

The problem wasn't just a simple missing .valid check. It seems simple, but the invalid entity error was just a symptom of a bigger problem. When a warp would occur, my mod would lose track of the hidden inserters it uses to move ammo around. Normally, I handle these entities script side, destroying them when their relevant turret dies or is picked up. The problem was that I didn't have a chance to destroy them properly before a warp, and they are indestructible, invisible, and inoperable. I could have just done a .valid check and made a new one if it was invalid, but that would mean the one that was warped would probably never get destroyed. Over time, this would lead to thousands of extra inserters eating up resources in the background.

My solution was a sort of garbage collection that runs every 5 minutes and looks for stray hidden inserters and their LuaObjects. That way I can just let the invalid ents go and make a new one without worrying about leaving a bunch of useless objects in my global table.

As for on_entity_cloned, I implemented it a while back when you mentioned it in another topic. For the moment, I believe our mods are fully compatible with one another.

5 years ago
(updated 5 years ago)

Not exactly the cleanest solution, ideally you would destroy internal entities like that in the on_cloned_event, effectively acting like a blacklist so they can't be cloned on their own.
ex.

local noCloneEnts={"my_internal_name_one","another_ent_to_never_clone"}
script.on_event(defines.events.on_entity_cloned,function(ev) for k,v in pairs(noCloneEnts)do if(ev.destination.name==v)then ev.destination.destroy() return end end end

Warptorio also has some remotes which can be used as an alternative to the above, which needs to be put in on_config_changed and on_init.

if(remote.interfaces["warptorio"])then remote.call("warptorio","insert_warp_blacklist","ammo-loader","entity_prototype_name_here") end

New response