Skip to content

Commit

Permalink
fix adding a new line
Browse files Browse the repository at this point in the history
fix remote call hardReset to properly initialize SmartTrains
  • Loading branch information
Choumiko committed Jul 27, 2016
1 parent e2e3df9 commit 6e824c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ local update_from_version = {
global.settings.minFlow = nil
return "0.4.3"
end,
["0.4.3"] = function() return "0.4.4" end,
}

function on_configuration_changed(data)
Expand Down Expand Up @@ -1777,6 +1778,7 @@ remote.add_interface("st",
if confirm then
global = nil
initGlob()
init_forces()
init_players()
findStations()
end
Expand Down
14 changes: 9 additions & 5 deletions gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,11 @@ on_gui_click = {
option2 = tonumber(option2)
local t = global.trains[option2]
local is_copy = t.line and t.line ~= name

if not t.train.schedule.records then
player.print("Train has no stations in the schedule") --TODO localization
return
end

if name ~= "" and t and t.train.valid and #t.train.schedule.records > 0 then
local records = util.table.deepcopy(t.train.schedule.records)
--new train line
Expand Down Expand Up @@ -923,19 +927,19 @@ on_gui_click = {
for recordIndex, record in pairs(records) do

if record.station == records2[recordIndex].station then
log(record.station .. " " .. records2[recordIndex].station)
log(serpent.block({c1=record, c2=records2[recordIndex]}, {comment=false}))
--log(record.station .. " " .. records2[recordIndex].station)
--log(serpent.block({c1=record, c2=records2[recordIndex]}, {comment=false}))
if not util.table.compare(record.wait_conditions, records2[recordIndex].wait_conditions) then
diff[recordIndex] = table.deepcopy(record.wait_conditions)
end
else
return false
end
end
log(serpent.block(diff,{comment=false}))
--log(serpent.block(diff,{comment=false}))
return diff
end
local new_conditions = conditions_changed()
local new_conditions = trainline.records and conditions_changed()
trainline.records = records
trainline.rules = table.deepcopy(rules)

Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SmartTrains",
"version": "0.4.3",
"version": "0.4.4",
"factorio_version": "0.13",
"title": "Smarter Trains",
"author": "Choumiko",
Expand Down

0 comments on commit 6e824c7

Please sign in to comment.