Skip to content

Instantly share code, notes, and snippets.

@Bilka2
Bilka2 / factorio_blueprint_string_edit.py
Created September 16, 2020 09:23
Decode a Factorio blueprint string, change some of it and reencode it
import json
import zlib
import base64
original_bp_string = '0eNp9j80OgjAQhN9lzq0RFNC+ijGGnw1uQhdCi5GQvrstXjx5m9mfb2c3NMNC08ziYTZwO4qDuW1w3Es9pJpfJ4IBe7JQkNomVztHthlYem3r9slCOkdQYOnoDZOFuwKJZ8/05e1mfchiG5rjwH+SwjS6uDxKShCB+nQoFNYoskOR7sQ0LvWmeeyW1vMr0rWNeiB9gslDSrBnNj8vKrxodjs2v2Tn6nytyio7lkUZwgd0Blhx'
bp_json = json.loads(zlib.decompress(base64.b64decode(original_bp_string[1:])).decode('utf8'))
# there is one entity in the blueprint, it's an assembler with a item request for 2 prod-3 modules and no recipe set
# for the fields of the blueprint json see https://wiki.factorio.com/Blueprint_string_format
bp_json['blueprint']['entities'][0]['items'] = {'copper-plate': 200} # overwrites existing item request
@Bilka2
Bilka2 / gist:128e465c0a9b16b949c6b710d63040dd
Last active March 19, 2020 18:53
Measure inserter cycles over multiple ticks blueprint string (Factorio)
0eNrtXeuO6zhyfpcG8idpTUSR1OVgJ8Ak2Vw2l01mNncsGrJNu5UjS15duqdn0A+Qt8iz5UlCyZcmJdHip5Z7R3sGCywwfezPIqtY9VUVq/Tj3SqtxaFIsuru0493yTrPyrtP//XjXZnssjht/la9HMTdp7ukEvu7+7ss3jf/FRdJ9bgXVbJ21vl+lWRxlRd3r/d3SbYR3999Iq/3oxgbsU42ohgG8F5/e38nsiqpEnF8ovY/Xh6yer8ShfyFC07zzFWcVSrQ/d0hL+V386z5eYnH7u9e7j45ofyFTVKI9fGf5F/lt6siTx9W4jF+SuRX5ee3SVqJwrART0lR1fIvl98/fsL5tnn6dV43O0lGNsKE8ctBDA/C+G4Qg87wHAzC+M0gBocwVmm8/jyIEzT6kZQPjRS3cVqK9kNZdpRs2WCT5v92hRCZqj/J5u5TFL7+9vW1eZKOUnmXBxCpRCqkeotMFLsXRx4QUWzjteirlhN8xY/axb/iHf0a+A06coj6+NSEPqy9b7AP8p83yWVDtklRVg/Wmy/i9WOz96VoYOy/903zpfwgivj4mHe/+IX8TF5Xhxr+9VeDWAux6QrVl59MinWdVO1/kkZBBqXP9Q9KSyN/xDMqi0cMysJgQbLfjyC/UaR4NpZyg1xdSn86QUjfQBLiPQmdN37gw8Q3bDuHt937KW/7H91821l32+91/R47ALQvtiG5+KhcyM9mzUJ69Lr0IlurF4JWLzKIOUDF7H7ZRi9EjF57Fod2PUR3/Qu3ecH1U0PdEfX37WxehIqF/2zzplA5XXrEbOWIh5k5Ghgk26gsJtovnNx1d/66oWsP4OC+g3F9cNr11xkjeVeJOB3iBkFEfeKFE2N6oqHRkBHPpd7E4N7TwCLXdUkUEG9imE/V0NoNaMBI6LGJ8T7THo0EIY8ipqBhkT/XZRCxgFDK3tB8CM1X0DzCqBdGKlgAgQXao3FOwshjoXtBCyG0UEPzKeEh87h/QYsgtEhD8+T/OA0VNOJCcN8MLvU
overall
- everything can either be drawn at position (to position/entity) or at entity (to position/entity)
- everything can have the color changed / be tinted
- everything can be visible to everyone or only to specifc players or forces
- what is drawn on top? "Best" would be to draw the new stuff on top of the old stuff, so if you draw thing1 and then thing2, thing2 is on top of thing1
things that can be drawn
- line, dashed line
@Bilka2
Bilka2 / worm-autoplace.lua
Last active May 6, 2019 10:10
Factorio version 0.16.51/0.17
-- data for 0.16.51, functionality in 0.17 explained in comment below
["big-worm-turret"] = {
autoplace = {
control = "enemy-base",
force = "enemy",
max_probability = 0.2,
order = "b[enemy]-b[worm]",
peaks = {
{
influence = 0,
@Bilka2
Bilka2 / control.lua
Last active January 30, 2023 04:29
Create a timelapse from a factorio replay save file
-- Just add this to the end of the control.lua file in the save file and then replay the file
-- This sequence is adjusted for https://www.speedrun.com/Factorio/run/mr87xlgy
script.on_nth_tick(300, function(event)
if event.tick < 90000 then
game.take_screenshot{
surface = game.surfaces[1],
position = {-88,-9},
resolution = {1920,1080},
zoom = 0.2,
accumulator
achievement
active-defense-equipment
ambient-sound
ammo
ammo-category
ammo-turret
arithmetic-combinator
armor
arrow
@Bilka2
Bilka2 / webhook.py
Last active October 12, 2024 18:57
Simple discord webhook with python
import requests # dependency
url = "<your url>" # webhook url, from here: https://i.imgur.com/f9XnAew.png
# for all params, see https://discordapp.com/developers/docs/resources/webhook#execute-webhook
data = {
"content" : "message content",
"username" : "custom username"
}
@Bilka2
Bilka2 / Data.raw 2.0.10
Last active October 25, 2024 14:59
Dump of Factorio's vanilla prototype data created with https://mods.factorio.com/mod/DataRawSerpent
This file has been truncated, but you can view the full file.
Script @__DataRawSerpent__/data-final-fixes.lua:1: {
accumulator = {
accumulator = {
chargable_graphics = {
charge_animation = {
layers = {
{
layers = {
{
filename = "__base__/graphics/entity/accumulator/accumulator.png",
@Bilka2
Bilka2 / gist:52697e925d34e6266c65b0e2b4768238
Last active August 15, 2024 16:14
factorio: 256:256 balancer (fractal)
0eNqkvd2ONc2NXnkv37GqkSTjt29lMBi0bcEQ0FYLkhqwYejep7qMUaWmd+03Y60jSZ+k/RSTmU8ygisZ//u3//Kv//77P/35D3/862///L9/+8N//bc//uW3f/6//vdvf/nDf//jv/zrf/yzv/6vP/3+t3/+7Q9//f3/+O13v/3xX/7Hf/yn3//PP/3593/5y8e///G//f7P//3P//b5rx//5ff/+tff/va73/7w+c/+52//HH/7v3/32+//+Nc//PUPv/8/v/n1H/7X//PHf/8f/+X3f/78H/ynX/vLn/71D3/96+d/97vf/vRvf/n8P/7bH//jL/j8sY9a1+9++1+f/yZy/lP/VPlvf/jz7//r//lf5N9+959+PP/Tj//1z//yx7/86d/+/Nf/84e+kJj7/5NYvxYoIrAOBBoRmD8ItBcCnQiMA4FBBPoPAuOFwCQC7SAHiwjUgcA+egZmHj0Dcf36eX2lEj8F8Lu/m8Ef//Tv//Gs/2fJQJJj/FLy3/79rz9pJtPsIsxikpcJsyHNvkWYnUl2EyZxjX7yUMc8euh6nT10xDN6nvz9myjEgUIy4+gXv9WSGUczt1oy42hNhMmMo7YJkxlHLREmM44qE+ZgminCnEgypwlzMc0hwtxMsokw6zoy6Twz6QpgoXli0sW8JUXtVcxbwtRexbwlRO1VzFvC1F7FvOUStVcxb7nUQ0dql+tkvVPMSi5h0u0iQZ2US424yXUdrKQbcpPcpmxoYIcj99EORzvx+NzzyONbZ9dMvCjbYJLC9NtkkmnuDFSC5BKm3zaTNO+2jlZBOYXp92BhmndbZ94yS4RZTNK82zqqVHJMESZzoLFMmMyChrCgzixoGAvqzIK6sKDOLKgbCxrMgnoYTeZBZvNnMAtSmz+DeZDZ/BnMgtTmz2AeZDZ/BrMgtfkzmAeZzZ/BLEht/gzmQWbzZzILSmNBk1lQCguazILCWNBkFhTCgiazoMtY0GQWdAkLmsyCLmNBk1mQ2dqYyIJiGwuam2m