Tiberium mod ore spread not recognized by mining drill

Place to get help with not working mods / modding interface.
Post Reply
torndar
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Aug 25, 2015 7:41 pm
Contact:

Tiberium mod ore spread not recognized by mining drill

Post 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


torndar
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Aug 25, 2015 7:41 pm
Contact:

Re: Tiberium mod ore spread not recognized by mining drill

Post 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13346
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Tiberium mod ore spread not recognized by mining drill

Post 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).
If you want to get ahold of me I'm almost always on Discord.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Tiberium mod ore spread not recognized by mining drill

Post 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

Post Reply

Return to “Modding help”