Skip to content

Instantly share code, notes, and snippets.

@akarnokd
Created October 8, 2022 09:49
Show Gist options
  • Select an option

  • Save akarnokd/fcf8029e932d2c17c14e14e42964733a to your computer and use it in GitHub Desktop.

Select an option

Save akarnokd/fcf8029e932d2c17c14e14e42964733a to your computer and use it in GitHub Desktop.

Revisions

  1. akarnokd created this gist Oct 8, 2022.
    40 changes: 40 additions & 0 deletions on_player_setup_blueprint.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    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)