Skip to content

Instantly share code, notes, and snippets.

@akarnokd
Created October 8, 2022 09:49
Show Gist options
  • Save akarnokd/fcf8029e932d2c17c14e14e42964733a to your computer and use it in GitHub Desktop.
Save akarnokd/fcf8029e932d2c17c14e14e42964733a to your computer and use it in GitHub Desktop.
script.on_event(defines.events.on_player_setup_blueprint, function(event)
local player = game.get_player(event.player_index)
local bp = player.blueprint_to_setup
if not bp.valid_for_read then
bp = player.cursor_stack
end
local bp_ents = bp.get_blueprint_entities()
if bp_ents then
local source = event.mapping.get()
for i, entity in pairs(bp_ents) do
local sourceEntity = source[entity.entity_number]
if sourceEntity then
if sourceEntity.name == "akarnokd-latc-active" or sourceEntity.name == "akarnokd-latc-passive" then
if not entity.tags then
entity.tags = { }
end
local v = getLimit(sourceEntity)
entity.tags["latcLimit"] = v
log("Tagging " .. entity.entity_number .. " of " .. sourceEntity.name .. " for " .. tostring(v))
elseif sourceEntity.name == "akarnokd-latc-requester" then
local trs = getThreshold(sourceEntity)
if trs then
if not entity.tags then
entity.tags = { }
end
entity.tags["latcThreshold"] = trs
log("Tagging " .. entity.entity_number .. " of " .. sourceEntity.name .. " for "
.. tostring(trs.enabled) .. ", "
.. tostring(trs.minValue) .. ", "
.. tostring(trs.maxValue) .. ", "
.. tostring(trs.request) .. ", "
)
end
end
end
end
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment