Skip to content

Instantly share code, notes, and snippets.

View slippycheeze's full-sized avatar

Daniel Pittman slippycheeze

View GitHub Profile
@slippycheeze
slippycheeze / EDDI-message-received.cottle
Last active April 11, 2023 10:17
EDDI message received script update
{_ is this a duplicate of the previous value? _}
{set duplicate to [
"source": event.source = state.sc_last_message_source,
"from": event.from = state.sc_last_message_from,
"message": event.message = state.sc_last_message_message
]}
{SetState('sc_last_message_source', event.source)}
{SetState('sc_last_message_from', event.from)}
{SetState('sc_last_message_message', event.message)}
// ==UserScript==
// @name Elite Dangerous: old forum URL redirector - frontier.co.uk
// @namespace rimspace.net
// @match *://forums.frontier.co.uk/showthread.php/*
// @grant none
// @run-at document-start
// @version 1.0
// @author Daniel Pittman <daniel@rimspace.net>
// @description when you land on an old forum URL, instead redirect to the "modern" equivalent.
// does not try and rewrite the URL before you hit the 404 page, though.
public class PrintUnlockableTechTrees: cmk.NMS.Script.QueryClass {
protected override void Execute() {
var Unlockable = Game.ExtractMbin<GcUnlockableTrees>("METADATA/REALITY/TABLES/UNLOCKABLEITEMTREES.MBIN");
foreach (var tree in Enum.GetValues<UnlockableItemTreeEnum>()) {
Log.AddHeading(Enum.GetName<UnlockableItemTreeEnum>(tree));
PrintTree(Unlockable.Trees[(int)tree]);
}
}
string Translate(string id) => Game.FindLanguageData(id)?.Text ?? id;
@slippycheeze
slippycheeze / Freighter-containerh-sceneref.cs
Last active December 4, 2022 19:44
No Mans Sky Freighter HullA ContainerH bugfix - now the venator freighter won't replace an entire ship segment with a broken cargo bubble!
public class Freighter_Containerh_Sceneref: SCModClass {
protected override void Execute() {
Log.AddInformation("Trying to fix the freighter bug where destroying a cargo container changes the entire section...");
var scene = ExtractMbin<TkSceneNodeData>("MODELS/COMMON/SPACECRAFT/INDUSTRIAL/CARGO/CARGOLARGEA.SCENE.MBIN");
// 1. find the bit where the cargo container children are at; a LOCATOR above their MESH data, in this case.
var container = scene
.Children
.Flatten(node => node.Children)
.Where(node => {
protected static void OnAfterExecute(NMS.Script.ModFiles modfiles, CancellationToken cancel) {
// gather all the warnings and above from the log
var alerts = modfiles.ExecuteLog
.Where(item => item.Type == LogItemType.Warning || item.Type == LogItemType.Failure)
.ToList();
if (alerts.Any()) {
int warnings = alerts.Where(item => item.Type == LogItemType.Warning).Count();
int errors = alerts.Where(item => item.Type == LogItemType.Failure).Count();
var heading = new StringBuilder("—————< ");
if (warnings > 0) heading.AppendFormat("{0} WARNINGS", warnings);
// WTF, why there no kitchen?
[HarmonyPatch(typeof(RoomRoleWorker_Kitchen), "GetScore")]
internal static class RoomRoleWorker_Kitchen__HandleDesignationCategoryChanges {
public static IEnumerable<CodeInstruction> Transpiler(
IEnumerable<CodeInstruction> code,
ILGenerator generator,
MethodBase original
) {
string name = original.ShortDescription();
try {
<?xml version="1.0" encoding="utf-8"?>
<Patch>
<Operation Class="XmlExtensions.Conditional">
<xpath>Defs/ThingDef[defName="VFEA_AncientChemfuelPoweredGenerator"]</xpath>
<caseTrue>
<Operation Class="XmlExtensions.PatchOperationSafeAdd">
<xpath>Defs/ThingDef[defName="VFEA_AncientChemfuelPoweredGenerator"]/comps/li/fuelFilter/thingDefs</xpath>
<compare>Both</compare>
<value>
<li MayRequire="Scruffy.Content.ONIAnimals">OxR_Coal</li>
<?xml version="1.0" encoding="utf-8"?>
<Patch>
<Operation Class="XmlExtensions.PatchOperationSafeAddOrReplace" MayRequire="Kompadt.Warhammer.Dryad">
<xpath>Defs/MeditationFocusDef[defName="Natural"]</xpath>
<compare>Both</compare>
<value>
<requiredBackstoriesAny>
<li>
<categoryName>KTDryadGood</categoryName>
<slot>Childhood</slot>
// This is just an excerpt, of course...
namespace CrashLanding {
public class Ticker_MTcounter : Building {
public void DoSpawn(int tickAmt) {
Predicate<IntVec3> validator = (Predicate<IntVec3>) (x => {
foreach (IntVec3 c in GenAdj.OccupiedRect(x, Rot4.North, new IntVec2(3, 3))) {
if (!c.InBounds(this.Map) || c.Fogged(this.Map) || !c.Standable(this.Map) || c.Roofed(this.Map) && c.GetRoof(this.Map).isThickRoof)
return false;
foreach (Thing thing in c.GetThingList(this.Map)) {
if (thing.def.preventSkyfallersLandingOn)
@slippycheeze
slippycheeze / iterm2-recv-zmodem.sh
Created June 2, 2020 17:04 — forked from dalei2019/iterm2-recv-zmodem.sh
iterm2 recv zmodem clone from matthew@mastracci.com
#!/bin/bash
# Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain
osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=$(osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")")
else