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. | |
]] |
View start.sh
#!/bin/bash | |
if [ -f .factorio-lock ]; then | |
echo "Factorio Server is already running." | |
exit 1 | |
else | |
touch .factorio-lock | |
fi | |
screen -Dm -S factorio ./watchdog & echo $! > .factorio-lock |
View update.sh
#!/bin/bash | |
python update_factorio.py --apply-to factorio/bin/x64/factorio -x -D | |
chmod +x factorio/bin/x64/factorio |
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>(); | |
g.GetBlocksOfType(reactors); |
View TTT Role Distribution Helper.lua
function math.clamp(val, min, max) | |
local step = math.max(val, min) | |
return math.min(step, max) | |
end | |
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} | |
} |
View MessageQueue.java
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) { |
View HEX2Color.lua
-- Hex2Color Converter | |
-- Copyright (c) 2016 Mischa Behrend <https://github.com/siasur> | |
--[[ | |
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. |
View TsBotBootstrapper.java
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(); | |
config.setHost("127.0.0.1"); |
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 | |
end | |
_x = math.floor( _x / 2 ) | |
_y = _y * 2 | |
end | |
return result |