Skip to content

Commit

Permalink
Cache get_signal
Browse files Browse the repository at this point in the history
  • Loading branch information
theRustyKnife committed Jul 18, 2020
1 parent 86b0863 commit 27c1291
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crafting_combinator/script/recipe-selector.lua
Expand Up @@ -65,11 +65,17 @@ function _M.get_recipes(entity, circuit_id, mode, last_signal, last_count)
end


local signal_cache = {}
function _M.get_signal(recipe)
return {
name = recipe,
type = (game.item_prototypes[recipe] and 'item') or (game.fluid_prototypes[recipe] and 'fluid') or 'virtual'
}
local signal = signal_cache[recipe]
if not signal then
signal = {
name = recipe,
type = (game.item_prototypes[recipe] and 'item') or (game.fluid_prototypes[recipe] and 'fluid') or 'virtual'
}
signal_cache[recipe] = signal
end
return signal
end


Expand Down

0 comments on commit 27c1291

Please sign in to comment.