Pavement Drive Assist Continued

by azaghal

Introduces a driver assistance system that autonomously follows paved roads, while maintaining a preset cruise speed if desired.

Content
a month ago
1.1 - 2.0
15.6K
Transportation

i [DONE] How can I set road scores in my own mod?

2 years ago

I have my own mod for various tweaks and such, and would like to fine-tune some road scores. Is it possible to do this and if so how?

2 years ago

Hello there,

It really depends on what you exactly want to do.

If you simply want to change how pre-defined "categories" of roads are scored, it can be done through map settings. In that case I would recommend having a look at settings.lua file in the sources for exact names of settings, and override them through your mod's settings-updates.lua file.

If you are interested in tweaking what categories different tiles fall within, currently that's not possible. Although, I just realised it should be possible to tweak even that by introducing a remote interface that other mods could use to change the built-in categories.

So, which one are you trying to achieve? :)

2 years ago
(updated 2 years ago)

I was hoping for the latter. I'm have added asphalt as road surface for Transport Drones and was hoping to separate the drone network from the road system using yellow markings while reserving white lines to steer my car.

I'll look into editing config.lua directly.

2 years ago

Hm... Well, although the score assignments are currently static, I think it would be a good addition to expose that data in some form via remote interface or through configuration.

Perhaps the easiest thing would be to simply move those tile listings out of config.lua and into map settings - I'm just not sure what would be the maximum length for a text field in there. Some of those entries look repetative, so maybe I could resort to some kind of pattern matching in there (if only Lua supported POSIX regex...).

Settings would be a bit more user-friendly perhaps, although it's going to be a bit low-level, players will need to know internal names etc as well. Remote interface could allow mods to dynamically register themselves with PDA instead - which could make it easier to keep things up-to-date on other mod's side (although, I doubt many would integrate with PDA).

Heck, even a combination of these two might be useful.

Got any thoughts on your side? What would you prefer? The settings route would probably be fairly easy to implement.

2 years ago

I think that for most users who just want to tweak something (like me), the settings menu should be more than enough. As for implementation, I would add a custom category or two that override the default ones. This keeps both simple settings for the average user and more precise settings for those who want more control.

2 years ago

Not sure I would like to go with more custom categories, instead I think it would be more interesting to add ability to override default lists of configured tiles.

But... I have thought a bit about it, and I think the right way to sort it out would be to add a string setting for each existing category + one more string setting for a "none" category.

The code could then first apply default config, then iterate over comma-separated list of tiles in settings for each category and readjust the tiles.

Would this kind of thing help you? You could remove hazard tiles completely from config this way (setting it to "none" category), or lower their priority in this way.

Regarding the code you mentioned in the other thread, not sure how much you got into Factorio mod API and all of that, so if you need some clarifications, let me know. Looking at the code, maybe some optimisation would be needed to reduce number of calls, but... From what I can tell it should be safe to add the logic to the config.set_scores() function

2 years ago
(updated 2 years ago)

I've got the custom categories working, I basically split the string setting into a table and set the score for each at the end of set_scores(). This neatly overrides the earlier values as well. I'll push the repo to github so you can check it out: https://github.com/Nedreow/Factorio-PavementDriveAssistContinuedAgain.

Feel free to use it for anything.

2 years ago

Hello nedreow,

I have ended-up adding something in a new release that maybe could satisfy your use-case - namely the ability to add new tiles and reassign existing ones to different tilesets. While it does not introduce new categories, it would allow you to tweak how the tiles are being assigned, and for example completely unassign the hazard tiles from path-finding logic.

There is also a pair of commands that at least help a little bit in figuring out what the internal tile names are and what the mod currently can see as configured tilesets.

Let me know if you decide to try it out and see if it is helpful to you :)

Best regards,
Branko

1 year, 10 months ago

Hello again,

I'm doing some cleanup on old threads, and since I think the feature for reassigning tiles to different categories should cover your use-case, I'll mark the feature as implemented, and lock the topic. If you run into any more missing features or issues, please feel free to open up a new thread.

Thank you once again for providing all the feedback :)

This thread has been locked.