Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

feat: Method to check if a technology is researchable #66

@EspadaV8

Description

@EspadaV8

Only just found out about this mod and was wondering if it'd possible to add something like flib_technology.is_researchable(technology). I have a very small mod and had to "implement" (I copied it from another mod) this, however, it only kind of works, since some technologies don't list all of their prerequisites (for example, the weapon damage and speed improvements don't list them all so the graph doesn't get cluttered) it's possible that this returns true when really the technology cannot be researched.

local flib_technology.is_researchable(technology)
    if (not technology.enabled) or technology.researched then
        return false
    end

    for _, prerequisite in pairs(technology.prerequisites) do
        if not prerequisite.researched then
            return false
        end
    end

    return true
end

I'm sure this could be improved, however, I don't have enough understanding of the Factorio data structures to know how to make those improvements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions