From b78485eaa5a9ba0bdb56ee3f5c1fe75d54a3b5dc Mon Sep 17 00:00:00 2001 From: Brevven Date: Sun, 4 Dec 2022 16:16:26 -0800 Subject: [PATCH] starting spawn --- changelog.txt | 2 ++ control.lua | 15 +++++++++++++++ locale/en/gas.cfg | 2 ++ prototypes/gas.lua | 1 - settings.lua | 7 +++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index a381509..bb37333 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ Version: 0.1.4 Date: 2022-12-02 Fixes: - Finite oil no longer produces gas when combined with some other mods + Changes: + - Add some gas to the starting area if there isn't any yet. (Can turn off in Map settings) --------------------------------------------------------------------------------------------------- Version: 0.1.3 Date: 2022-10-23 diff --git a/control.lua b/control.lua index 2afa613..78867c4 100644 --- a/control.lua +++ b/control.lua @@ -14,3 +14,18 @@ function on_console_chat(event) end end script.on_event(defines.events.on_console_chat, on_console_chat) + +function on_init() + if global.starting_spawn then return end + if settings.global["bzgas-force-spawn"].value then + local gas = game.surfaces["nauvis"].find_entities_filtered({area = {{-100, -100}, {100, 100}}, name="gas"}) + if #gas == 0 then + local position=game.surfaces["nauvis"].find_non_colliding_position("gas", {math.random(-100,100),math.random(-100,100)}, 0, 1) + if position then + game.surfaces["nauvis"].create_entity({name="gas", amount=math.random(400000, 999999), position=position}) + end + end + end + global.starting_spawn = true +end +script.on_init(on_init) diff --git a/locale/en/gas.cfg b/locale/en/gas.cfg index 8412fcc..454d778 100644 --- a/locale/en/gas.cfg +++ b/locale/en/gas.cfg @@ -43,12 +43,14 @@ bzgas-list=Make a list of modified recipes bzgas-more-intermediates=Enable more intermediates bzgas-handcraft=Add hand-craft circuit recipe bzgas-boiler=Enable ElAdamo's fluid boiler +bzgas-force-spawn=Force starting spawn [mod-setting-description] bzgas-recipe-bypass=Skip modifying these recipes (comma-separated list). bzgas-list=If enabled, the text command [color=orange]BZList[/color] will dump a file to the script-output directory with a full list of recipes modified.\nRecommended to turn this off after you are done configuring your other settings. bzgas-boiler=Natural gas mod currnelty can incorporate ElAdamo's public domain fluid boiler. If that mod is updated to 1.1, this may be removed. bzgas-handcraft=This enables an alternative wood-based handcrafting-only recipe for electronic circuits. Defaults to off, as bakelite only takes a few steps to make, but provided to enable varying playstyles. +bzgas-force-spawn=Force a spawn of natural gas in the starting area, if the game does not spawn one. [string-mod-setting] bzgas-more-intermediates-no=No diff --git a/prototypes/gas.lua b/prototypes/gas.lua index 342addc..2830faf 100644 --- a/prototypes/gas.lua +++ b/prototypes/gas.lua @@ -156,5 +156,4 @@ if util.me.finite() then }, }, } - end diff --git a/settings.lua b/settings.lua index d998bee..57148d1 100644 --- a/settings.lua +++ b/settings.lua @@ -32,4 +32,11 @@ data:extend({ setting_type = "startup", default_value = true, }, + + { + type = "bool-setting", + name = "bzgas-force-spawn", + setting_type = "runtime-global", + default_value = true, + }, })