Skip to content

Instantly share code, notes, and snippets.

siasur / string_splice.lua
Created May 29, 2020
Lua Splice strings
View string_splice.lua
-- Copyright (c) 2020 Siasur
This lua function allows you to splice a string (value) into another string (base) at a given location (position) without changing its length.
I created this function for a now scrapped project but as I spent a long time figuring out how to do it I decided to make it a public gist.
If you need this functionality in your script you are free to use this code as it is.
siasur /
Last active Aug 22, 2019
Factorio Server stuff
if [ -f .factorio-lock ]; then
echo "Factorio Server is already running."
exit 1
touch .factorio-lock
screen -Dm -S factorio ./watchdog & echo $! > .factorio-lock
siasur /
Created Apr 18, 2019
Update script for Factorio (I got this from somewhere online)
python --apply-to factorio/bin/x64/factorio -x -D
chmod +x factorio/bin/x64/factorio
siasur / Scaffolding.cs
Created Apr 16, 2019
Grundgerüst für ein SE Script...
View Scaffolding.cs
public void Main(string argument)
var groups = new List<IMyBlockGroup>();
GridTerminalSystem.GetBlockGroups(groups, selector => selector.Name.EndsWith("#Battery"));
foreach (var g in groups)
List<IMyReactor> reactors = new List<IMyReactor>();
View TTT Role Distribution Helper.lua
function math.clamp(val, min, max)
local step = math.max(val, min)
return math.min(step, max)
local roles = {
{ name = "Traitor", pct = 0.25, max = 6, minply = 0},
{ name = "Detective", pct = 0.17, max = 4, minply = 8},
{ name = "Jackal", pct = 1, max = 1, minply = 6}
public class MessageQueue<T> {
private static final int MAX_SIZE = 255;
private T[] messages;
private int lastReadIndex;
private int lastInsertIndex;
private int adjustIndex(int index) {
if (index >= MAX_SIZE) {
siasur / HEX2Color.lua
Created Apr 27, 2016
Hex2Color Converter - Convert (extended) hexadecimal colors to its RGBA counterpart
View HEX2Color.lua
-- Hex2Color Converter
-- Copyright (c) 2016 Mischa Behrend <>
Dieses kleine Codesnippet konvertiert (erweiterte) Hexadezimalfarben in ihre entsprechenden RGBA Werte.
Erweitert bedeutet, dass die Hexadezimalwerte (vom Standard abweichend) um eine weitere Stelle für den
Alphakanal ergänzt werden dürfen. Die führende Raute kann bei bedarf weggelassen werden.
This little codesnippet will convert (extended) hexadecimal colors to its RGBA counterpart. Extended
means that you can (different to the default) append a fourth value for the alpha channel.
public class TsBotBootstrapper {
public static final TS3Config config;
public static TS3Query query;
public static TS3Api api;
public static TS3Listener listener;
public static void main(String[] args) {
config = new Ts3Config();
siasur / Russische Bauernmultiplikation.lua
Created Nov 5, 2015
Die Russische Bauernmultiplikation (auch Ägyptisches Multiplizieren, Abessinische Bauernregel oder Verdopplungs-Halbierungs-Methode genannt) ist ein einfaches Verfahren zur Multiplikation zweier natürlicher Zahlen.
View Russische Bauernmultiplikation.lua
local function Mul( --[[number]] _x, --[[number]] _y )
local result = 0
while ( _x >= 1 ) do
if ( _x%2 ~= 0 ) then
result = result + _y
_x = math.floor( _x / 2 )
_y = _y * 2
return result