1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

After init, check if loaders should be enabled.

This commit is contained in:
plague006 2019-02-18 01:16:21 -05:00
parent 06915dd5bb
commit 7f53ad171d

View File

@ -6,6 +6,7 @@ local Event = require 'utils.event'
local Utils = require 'utils.core'
local Global = require 'utils.global'
local table = require 'utils.table'
local Task = require 'utils.task'
local Rank = require 'features.rank_system'
local config = global.config.redmew_qol
@ -41,13 +42,6 @@ local random_train_color =
end
)
local function on_init()
-- Set player force's ghost_time_to_live to an hour. Giving the players ghosts before the research of robots is a nice QOL improvement.
if config.ghosts_before_research then
Public.set_ghost_ttl()
end
end
--- If a newly placed entity is a provider or non-logi chest, set it to only have 1 slot available.
-- If placed from a bp and the bp has restrictions on the chest, it takes priority.
local restrict_chest =
@ -112,6 +106,21 @@ local function enable_loaders(event)
end
end
--- After init, checks if any of the loader techs have been researched
-- and enables loaders if appropriate.
local loader_check_token =
Token.register(
function()
for _, force in pairs(game.forces) do
for key, recipe in pairs(loaders_technology_map) do
if force.technologies[key].researched then
force.recipes[recipe].enabled = true
end
end
end
end
)
-- Event registers
local function register_random_train_color()
@ -143,6 +152,16 @@ local function register_change_backer_name()
return true
end
local function on_init()
-- Set player force's ghost_time_to_live to an hour. Giving the players ghosts before the research of robots is a nice QOL improvement.
if config.ghosts_before_research then
Public.set_ghost_ttl()
end
if config.loaders then
Task.set_timeout_in_ticks(1, loader_check_token, nil)
end
end
Event.on_init(on_init)
-- Public functions