Skip to content

Commit

Permalink
YAFC compatibility #44
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiHawk committed Feb 21, 2021
1 parent 73c3565 commit f3eaa51
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
1 change: 1 addition & 0 deletions SeaBlock/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Date: ???
- Increased starting landfill from 1k to 2k
- Updated crystallization recipe icons
- Unsubscribe from relevant event handlers after home rock has been placed / all tutorial techs have been unlocked
- Added table of starting tech and items for YAFC to read
Bugfixes:
- Fixed crash when Train Construction Site is enabled
- Fixed Forage for cellulose fiber recipe not usable with mods that replace the default character
Expand Down
31 changes: 4 additions & 27 deletions SeaBlock/control.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
seablock = seablock or {}

require "starting-items"

function seablock.GiveResearch(force)
if not force.technologies['sb-startup1'].researched then
force.add_research("sb-startup1")
end
end

function seablock.GiveItems(entity)
local landfill = 'landfill'
if settings.startup['sb-default-landfill'] and game.item_prototypes[settings.startup['sb-default-landfill'].value] then
landfill = settings.startup['sb-default-landfill'].value
end
local stuff = {
{landfill, 2000},
{"stone", 50},
{"small-electric-pole", 50},
{"small-lamp", 12},
{"iron-plate", 1200},
{"basic-circuit-board", 200},
{"stone-pipe", 100},
{"stone-pipe-to-ground", 50},
{"stone-brick", 500},
{"pipe", 22},
{"copper-pipe", 5},
{"iron-gear-wheel", 20},
{"iron-stick", 96},
{"pipe-to-ground", 2}
}
if game.item_prototypes["wind-turbine-2"] then
table.insert(stuff, {"wind-turbine-2", 120})
else
table.insert(stuff, {"solar-panel", 38})
table.insert(stuff, {"accumulator", 32})
end
for _,v in ipairs(stuff) do
for _,v in pairs(global.starting_items) do
entity.insert{name = v[1], count = v[2]}
end
end
Expand All @@ -46,6 +22,7 @@ end

local function init()
SetPvp()
seablock.Populate_Starting_Items(global, game.item_prototypes)
if remote.interfaces.freeplay and remote.interfaces.freeplay.set_disable_crashsite then
remote.call("freeplay", "set_disable_crashsite", true)
end
Expand Down
15 changes: 15 additions & 0 deletions SeaBlock/data-updates/startup.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'starting-items'

-- First stage: circuit board pipe pipe-to-ground iron-gear iron-stick copper-pipe
-- Electrolyser 5 20*4
-- Liquifier 5 2
Expand Down Expand Up @@ -314,3 +316,16 @@ data.raw.technology['bio-paper-1'].unit = {
bobmods.lib.tech.remove_recipe_unlock('bio-processing-brown', 'solid-alginic-acid')
bobmods.lib.tech.add_recipe_unlock('bio-paper-1', 'solid-alginic-acid')
bobmods.lib.tech.remove_prerequisite('bio-paper-2', 'bio-paper-1')

if data.data_crawler then
data.script_enabled = data.script_enabled or {}

for k,_ in pairs(sbtechs) do
table.insert(data.script_enabled, {type = 'technology', name = k})
end

seablock.Populate_Starting_Items(seablock.starting_items, data.raw.item)
for _,v in pairs(seablock.starting_items) do
table.insert(data.script_enabled, {type = 'item', name = v[1]})
end
end
37 changes: 37 additions & 0 deletions SeaBlock/starting-items.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
seablock = seablock or {}

function seablock.Populate_Starting_Items(dest, items)
dest.starting_items = {
{'stone', 65},
{'small-electric-pole', 50},
{'small-lamp', 12},
{'iron-plate', 1200},
{'basic-circuit-board', 200},
{'stone-pipe', 100},
{'stone-pipe-to-ground', 50},
{'stone-brick', 500},
{'pipe', 22},
{'copper-pipe', 5},
{'iron-gear-wheel', 20},
{'iron-stick', 96},
{'pipe-to-ground', 2}
}

-- Starting power production
if items['wind-turbine-2'] then
table.insert(dest.starting_items, {'wind-turbine-2', 120})
else
table.insert(dest.starting_items, {'solar-panel', 38})
table.insert(dest.starting_items, {'accumulator', 32})
end

-- Starting landfill
local landfill
setting = settings.startup['sb-default-landfill']
if setting and items[setting.value] then
landfill = setting.value
else
landfill = 'landfill'
end
table.insert(dest.starting_items, {landfill, 2000})
end

0 comments on commit f3eaa51

Please sign in to comment.