Pavement Drive Assist

by Arcitos

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

Utilities
4 years ago
0.14 - 0.18
184

g 1.1 Update Please

3 years ago

I nag after a week, just for future reference ;-)

3 years ago

+1

3 years ago

+1 here! I wanna do a cityblock base in my next playtrough, pavement driving system would really tie it together well.

3 years ago

+1 pleaseeeeee!!!!

3 years ago

I have another vote to throw into the void
one of the most useful mods in the game period

3 years ago

+1 Pretty Please

3 years ago

Updating the Factorio version in info.json to 1.1 will get game saves to work along with most functions. I haven't placed many (any) new signs recently until today and discovered there are some other bugs to work out. Once (if) I get them sorted out I'll post my findings for anyone that wants to manually update in the absence of the mod dev.

3 years ago

Hi Fitwe, lemme know if you decide on updating it. I will help out as much as I can :)

Really cant play factorio without this mod :( such a lovely mod!

3 years ago

I think this was the only change I made...in pda.lua, line 1077

change

e.get_or_create_control_behavior().parameters = {parameters={{index = 1, count = limit, signal = {type="virtual", name="signal-L"}}}}

to

e.get_or_create_control_behavior().parameters = {index = 1, count = limit, signal = {type="virtual", name="signal-L"}}

3 years ago

+1 for update 1.1! thanks

3 years ago
(updated 3 years ago)

There is a couple more places that need to be fixed for accessing the parameters attribute. Relevant change in Factorio API was made to LuaConstantCombinatorControlBehavior (see https://forums.factorio.com/viewtopic.php?p=518171#p518171). In addition, the dialog for setting the cruise speed will crash if the value has already been set. The fix for this seems to be simply invoking tostring function on one of the returned values.

I have not done any thorough tests for the road sensor, though - haven't used this before, so not quite sure what to do with it/how to set it up :)

Update 1: I followed the FAQ to set-up a simple crossing, and it looks to me like the road sensor works correctly as well with the patch applied. I have not tested the road crossing set-up in server environment (with multiple players and stop signs).

My full patch currently looks as follows:

diff --git a/info.json b/info.json
index cef8fc3..db2781f 100644
--- a/info.json
+++ b/info.json
@@ -1,10 +1,10 @@
 {
   "name": "PavementDriveAssist",
   "version": "2.2.0",
   "title": "Pavement Drive Assist",
   "author": "Arcitos",
   "homepage": "",
   "description": "Introduces a driver assistance system that autonomously follows paved roads, while maintaining a preset cruise speed if desired.",
-  "factorio_version": "0.18",
+  "factorio_version": "1.1",
   "dependencies": ["?AsphaltRoads"]
-}
\ No newline at end of file
+}
diff --git a/pda.lua b/pda.lua
index da748b5..6097e8f 100644
--- a/pda.lua
+++ b/pda.lua
@@ -317,7 +317,7 @@ function pda.set_cruise_control_limit(event)
                 PDA_Modgui.create_cc_limit_gui(player)
                 -- if cruise control is active, load the current limit
                 if global.cruise_control[player.index] == true then
-                    player.gui.center.pda_cc_limit_gui_frame.pda_cc_limit_gui_textfield.text = mpt_to_kmph(global.cruise_control_limit[player.index])
+                    player.gui.center.pda_cc_limit_gui_frame.pda_cc_limit_gui_textfield.text = tostring(mpt_to_kmph(global.cruise_control_limit[player.index]))
                 else
                     player.gui.center.pda_cc_limit_gui_frame.pda_cc_limit_gui_textfield.text = ""
                 end
@@ -601,7 +601,7 @@ local function register_to_road_sensor(sign, player_index, velocity)
             end
         end
     else
-        for _, s in pairs(signals.parameters.parameters) do
+        for _, s in pairs(signals.parameters) do
             if find[s.signal.name] then
                 found[s.signal.name] = s.count
                 find[s.signal.name] = false
@@ -725,7 +725,7 @@ local function update_road_sensor_data(sign_uid)
             end
         end
     else
-        for _, s in pairs(signals.parameters.parameters) do
+        for _, s in pairs(signals.parameters) do
             if find[s.signal.name] then
                 found[s.signal.name] = s.count
                 find[s.signal.name] = false
@@ -1074,18 +1074,19 @@ function pda.on_placed_sign(event)
                 if p ~= nil then
                     limit = game.players[p].mod_settings["PDA-setting-personal-limit-sign-speed"].value
                 end
-                e.get_or_create_control_behavior().parameters = {parameters={{index = 1, count = limit, signal = {type="virtual", name="signal-L"}}}}
+                e.get_or_create_control_behavior().parameters = {{index = 1, count = limit, signal = {type="virtual", name="signal-L"}}}
             end
         elseif e.name == "pda-road-sensor" then
             create_sign_logic_table(e)
             local limit = p ~= nil and game.players[p].mod_settings["PDA-setting-personal-limit-sign-speed"].value or settings.global["PDA-setting-server-limit-sign-speed"].value
             local params = e.get_or_create_control_behavior().parameters
-            e.get_or_create_control_behavior().parameters = {parameters={
-                {index = 1, count = 0, signal = {type="virtual", name="signal-V"}},
-                {index = 2, count = (params.parameters[2].signal.name == "signal-C" and params.parameters[2].count) or -1, signal = {type="virtual", name="signal-C"}},
-                {index = 3, count = (params.parameters[3].signal.name == "signal-S" and params.parameters[3].count) or 0, signal = {type="virtual", name="signal-S"}},
-                {index = 4, count = (params.parameters[4].signal.name == "signal-L" and params.parameters[4].count) or limit, signal = {type="virtual", name="signal-L"}}
-            }}
+            e.get_or_create_control_behavior().parameters =
+                {
+                    {index = 1, count = 0, signal = {type="virtual", name="signal-V"}},
+                    {index = 2, count = (params[2].signal.name == "signal-C" and params[2].count) or -1, signal = {type="virtual", name="signal-C"}},
+                    {index = 3, count = (params[3].signal.name == "signal-S" and params[3].count) or 0, signal = {type="virtual", name="signal-S"}},
+                    {index = 4, count = (params[4].signal.name == "signal-L" and params[4].count) or limit, signal = {type="virtual", name="signal-L"}}
+                }
         end
     end
 end
@@ -1198,4 +1199,4 @@ function pda.on_tick(event)
         end
     end
     --global.playertick = ptick
-end
\ No newline at end of file
+end
3 years ago

Oh, and it would be interesting if the original mod author (Arcitos) would step in or perhaps be interested to turn over to mod to someone who wants to maintain it (if not into Factorio any longer) - maybe some kind of shared custody (for reducing the truck factor of 1) would be a good idea in general. This mod is a real gem, and it would be a shame if it were lost or had to be forked. :)

3 years ago
(updated 3 years ago)

+1 and thanks for the patch
One more bug I found (and since it's technicallt not official mod version bug and You are working on hotfix I'll post it here):
When trying to enter one of the avaliable testing areas in tips/tricks menu (the one between bonuses and trains) there is an error caused by .../migrations/2.1.8.lua.
Commenting out the file resolves the problem.

3 years ago
(updated 3 years ago)

(nevermind)

3 years ago

@Mathematician: Could you be more precise on how to reproduce this? I have launched-up a fresh install, deployed patched Pavement Drive Assist, and opened the tips and tricks window. I have then read through all of the tips, and no errors were reported.

What do you mean regarding "trying to enter one of the available testing areas"? Is there some way to go into the tips and tricks simulation as a player?

3 years ago

@Mathematician: Ah, gotcha, when trying to play a tutorial in one of those, I managed to reproduce it :)

3 years ago

Ok, so I do not think that the file should be commented out, there is probably a good reason why the migration is there. I think there is just an erroneously commented-out line in that file (the first one), but I'll try to maybe install some older version of Factorio for testing this through :)

P.S.
Funnily enough, I get a different error when trying to play a tutorial, but that might be related to the way I launch Factorio instances...

3 years ago

Is ther hope to have this working for current version and future versions? at least the auto-turn feature. The rest of the features are good but the escencial is to be able to drive at full speed and do not crash constantly.
I know little programing, I wonder if this is a good start to incurse myself into java or if this is too advanced

3 years ago

Hello folks,

After some time of waiting, I have decided to fork the mod and update it for Factorio 1.1. Initially I did try to reach out to Arcitos on forums to see if he would be interested in sharing project maintenance, but I haven't received any replies.

The idea is to make the fork somewhat more viable long-term, and for this purpose I have set-up a project repository on Github, as well as imported all the previous archive-only releases for historic purposes.

Now, while I cannot guarantee improvements in terms of driving algorithms, I will at least try to maintain compatibility, fix crashes, and possibly clean-up the code here and there. For now the fork contains just the patch that I have posted above (which is pretty trivial in its own), some wording changes to documentation, and tidied-up licensing information (still MIT, just update formatting a bit and added the original author - sillyfly - to places where his name was probably removed by mistake).

Should you wish to give the fork a go, you can find it at:

https://mods.factorio.com/mod/PavementDriveAssistContinued

Just make sure to backup your savegame before trying it out, please!

Best regards

P.S.
This is a friendly fork, should it happen that Arcitos comes back, no reason not to merge the efforts :)

3 years ago

thank you a lot for your work!

2 years ago

Kommt ein Update auf 1.1?

New response