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
Tiberium mod ore spread not recognized by mining drill
Re: Tiberium mod ore spread not recognized by mining drill
Code: Select all
entity.active = false
entity.active = true
Re: Tiberium mod ore spread not recognized by mining drill
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.
/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
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.torndar wrote: ↑Sun Jan 06, 2019 10:54 pmI 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.
AKA: exactly what the core game would do if it handled this situation (and why it doesn't).
If you want to get ahold of me I'm almost always on Discord.
Re: Tiberium mod ore spread not recognized by mining drill
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/RITEGtorndar wrote: ↑Sun Jan 06, 2019 10:54 pmExplicitly 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.
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