Just deleted about 400 bot accounts and a bunch of spam. To mitigate this in the future, we've enabled reCaptcha on signup. Let me know if someone got caught in the crossfire.

Commit 3d7eb411 authored by Rob Nelson's avatar Rob Nelson
Browse files

Added angelbob-bio, a shitty N3X15 mod.

parent af246fad
import copy
import os
import re
import sys
import yaml
from buildtools import log, os_utils
from buildtools.config import delimset
from buildtools.indentation import IndentWriter
from PIL import Image
REG_COLOR = re.compile(r'#?([a-f0-9]{6})')
DIVIDER = '-- ' + ('-' * 30)
ANGELSBIOPROCESSING_PATH = ''
alphas = 'abcdefghijklmnopqrstuvwxyz'
VERSION='0.15.3'
def decode_color(hexcolor):
m = REG_COLOR.match(hexcolor.lower())
r, g, b = (0, 0, 0)
if m is not None:
rgb = m.group(1)
r = int(rgb[0:2], base=16)
g = int(rgb[2:4], base=16)
b = int(rgb[4:6], base=16)
return r, g, b
def test_decode(inp, expected):
out = decode_color(inp)
if out != expected:
log.error('Test %r -> %r failed: Got %r', inp, expected, out)
test_decode('ff0000', (255, 0, 0))
test_decode('00ff00', (0, 255, 0))
test_decode('0000ff', (0, 0, 255))
def lua_color(rgb):
return '{{r = {R:.2f}, g = {G:.2f}, b = {B:.2f}}}'.format(R=rgb[0] / 255, G=rgb[1] / 255, B=rgb[2] / 255)
def duplicateStructure(struct, variables={}):
out = copy.deepcopy(struct)
for k, v in variables.items():
delimset(out, k, v)
return out
def asLuaTable(inp, w, key=None, comma=False):
if key is not None:
key += ' = '
else:
key = ''
suffix = ''
if comma:
suffix += ','
if isinstance(inp, dict):
with w.writeline(key + '{'):
size = len(inp)
for k, v in inp.items():
size -= 1
asLuaTable(v, w, key=k, comma=size > 0)
w.writeline('}' + suffix)
elif isinstance(inp, list):
with w.writeline(key + '{'):
size = len(inp)
for entry in inp:
size -= 1
asLuaTable(entry, w, comma=size > 0)
w.writeline('}' + suffix)
elif isinstance(inp, str):
w.writeline('{}"{}"{}'.format(key, inp, suffix))
else:
w.writeline('{}{}{}'.format(key, inp, suffix))
def make_icon(recipe, artifact_config, large):
global ANGELSBIOPROCESSING_PATH
recipe_name = recipe['name']
output = recipe_name + '.png'
base = 'alien-goo.png'
dash = '-' if artifact_config['type'] != 'pink' else ''
color = '' if artifact_config['type'] == 'pink' else artifact_config['type']
overlay = '{}alien-artifact{}{}.png'.format('' if large else 'small-', dash, color)
with log.info('Writing %s...', output):
os_utils.ensureDirExists('graphics/icons')
baseicon = Image.open(os.path.join(ANGELSBIOPROCESSING_PATH, 'graphics', 'icons', base))
overlay = Image.open(os.path.join(ANGELSBIOPROCESSING_PATH, 'graphics', 'icons', overlay))
overlay.thumbnail((16, 16), Image.BICUBIC)
baseicon.paste(overlay, (0, 0), overlay)
baseicon.save(os.path.join('graphics', 'icons', output))
recipe['icon'] = '__angelbob-bio__/graphics/icons/' + output
def main():
global ANGELSBIOPROCESSING_PATH
config = {}
with open('config.yml', 'r') as f:
config = yaml.load(f)
ANGELSBIOPROCESSING_PATH = config.get('paths').get('angelsbioprocessing')
recipe_structure = config.get('recipes').get('output')
recipes = []
tech_append_recipes = {'bio-processing-alien': []}
amount_out = config.get('balance', {}).get('small-out', 1)
idx = 0
for typeid, data in config.get('artifacts').get('small').items():
recipeid = 'alien-goo-artifact-sm' + data['type']
recipe = duplicateStructure(recipe_structure, {'name': recipeid})
recipe['ingredients'][0]['name'] = typeid
recipe['results'][0]['amount'] = amount_out
recipe['order'] = '{} [{}]'.format(alphas[idx], recipeid)
recipe['subgroup'] = 'angelbob-bio-small'
recipes.append(recipe)
make_icon(recipe, data, False)
tech_append_recipes['bio-processing-alien'].append(recipeid)
idx += 1
smallpink_order='{} [{}]'.format(alphas[idx], recipeid)
amount_out = config.get('balance', {}).get('large-out', 5)
idx = 0
for typeid, data in config.get('artifacts').get('large').items():
recipeid = 'alien-goo-artifact-lg' + data['type']
recipe = duplicateStructure(recipe_structure, {'name': recipeid})
recipe['ingredients'][0]['name'] = typeid
recipe['results'][0]['amount'] = amount_out
recipe['order'] = '{} [{}]'.format(alphas[idx], recipeid)
recipe['subgroup'] = 'angelbob-bio-large'
recipes.append(recipe)
make_icon(recipe, data, True)
tech_append_recipes['bio-processing-alien'].append(recipeid)
idx += 1
idx = 0
# Make icon for standard pink small artifact recipe
smallpink_icon=''
with log.info('Generating icon for alien-goo-artifact recipe...'):
recipe={'name':'alien-goo-artifact'}
make_icon(recipe,{'type':'pink'},False)
smallpink_icon=recipe['icon']
#Fixes to recipes
with log.info('Generating recipe for goo -> dish...'):
recipe = config.get('recipes').get('goo2dish')
recipes.append(recipe)
tech_append_recipes['bio-processing-alien'].append(recipe['name'])
idx = 0
newgroups = []
grouporder = {}
for parentgroup, subgroups in config.get('ordering').get('groups').items():
grouporder[parentgroup] = subgroups
for parentgroup, subgroups in config.get('groups').get('new').items():
for newgroup in subgroups:
# log.info(newgroup)
orderidx = grouporder[parentgroup].index(newgroup)
newgroups += [{'type': 'item-subgroup', 'name': newgroup, 'group': parentgroup, 'order': alphas[orderidx]}]
log.info('Writing prototypes/recipes.lua...')
with open('prototypes/recipes.lua', 'w') as f:
w = IndentWriter(f)
w.writeline('-- Generated by BUILD.py.')
with w.writeline('data:extend('):
asLuaTable(recipes, w)
w.writeline(")")
log.info('Writing prototypes/categories.lua...')
with open('prototypes/categories.lua', 'w') as f:
w = IndentWriter(f)
w.writeline('-- Generated by BUILD.py.')
with w.writeline('data:extend('):
asLuaTable(newgroups, w)
w.writeline(")")
log.info('Writing data-final-fixes.lua...')
with open('data-final-fixes.lua', 'w') as f:
w = IndentWriter(f)
w.writeline('-- Generated by BUILD.py.')
for techname, recipes in tech_append_recipes.items():
for recipename in recipes:
#w.writeline('table.insert(data.raw["technology"]["{TECHNAME}"].effects, {{type = "unlock-recipe", recipe = "{RECIPENAME}"}})'.format(TECHNAME=techname, RECIPENAME=recipename))
w.writeline('table.insert(data.raw.technology["{}"].effects, {{type = "unlock-recipe", recipe = "{}"}})'.format(techname, recipename))
w.writeline('-- Bring original Angel alien goo recipe into order.')
w.writeline('data.raw.recipe["alien-goo-artifact"].order="{}"'.format(smallpink_order))
w.writeline('data.raw.recipe["alien-goo-artifact"].subgroup="angelbob-bio-small"')
w.writeline('data.raw.recipe["alien-goo-artifact"].icon="{}"'.format(smallpink_icon))
# with open('data-updates.lua', 'w') as f:
# w = IndentWriter(f)
# w.writeline('-- Generated by BUILD.py.')
w.writeline(DIVIDER)
w.writeline('-- GROUPS')
w.writeline(DIVIDER)
for parentgroup, subgroups in grouporder.items():
idx = 0
w.writeline('-- ' + parentgroup)
for groupname in subgroups:
w.writeline('data.raw["item-subgroup"]["{GROUPNAME}"].order = "{ORDER}"'.format(GROUPNAME=groupname, ORDER=alphas[idx]))
idx += 1
log.info('Writing locale/en/angelbob-bio.cfg...')
with open('locale/en/angelbob-bio.cfg', 'w') as f:
f.write('[recipe-name]\n')
for techname, recipes in tech_append_recipes.items():
for recipename in recipes:
f.write('{}={}\n'.format(recipename, 'Alien Goo'))
log.info('Writing migrations/%s.lua...', VERSION)
with open('migrations/{}.lua'.format(VERSION), 'w') as f:
w = IndentWriter(f)
w.writeline(DIVIDER)
w.writeline('-- GENERIC')
w.writeline(DIVIDER)
w.writeline('print("Applying {}...")'.format(VERSION))
w.writeline('game.reload_script()')
with w.writeline('for index, force in pairs(game.forces) do'):
w.writeline('force.reset_recipes()')
w.writeline('force.reset_technologies()')
w.writeline('end')
w.writeline(DIVIDER)
w.writeline('-- RESEARCH FIXES')
w.writeline(DIVIDER)
with w.writeline('for i, force in pairs (game.forces) do'):
for techname, recipes in tech_append_recipes.items():
with w.writeline('if force.technologies["{TECHNAME}"].researched == true then'.format(TECHNAME=techname)):
w.writeline('print("{} is detected as RESEARCHED! Enabling {} recipes...")'.format(techname, len(recipes)))
for recipename in recipes:
with w.writeline('if not force.recipes["{RECIPENAME}"].enabled then'.format(RECIPENAME=recipename)):
w.writeline('force.recipes["{RECIPENAME}"].enabled = true'.format(RECIPENAME=recipename))
w.writeline('print(" - Enabled {}!")'.format(recipename))
w.writeline('end')
with w.writeline('else'):
w.writeline('print(force.name.." does not have {} researched!")'.format(techname))
w.writeline('end')
w.writeline('end')
if __name__ == '__main__':
main()
paths:
angelsbioprocessing: F:\Projects\Factorio-ModManager\modpool\angelsbioprocessing\0.4.0_x\angelsbioprocessing_0.4.0
artifacts:
small:
small-alien-artifact-red:
type: red
small-alien-artifact-orange:
type: orange
small-alien-artifact-yellow:
type: yellow
small-alien-artifact-green:
type: green
small-alien-artifact-blue:
type: blue
small-alien-artifact-purple:
type: purple
#small-alien-artifact:
# type: 'pink'
large:
alien-artifact-red:
type: red
alien-artifact-orange:
type: orange
alien-artifact-yellow:
type: yellow
alien-artifact-green:
type: green
alien-artifact-blue:
type: blue
alien-artifact-purple:
type: purple
alien-artifact:
type: 'pink'
groups:
new:
bio-processing:
- angelbob-bio-small
- angelbob-bio-large
ordering:
groups:
bio-processing:
- bio-processing-green
- bio-processing-brown
- bio-processing-blue
- bio-processing-red
- bio-processing-alien-intermediate
- bio-processing-paste
- bio-processing-alien-pre
- bio-processing-alien-small
- bio-processing-alien-big
- angelbob-bio-small
- angelbob-bio-large
- bio-processing
- bio-processing-buildings
balance:
large-out: 25
small-out: 1
recipes:
output:
type: "recipe"
name: "alien-goo-artifact"
category: "chemistry"
subgroup: "bio-processing-alien-comprehensive"
enabled: "false"
energy_required: 3,
ingredients:
- type: item
name: ''
amount: 1
results:
- type: fluid
name: alien-goo
amount: 1
icon: "__angelsbioprocessing__/graphics/icons/alien-goo.png"
order: "c [alien-goo-artifact-{{TYPE}}]"
goo2dish:
type: "recipe"
name: "alien-pre-artifact-goo"
category: "chemistry"
subgroup: "bio-processing-alien-intermediate"
enabled: "false"
energy_required: 2
ingredients:
- type: "item"
name: "substrate-dish"
amount: 3
- type: "fluid"
name: "alien-goo"
amount: 5
results:
- type: "item"
name: "alien-pre-artifact"
amount: 3
icon: "__angelsbioprocessing__/graphics/icons/alien-pre-artifact.png"
order: "h [alien-pre-artifact-goo]"
-- Generated by BUILD.py.
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-smred"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-smorange"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-smyellow"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-smgreen"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-smblue"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-smpurple"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-lgred"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-lgorange"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-lgyellow"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-lggreen"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-lgblue"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-lgpurple"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-goo-artifact-lgpink"})
table.insert(data.raw.technology["bio-processing-alien"].effects, {type = "unlock-recipe", recipe = "alien-pre-artifact-goo"})
-- Bring original Angel alien goo recipe into order.
data.raw.recipe["alien-goo-artifact"].order="g [alien-goo-artifact-smpurple]"
data.raw.recipe["alien-goo-artifact"].subgroup="angelbob-bio-small"
data.raw.recipe["alien-goo-artifact"].icon="__angelbob-bio__/graphics/icons/alien-goo-artifact.png"
-- ------------------------------
-- GROUPS
-- ------------------------------
-- bio-processing
data.raw["item-subgroup"]["bio-processing-green"].order = "a"
data.raw["item-subgroup"]["bio-processing-brown"].order = "b"
data.raw["item-subgroup"]["bio-processing-blue"].order = "c"
data.raw["item-subgroup"]["bio-processing-red"].order = "d"
data.raw["item-subgroup"]["bio-processing-alien-intermediate"].order = "e"
data.raw["item-subgroup"]["bio-processing-paste"].order = "f"
data.raw["item-subgroup"]["bio-processing-alien-pre"].order = "g"
data.raw["item-subgroup"]["bio-processing-alien-small"].order = "h"
data.raw["item-subgroup"]["bio-processing-alien-big"].order = "i"
data.raw["item-subgroup"]["angelbob-bio-small"].order = "j"
data.raw["item-subgroup"]["angelbob-bio-large"].order = "k"
data.raw["item-subgroup"]["bio-processing"].order = "l"
data.raw["item-subgroup"]["bio-processing-buildings"].order = "m"
-- Generated by BUILD.py.
-- ------------------------------
-- GROUPS
-- ------------------------------
-- bio-processing
data.raw["item-subgroup"]["bio-processing-green"].order = "a"
data.raw["item-subgroup"]["bio-processing-brown"].order = "b"
data.raw["item-subgroup"]["bio-processing-blue"].order = "c"
data.raw["item-subgroup"]["bio-processing-red"].order = "d"
data.raw["item-subgroup"]["bio-processing-alien-intermediate"].order = "e"
data.raw["item-subgroup"]["bio-processing-paste"].order = "f"
data.raw["item-subgroup"]["bio-processing-alien-pre"].order = "g"
data.raw["item-subgroup"]["bio-processing-alien-small"].order = "h"
data.raw["item-subgroup"]["bio-processing-alien-big"].order = "i"
data.raw["item-subgroup"]["angelbob-bio-small"].order = "j"
data.raw["item-subgroup"]["angelbob-bio-large"].order = "k"
data.raw["item-subgroup"]["bio-processing"].order = "l"
data.raw["item-subgroup"]["bio-processing-buildings"].order = "m"
require("prototypes.recipes")
require("prototypes.categories")
{
"name": "angelbob-bio",
"version": "0.15.3",
"factorio_version": "0.15",
"title": "Angel Bioprocessing - Alien Goo for Bob Artifacts",
"author": "N3X15",
"description": "Angel's bioprocessing now has recipes for making Alien Goo from Bob's artifacts.",
"dependencies": [
"angelsbioprocessing >= 0.4.0"
]
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment