mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-14 02:12:42 -06:00
added null check
This commit is contained in:
@@ -181,37 +181,39 @@ function set_manifest_schedule(map_data, train, depot_name, d_surface_i, p_stop,
|
|||||||
if (is_p_on_t or p_surface_i == other_surface_i) and (is_r_on_t or r_surface_i == other_surface_i) and (is_d_on_t or d_surface_i == other_surface_i) then
|
if (is_p_on_t or p_surface_i == other_surface_i) and (is_r_on_t or r_surface_i == other_surface_i) and (is_d_on_t or d_surface_i == other_surface_i) then
|
||||||
local t_zone = remote.call("space-exploration", "get_zone_from_surface_index", {surface_index = t_surface_i})--[[@as {}]]
|
local t_zone = remote.call("space-exploration", "get_zone_from_surface_index", {surface_index = t_surface_i})--[[@as {}]]
|
||||||
local other_zone = remote.call("space-exploration", "get_zone_from_surface_index", {surface_index = other_surface_i})--[[@as {}]]
|
local other_zone = remote.call("space-exploration", "get_zone_from_surface_index", {surface_index = other_surface_i})--[[@as {}]]
|
||||||
local is_train_in_orbit = other_zone.orbit_index == t_zone.index
|
if t_zone and other_zone then
|
||||||
if is_train_in_orbit or t_zone.orbit_index == other_zone.index then
|
local is_train_in_orbit = other_zone.orbit_index == t_zone.index
|
||||||
local elevator_name = se_get_space_elevator_name(t_surface)
|
if is_train_in_orbit or t_zone.orbit_index == other_zone.index then
|
||||||
if elevator_name then
|
local elevator_name = se_get_space_elevator_name(t_surface)
|
||||||
local records = {create_inactivity_order(depot_name)}
|
if elevator_name then
|
||||||
if t_surface_i == p_surface_i then
|
local records = {create_inactivity_order(depot_name)}
|
||||||
records[#records + 1] = create_direct_to_station_order(p_stop)
|
if t_surface_i == p_surface_i then
|
||||||
else
|
records[#records + 1] = create_direct_to_station_order(p_stop)
|
||||||
records[#records + 1] = se_create_elevator_order(elevator_name, is_train_in_orbit)
|
else
|
||||||
is_train_in_orbit = not is_train_in_orbit
|
records[#records + 1] = se_create_elevator_order(elevator_name, is_train_in_orbit)
|
||||||
end
|
is_train_in_orbit = not is_train_in_orbit
|
||||||
records[#records + 1] = create_loading_order(p_stop, manifest)
|
end
|
||||||
|
records[#records + 1] = create_loading_order(p_stop, manifest)
|
||||||
|
|
||||||
if p_surface_i ~= r_surface_i then
|
if p_surface_i ~= r_surface_i then
|
||||||
records[#records + 1] = se_create_elevator_order(elevator_name, is_train_in_orbit)
|
records[#records + 1] = se_create_elevator_order(elevator_name, is_train_in_orbit)
|
||||||
is_train_in_orbit = not is_train_in_orbit
|
is_train_in_orbit = not is_train_in_orbit
|
||||||
elseif t_surface_i == r_surface_i then
|
elseif t_surface_i == r_surface_i then
|
||||||
records[#records + 1] = create_direct_to_station_order(r_stop)
|
records[#records + 1] = create_direct_to_station_order(r_stop)
|
||||||
end
|
end
|
||||||
records[#records + 1] = create_unloading_order(r_stop)
|
records[#records + 1] = create_unloading_order(r_stop)
|
||||||
if r_surface_i ~= d_surface_i then
|
if r_surface_i ~= d_surface_i then
|
||||||
records[#records + 1] = se_create_elevator_order(elevator_name, is_train_in_orbit)
|
records[#records + 1] = se_create_elevator_order(elevator_name, is_train_in_orbit)
|
||||||
is_train_in_orbit = not is_train_in_orbit
|
is_train_in_orbit = not is_train_in_orbit
|
||||||
end
|
end
|
||||||
|
|
||||||
train.schedule = {current = start_at_depot and 1 or 2--[[@as uint]], records = records}
|
train.schedule = {current = start_at_depot and 1 or 2--[[@as uint]], records = records}
|
||||||
if old_schedule and not train.has_path then
|
if old_schedule and not train.has_path then
|
||||||
train.schedule = old_schedule
|
train.schedule = old_schedule
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
return true
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user