diff --git a/cybersyn/info.lua b/cybersyn/info.lua index 860f838..90cefac 100644 --- a/cybersyn/info.lua +++ b/cybersyn/info.lua @@ -3,4 +3,4 @@ --- It is used in migrations.lua to determine if any migrations need to be run for beta testers. --- It is expected these are only meaningful between releases during beta testing. --- It should be set to nil for any release version. -return 1 +return 2 diff --git a/cybersyn/locale/en/base.cfg b/cybersyn/locale/en/base.cfg index d7ec62c..dbba4ea 100644 --- a/cybersyn/locale/en/base.cfg +++ b/cybersyn/locale/en/base.cfg @@ -87,9 +87,9 @@ switch-request-tooltip=Lock this station to only request items from the network. network=Network network-tooltip=A signal is used to identify which network this combinator is a member of. Trains will only be dispatched from depots to provider and requester stations if they are all identified with the same signal. allow-list-description=Automatic allow-list -allow-list-tooltip=When checked trains in the network are automatically added to the allow-list if every wagon of the train is able to be loaded or unloaded by this station. When unchecked the allow-list is not used and all trains are allowed to park here. +allow-list-tooltip=Normally when a delivery is requested, any train with a large enough cargo capacity may fulfill it. When this setting is checked trains must also be on this station's "allow-list". Trains are automatically added to the allow-list if each of its wagons are able to be loaded or unloaded by inserters or pumps along this station. is-stack-description=Stack thresholds -is-stack-tooltip=When checked all request thresholds for this station are interpretted as a count of item stacks rather than a count of total items. Thresholds for fluids are unaffected. +is-stack-tooltip=When checked all request thresholds for this station are interpreted as a count of item stacks rather than a count of total items. Thresholds for fluids are unaffected. enable-inactive-description=Inactivity condition enable-inactive-tooltip=When checked a train at a provider is required to wait for inactivity even if its order has been fulfilled. This is frequently useful for preventing inserters from getting items stuck in their hands. use-same-depot-description=Require same depot diff --git a/cybersyn/scripts/factorio-api.lua b/cybersyn/scripts/factorio-api.lua index b053e19..a34109e 100644 --- a/cybersyn/scripts/factorio-api.lua +++ b/cybersyn/scripts/factorio-api.lua @@ -3,6 +3,8 @@ local get_distance = require("__flib__.position").distance local table_insert = table.insert local bit_extract = bit32.extract local bit_replace = bit32.replace +local string_sub = string.sub +local string_len = string.len local DEFINES_WORKING = defines.entity_status.working local DEFINES_LOW_POWER = defines.entity_status.low_power @@ -38,19 +40,14 @@ end function se_get_space_elevator_name(cache, surface) ---@type LuaEntity? local entity = nil - ---@type string? - local name = nil - local cache_idx = 2*surface.index + local cache_idx = surface.index if cache.se_get_space_elevator_name then - entity = cache.se_get_space_elevator_name[cache_idx - 1] - name = cache.se_get_space_elevator_name[cache_idx] + entity = cache.se_get_space_elevator_name[cache_idx] else cache.se_get_space_elevator_name = {} end - if entity and entity.valid then - return name - else + if not entity or not entity.valid then --Chaching failed, default to expensive lookup entity = surface.find_entities_filtered({ name = SE_ELEVATOR_STOP_PROTO_NAME, @@ -59,14 +56,15 @@ function se_get_space_elevator_name(cache, surface) })[1] if entity then - name = string.sub(entity.backer_name, 1, string.len(entity.backer_name) - SE_ELEVATOR_SUFFIX_LENGTH) - cache.se_get_space_elevator_name[cache_idx - 1] = entity - cache.se_get_space_elevator_name[cache_idx] = name - return name - else - return nil + cache.se_get_space_elevator_name[cache_idx] = entity end end + + if entity and entity.valid then + return string_sub(entity.backer_name, 1, string_len(entity.backer_name) - SE_ELEVATOR_SUFFIX_LENGTH) + else + return nil + end end ---@param cache PerfCache ---@param surface_index uint