EarendelDevelopers / factorio-mods

This is a public repository for tracking issues with Earendel's factorio mods.
19 stars 3 forks source link

[SE] Universe's resources API #298

Open RedRafe opened 1 year ago

RedRafe commented 1 year ago

Hi, I would like to discuss possible features of the universe's generation and resource placement on planets/moons to improve compatibility with other mods which add/modify resources :)

Currently the universe building and placement of resources is handled by SE with many hardcoded values during control stage, making it difficult for other mods to interact with it i.e. moving resources outside Nauvis, setting planets/moons to have a different primary resource different from the hardcoded one

The goal would be to basically expose Universe/Universe-raw to other mods, with the possibility to Get/Add/Remove resources (any resource, new ones and even vanilla ones) globally, and tweak planets/moons' resources settings.

Now, I know this is a big feature that would require some refactor of the code, and I don't have a PR ready with the solution to be applied, but I've brainstormed a couple of possible solutions that we can work on together and help each other:

  1. SE exposes remote interfaces in control stage for other mods to Get/Add/Remove resources and tweak planets/moons configs (targeting all universe-raw.lua, and mainly universe.lua L127-207. Has a bit of work on your part to implement the API, but then could be used internally both by SE and by any other mod independently without disrupting too much the flow of control, as the remote calls would be done before on_init when SE builds the universe

-or-

  1. Have other mods expose their own remote interfaces (in a specific format) with the intended changes, and then handle them on your side. Would not require a big work on the API, but more logic to integrate the requests, especially if there are conflicting requests from different mods. In that case, SE would have the upper hand on how to manage the issues

These are jus 2 possible solutions, might not even be the better ones of course. The end goal is still to make resource handling a bit more dynamic rather than just hardcoded on SE's side :)

Wiwiweb commented 9 months ago

Sorry this slipped through the backlog of tickets.

I think this is something we would like to have. Most likely we would go with option 2, the reverse remote interfaces, similar to how Jetpack does custom fuels.

At the moment though I don't think we can prioritize this work ourselves. Mostly because the universe generation code will be changed a lot for 0.7 and adding this now would cause some amount of wasted work, but also because compatibility work in general is lower-priority while SE is still under development.

If you would like to provide a patch, we will take a look and see if we can integrate it. It will probably have to be reworked or removed for 0.7, though that is still far off.