Factorio and Conquer: Tiberian Dawn


Adds Tiberium ore that spreads - Harvest it, refine it, and convert it to power, weapons, and other ores. By Zillo7 (0.15), SAH4001 (0.16), Oktabyte (0.17), JamesFire and randomflyingtaco (0.17 update and 0.18+)

Content
a day ago
0.17 - 2.0
18.9K
Combat Environment Mining Manufacturing Power

i [Fixed] Function to add tiberium-basic-science and tiberium-science more easily

3 years ago

I am playing around with Yuoki's mods, Mobile Factory Erya, and some of 5Dims mods. They add some assemblers and chem plants. This function will add Tiberium science to all applicable prototypes:

local function addScienceIfNeeded(prototype)
    local basics_chem = {
        chemistry = true
    }
    local basics_asm = {
        crafting = true,
        ["basic-crafting"] = true,
        ["advanced-crafting"] = true,
    }
    local categories = prototype.crafting_categories or {}
    for k, v in pairs(categories) do
        if v == "basic-tiberium-science" or v == "tiberium-science" then return end
        if basics_chem[v] then basics_chem[v] = nil end
        if basics_asm[v] then basics_asm[v] = nil end
    end
    if table_size(basics_chem) == 0 then
        table.insert(categories, "basic-tiberium-science")
        table.insert(categories, "tiberium-science")
    elseif table_size(basics_asm) == 0 then
        table.insert(categories, "basic-tiberium-science")
    end
end

I added it in data-updates, and call it below the existing two add functions (starting with for _, assembler in pairs(TibBasicScience) do).

Another suggestion: the science table is set up with names as values. LSLib probably protects against adding a crafting category twice by accident, but if the TibScience tables were instead ["prototype-name"] = true, then one could use any logic to add the machines, without having to be concerned with it being present multiple times in the table (as may happen with table.insert()).

The above function could be tweaked of course, to add prototype names to the TibScience tables, instead of modifying the prototype itself

3 years ago

Good idea, I've added this in 1.1.17

New response