Skip to content

Commit

Permalink
Fixes nil error #3493
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Oct 4, 2024
1 parent d3d723b commit 0b7841b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions scripts/Course.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,8 @@ function Course:saveToXml(courseXml, courseKey)
end
end

---@param vehicle table
---@param courseXml XmlFile
---@param vehicle table|nil
---@param courseXml table
---@param courseKey string key to the course in the XML
function Course.createFromXml(vehicle, courseXml, courseKey)
local course = Course(vehicle, {})
Expand Down Expand Up @@ -1602,7 +1602,9 @@ function Course.createFromXml(vehicle, courseXml, courseKey)
if course.nVehicles and course.nVehicles > 1 then
course.multiVehicleData = Course.MultiVehicleData.createFromXmlFile(courseXml, courseKey)
course:setPosition(course.multiVehicleData:getPosition())
vehicle:getCpLaneOffsetSetting():setValue(course.multiVehicleData:getPosition())
if vehicle then
vehicle:getCpLaneOffsetSetting():setValue(course.multiVehicleData:getPosition())
end
else
course:enrichWaypointData()
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/editor/CourseEditor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function CourseEditor:loadCourse()
local function load(self, xmlFile, baseKey, noEventSend, name)
xmlFile:iterate(baseKey, function (i, key)
CpUtil.debugVehicle(CpDebug.DBG_COURSES, self, "Loading assigned course: %s", key)
local course = Course.createFromXml(self, xmlFile, key)
local course = Course.createFromXml(nil, xmlFile, key)
course:setName(name)
self.courseWrapper = EditorCourseWrapper(course)
end)
Expand Down

0 comments on commit 0b7841b

Please sign in to comment.