Potential item search implementation

This commit is contained in:
Will Berry
2023-03-10 13:57:28 -05:00
parent 681358705f
commit 726b8162be
3 changed files with 40 additions and 26 deletions

View File

@@ -99,14 +99,9 @@ function stations_tab.build(map_data, player_data, query_limit)
end
if search_network_name then
--nil matches all?
if search_network_name == nil then
goto has_match
end
if search_network_name ~= station.network_name then
goto continue
end
::has_match::
local train_flag = get_network_flag(station, station.network_name)
if not bit32.btest(search_network_mask, train_flag) then
goto continue
@@ -128,12 +123,22 @@ function stations_tab.build(map_data, player_data, query_limit)
if search_item then
if not station.deliveries then
goto continue
end
for item_name, _ in pairs(station.deliveries) do
if item_name == search_item then
goto has_match
if station.deliveries then
for item_name, _ in pairs(station.deliveries) do
if item_name == search_item then
goto has_match
end
end
else
local comb1_signals, _ = get_signals(station)
for _, signal_ID in pairs(comb1_signals) do
local item = signal_ID.signal.name
if item then
if string.match(item, search_item) then
goto has_match
end
end
end
end
goto continue
@@ -289,7 +294,7 @@ function stations_tab.handle.open_station_gui(player, player_data, refs, e)
if e.shift then
if station_entity.surface ~= player.surface then
util.error_flying_text(gui.player, { "cybersyn-message.error-cross-surface-camera-invalid" })
util.error_flying_text(player, { "cybersyn-message.error-cross-surface-camera-invalid" })
else
player.zoom_to_world(station_entity.position, 1, station_entity)