Page 1 of 1
Tiberium mod ore spread not recognized by mining drill
Posted: Sun Jan 06, 2019 9:15 pm
by torndar
I'm playing with the "Fixed Tiberium" mod and when the tiberium fields spread the mining drills don't recognize it until I force them to update by removing
and replacing or by rotating. Lua looks fairly easy to write/modify and I found the control script in the mod package but I have no idea where in the Factorio mod API to look for a way to tell the mining drills to check again. Any tips?
https://mods.factorio.com/mod/Fixed_Tiberium
Re: Tiberium mod ore spread not recognized by mining drill
Posted: Sun Jan 06, 2019 10:13 pm
by darkfrei
Re: Tiberium mod ore spread not recognized by mining drill
Posted: Sun Jan 06, 2019 10:54 pm
by torndar
I just tried getting the count of active=true vs active=false for the mining drills and they all show as active (true=179 false=0 command at bottom). There is a drill with recently spread ore in its area and it shows "Expected resources: 20" but it's not doing anything. The belt in front of the drill is empty and it has power.
/c local count = 0 for key, value in pairs(game.player.surface.find_entities_filtered({name="electric-mining-drill"})) do if (value.active == true) then count = count +1 end end game.player.print(count)
Edit:
Explicitly setting active to false and back to true seems to have made the drills re-recognize there is ore to mine. If nobody suggests a better way to do it I'll probably just have that run every 5 minutes or so (based on ticks). I worry about lag spikes doing that but I'm not going for a megabase so I probably don't really need to.
Re: Tiberium mod ore spread not recognized by mining drill
Posted: Mon Jan 07, 2019 4:43 am
by Rseding91
torndar wrote: Sun Jan 06, 2019 10:54 pm
I just tried getting the count of active=true vs active=false for the mining drills and they all show as active (true=179 false=0 command at bottom). There is a drill with recently spread ore in its area and it shows "Expected resources: 20" but it's not doing anything. The belt in front of the drill is empty and it has power.
/c local count = 0 for key, value in pairs(game.player.surface.find_entities_filtered({name="electric-mining-drill"})) do if (value.active == true) then count = count +1 end end game.player.print(count)
Edit:
Explicitly setting active to false and back to true seems to have made the drills re-recognize there is ore to mine. If nobody suggests a better way to do it I'll probably just have that run every 5 minutes or so (based on ticks). I worry about lag spikes doing that but I'm not going for a megabase so I probably don't really need to.
When you create-entity a new ore, scan for mining drills overlapping with that tile and process them at that point. You can iterate the entity prototypes and get the max mining drill radius to know the full area you'll need to scan.
AKA: exactly what the core game would do if it handled this situation (and why it doesn't).
Re: Tiberium mod ore spread not recognized by mining drill
Posted: Mon Jan 07, 2019 5:48 am
by darkfrei
torndar wrote: Sun Jan 06, 2019 10:54 pm
Explicitly setting active to false and back to true seems to have made the drills re-recognize there is ore to mine. If nobody suggests a better way to do it I'll probably just have that run every 5 minutes or so (based on ticks). I worry about lag spikes doing that but I'm not going for a megabase so I probably don't really need to.
You can make on_tick for only one entity per tick. So If you have megabase, it takes the same lag as by tiny base.See code of
https://mods.factorio.com/mod/RITEG
And add some pause for updating
Code: Select all
drill =
{
entity = entity,
next_tick_for_update = game.tick + 300
}
Code: Select all
if game.tick < drill.next_tick_for_update then return end