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