Jump to content

Mine/Factory founding bugs (wrong mine/factory and no translation)


Rinart73

Recommended Posts

Found two bugs in the "data\scripts\entity\minefounder.lua" and one in the "data\scripts\entity\stationfounder.lua".

 

1. Sometimes when you want to create "Silver & Platinum" mine, "Silver & Gold" will be created instead. This happens because of typical "Lua doesn't care about the order in 'for in pairs'". Also because factories is categorized by goods but there is no check if current good is the first output.

How to fix:

Line 123-125, replace:

for _, productions in pairs(productionsByGood) do

        for index, production in pairs(productions) do

with

local production

    for _, productions in pairs(productionsByGood) do

        for index = 1, #productions do
            production = productions[index]

 

Line 138-142, replace:

if levels[result.level] ~= nil and not usedProductions[production.index] then
    usedProductions[production.index] = true
    table.insert(possibleProductions, {production=production, index=index})
end

with

if _ == production.results[1].name then
    if levels[result.level] ~= nil and not usedProductions[production.index] then
        usedProductions[production.index] = true
        table.insert(possibleProductions, {production=production, index=index})
    end
end

 


2. When you found a mine, it will have untranslated title.

How to fix:

Line 290, replace:

station:invokeFunction("factory", "setProduction", production, 1)

with

station:invokeFunction("factory", "setProduction", production, 1)
station:invokeFunction("factory", "updateTitle")

And remove lines 281-285:

if goodName == "Raw Oil" then
    station.title = "Oil Rig"%_t
else
    station.title = "${good} Mine"%_t % {good = goodName}
end

 


--------

3. Also, the same bug (wrong factory) can happen when founding stations. Just do the same in the "data\scripts\entity\stationfounder.lua" file:

Line 335-338, replace:

for _, productions in pairs(productionsByGood) do

        for index, production in pairs(productions) do

with

local production

    for _, productions in pairs(productionsByGood) do

        for index = 1, #productions do
            production = productions[index]

 

And Line 342-336, replace:

if levels[result.level] ~= nil and not usedProductions[production.index] then
    usedProductions[production.index] = true
    table.insert(possibleProductions, {production=production, index=index})
end

with

if _ == production.results[1].name then
    if levels[result.level] ~= nil and not usedProductions[production.index] then
        usedProductions[production.index] = true
        table.insert(possibleProductions, {production=production, index=index})
    end
end

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...