Added config for silo script

This commit is contained in:
Cooldude2606
2019-05-28 01:20:58 +01:00
parent 56b102d823
commit 0ddf4676fe
3 changed files with 41 additions and 11 deletions

View File

@@ -62,6 +62,9 @@ end
return {
skip_intro=true, -- skips the intro given in the default factorio free play scenario
skip_victory=true, -- will skip the victory screen when a rocket is launched
disable_base_game_silo_script=true, -- will not load the silo script at all
research_queue_from_start=true, -- when true the research queue is useible from the start
friendly_fire=false, -- weather players will be able to attack each other on the same force
enemy_expansion=false, -- a catch all for in case the map settings file fails to load
chart_radius=10*32, -- the number of tiles that will be charted when the map starts

View File

@@ -31,4 +31,14 @@ Event.on_init(function()
remote.call('freeplay','set_created_items',{})
remote.call('freeplay','set_chart_distance',0)
remote.call('freeplay','set_skip_intro',config.skip_intro)
if config.research_queue_from_start then
for _,force in pairs(game.forces) do
force.research_queue_enabled = true
end
end
if not config.disable_base_game_silo_script then
if config.skip_victory then
remote.call('silo_script','set_no_victory',true)
end
end
end)

View File

@@ -1,8 +1,13 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
local config = require 'config.advanced_start'
local use_silo_script = not config.disable_base_game_silo_script
local util = require("util")
local silo_script = require("silo-script")
local silo_script
if use_silo_script then
silo_script = require("silo-script")
end
local global = {}
Global.register(global,function(tbl)
@@ -29,8 +34,10 @@ local respawn_items = function()
}
end
for k,v in pairs(silo_script.get_events()) do
Event.add(k, v)
if use_silo_script then
for k,v in pairs(silo_script.get_events()) do
Event.add(k, v)
end
end
Event.add(defines.events.on_player_created, function(event)
@@ -48,27 +55,37 @@ Event.add(defines.events.on_player_created, function(event)
end
end
silo_script.on_event(event)
if use_silo_script then
silo_script.on_event(event)
end
end)
Event.add(defines.events.on_player_respawned, function(event)
local player = game.players[event.player_index]
util.insert_safe(player, global.respawn_items)
silo_script.on_event(event)
if use_silo_script then
silo_script.on_event(event)
end
end)
Event.on_load(function()
silo_script.on_load()
end)
if use_silo_script then
Event.on_load(function()
silo_script.on_load()
end)
end
Event.on_init(function()
global.created_items = created_items()
global.respawn_items = respawn_items()
silo_script.on_init()
if use_silo_script then
silo_script.on_init()
end
end)
silo_script.add_remote_interface()
silo_script.add_commands()
if use_silo_script then
silo_script.add_remote_interface()
silo_script.add_commands()
end
remote.add_interface("freeplay",
{