That's exactly what it is. If I feel like it I might re-work it slightly to avoid that if possible but it won't always help.Adil wrote:So, this function is just equivalent of using find_entities() and filtering the results yourself? One would hope that the C++ would feature some optimizations over that.Rseding91 wrote:Indeed. Because the filtering allowed (type, force, name) isn't applied until after all of the entities in the given area are collected.Adil wrote:On a side note, setting limit=1 in the find_entities_filtered() didn't affect performance, the C++ backend apparently finds and stores all results and only then discards everything above the threshold.
FPS/UPS drop to <20
Re: FPS/UPS drop to <20
If you want to get ahold of me I'm almost always on Discord.
- Deadly-Bagel
- Smart Inserter
- Posts: 1498
- Joined: Wed Jul 13, 2016 10:12 am
- Contact:
Re: FPS/UPS drop to <20
Not sure if the Loot Chest mod is any better processing-wise, it hooks into events so whenever a biter, worm or spawner dies the location is stored in an array and every three seconds it iterates the array and collects any artefacts in a small radius around each death.
It's a global thing so you might feel it a bit cheaty but with Bob's Mods the dozen or so types of artefacts are a pain to collect and quickly fill your inventory so it's handy to just have them teleported to where you would be dumping them anyway. It can however take up to three seconds to pick them up so you do still end up with some in your inventory but meh.
Would it help to have loot stored (or referenced) separately so mods can more efficiently manage it? I know Bob is intending on keeping loot in his mods when he updates for 0.15.
It's a global thing so you might feel it a bit cheaty but with Bob's Mods the dozen or so types of artefacts are a pain to collect and quickly fill your inventory so it's handy to just have them teleported to where you would be dumping them anyway. It can however take up to three seconds to pick them up so you do still end up with some in your inventory but meh.
Would it help to have loot stored (or referenced) separately so mods can more efficiently manage it? I know Bob is intending on keeping loot in his mods when he updates for 0.15.
Money might be the root of all evil, but ignorance is the heart.
Re: FPS/UPS drop to <20
Not exactly a fix for collecting the artifacts but how I've solved it is to build a belt outside my defensive walls that brings stuff to my artifact storage area. Sure, it'll still mean that you'll have huge fields of artifacts laying on ground but at least those fields won't expand infinitely since you keep removing items via those belts.
-
- Long Handed Inserter
- Posts: 51
- Joined: Sat Jan 07, 2017 12:17 am
- Contact:
Re: FPS/UPS drop to <20
And with any difficulty mods, spitters usually get enough range that they could kill that belt easily without dying. Not an option if you want those mods.hoho wrote:Not exactly a fix for collecting the artifacts but how I've solved it is to build a belt outside my defensive walls that brings stuff to my artifact storage area. Sure, it'll still mean that you'll have huge fields of artifacts laying on ground but at least those fields won't expand infinitely since you keep removing items via those belts.
How about the "Artifact Deconstructor" mod? It doesn't seem to cause much lag (I'll need to verify that), and it seems to be doing a very similar thing. Could we just use whatever it's doing, but instead of having the selected item mark for deconstruction, we put it in the chest?
-
- Long Handed Inserter
- Posts: 51
- Joined: Sat Jan 07, 2017 12:17 am
- Contact:
Re: FPS/UPS drop to <20
Verifed: Artifact Deconstructor uses .002 -.05 ms of CPU time, which is extremely reasonable compared to the item collectors.
Here is the Entirety of the code for the Artifact Deconstructor (https://mods.factorio.com/mods/Kane.Nex ... constuctor):
Config.lua
Control.lua
It's very simple compared to the Item collectors. In part, that's because it doesn't use any sort of item, technology, recipe, or entity. But couldn't the code be shifted from the player to the items without causing too much hassle? And then just, instead of marking for deconstruction, teleport the item to the collector?
Here is the Entirety of the code for the Artifact Deconstructor (https://mods.factorio.com/mods/Kane.Nex ... constuctor):
Config.lua
Code: Select all
-- seconds between artifact checks
artifact_polling_delay_secs = 5
-- square radius searched around players (larger = more area = more lag)
search_radius = 100
Code: Select all
require "config"
local artifact_polling_delay = math.max(artifact_polling_delay_secs,1)*60
local function find_all_entities(args)
for _, allPlayers in pairs( game.players ) do
args.area = {{game.players[allPlayers.index].position.x-search_radius, game.players[allPlayers.index].position.y-search_radius}, {game.players[allPlayers.index].position.x+search_radius, game.players[allPlayers.index].position.y+search_radius}}
for _, ent in pairs(game.surfaces[1].find_entities_filtered(args)) do
if game.players[allPlayers.index] and (ent.stack.name == "alien-artifact" or ent.stack.name == "alien-artifact-red" or ent.stack.name == "alien-artifact-orange" or ent.stack.name == "alien-artifact-yellow" or ent.stack.name == "alien-artifact-green" or ent.stack.name == "alien-artifact-blue" or ent.stack.name == "alien-artifact-purple") and not ent.to_be_deconstructed(game.players[allPlayers.index].force) then
ent.order_deconstruction(game.players[allPlayers.index].force)
end
end
end
return
end
local function onTick(event)
if event.tick%artifact_polling_delay == 0 then
-- debug("Find Artifact")
find_all_entities({name="item-on-ground"})
end
end
script.on_event(defines.events.on_tick, onTick)
Re: FPS/UPS drop to <20
Well, if you do that, you'll just get the ItemCollectors mod as it is.
Simply use the fixed version from previous page.
Edit:
Well and change the 8th line in the control.lua to something like:
Simply use the fixed version from previous page.
Edit:
Well and change the 8th line in the control.lua to something like:
Code: Select all
global.ticks = 60
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: FPS/UPS drop to <20
When I had a system like that, I was using a ton of mods that made life harder. E.g all of natural evolution, bob's and some other enemy AI-related thingy (IIRC Misanthrope). I had Bob's sniper turrets as my defensive line with about 3-4 tile gap between them and the belt moving artifacts. Not once did the spitters even attempt to destroy the belts, they were always going straight to turrets.SquarelyCircle wrote:And with any difficulty mods, spitters usually get enough range that they could kill that belt easily without dying. Not an option if you want those mods.hoho wrote:Not exactly a fix for collecting the artifacts but how I've solved it is to build a belt outside my defensive walls that brings stuff to my artifact storage area. Sure, it'll still mean that you'll have huge fields of artifacts laying on ground but at least those fields won't expand infinitely since you keep removing items via those belts.
-
- Long Handed Inserter
- Posts: 51
- Joined: Sat Jan 07, 2017 12:17 am
- Contact:
Re: FPS/UPS drop to <20
Adil wrote:Well, if you do that, you'll just get the ItemCollectors mod as it is.
Simply use the fixed version from previous page.
Edit:
Well and change the 8th line in the control.lua to something like:Code: Select all
global.ticks = 60
Oh, yup. That did it. Item collector is taking very little CPU time now... like 0.02-0.05. What change optimized it?
Re: FPS/UPS drop to <20
It didn't optimize, it just made it compute less frequently.
After some thought, that change wasn't as good, it makes them collect a single item in a second.
Here's the modification, that makes the slowest bit of the mod run less often while still picking up items alright.
Maybe some day I'll do a proper release of more performant mod.
After some thought, that change wasn't as good, it makes them collect a single item in a second.
Here's the modification, that makes the slowest bit of the mod run less often while still picking up items alright.
Maybe some day I'll do a proper release of more performant mod.
- Attachments
-
- Item Collectors_1.1.9.zip
- (18.33 KiB) Downloaded 82 times
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.