Planet Arrakis

by Gladon

(Alpha version, development currently paused) Adding one of the legendary planets in fiction: Arrakis aka. Dune!

Content
30 days ago
2.0
6.06K
Factorio: Space Age Icon Space Age Mod
Environment

g Code Suggestions

3 months ago

Instead of checking the game tick % 600 in on_event, you should use on_nth_tick. It'll reduce the overhead during non-active ticks.

When refreshing ore, you should add a check to make sure the amount only increases. In fact it might be better to add the value instead of replacing, so a worm hanging around in one area for a long time makes a very rich spice field.

Ore reductions should happen before ore spawns, so that the freshly spawned ore doesn't get immediately reduced.

Define a SPAWN_RADIUS_SQUARED local, and use it to avoid doing an expensive math.sqrt 25 times in a row.

Instead of applying noise to the position, I think it would work better to apply noise to the ore amount based on distance from center, and simply skip to the next position if the ore amount comes up negative after applying noise. Something like local ore_amount_random = ORE_AMOUNT * (20 + 10*math.random() - x^2 - y^2)

Also, it would be significantly more complicated to implement, but you could consider iterating over the enemies and only spawning ore near one at a time, but on a faster cycle. This would reduce the amount of work that gets done in an individual tick.

Good luck with this project. I'm looking forward to playing with a legendary quality end result :)

3 months ago

Thanks for the interest.
Generally I know these things, but I just wanted to get it done quickly and dirty. The thing is in future versions the spice spawning is going to be completely different and so I didn't optimise the code as it will be obsolete soon.

3 months ago

I see.

In that case, I'll hold off on trying it until everything is slow and clean.

3 months ago

Also a small note, your mod will cause desyncs in multiplayer because of the local worm_brain = { } . Any data that might change during events must be stored in storage. So in the event you could simply do storage.worm_brain = storage.worm_brain or {}, and then use that for the rest.

3 months ago

Also a small note, your mod will cause desyncs in multiplayer because of the local worm_brain = { } . Any data that might change during events must be stored in storage. So in the event you could simply do storage.worm_brain = storage.worm_brain or {}, and then use that for the rest.

Ah thanks for the info

New response