Skip to content

Instantly share code, notes, and snippets.

@ChuckSavage
ChuckSavage / pirate_raiders.cs
Created Dec 6, 2018
Space Engineers Pirate Raiders Script Modification
View pirate_raiders.cs
// Script written by Rich_27, Designed by Splitsie
// Modified by Dune to check for no antenna, and to echo antenna name & radius
// CHANGE ME: Name of the antenna responsible for spawning drones in the pirate base
const string ANTENNA_NAME = "Antenna name";
// CHANGE ME: The time interval between antenna increments, in seconds
const float TIME_INTERVAL = 120.0f;
// CHANGE ME: The minimum and maximum antenna distances
@ChuckSavage
ChuckSavage / StoneDusterRunIfOverValue.cs
Created Nov 10, 2018
Space Engineers - Stone Duster mod, script to control stone amounts
View StoneDusterRunIfOverValue.cs
// Written by steam handle "Dune__" aka Chuck Savage
// - Gist link: https://gist.github.com/ChuckSavage/fd5777417b802bf59a07a60688f84a94
// Feel free to use and modify. It'd be great if you list any
// changes here on this gist page so I can keep this up to date if they are important changes.
// Todo: handle multiple stone dusters. I'm not sure how to go about finding the type "Stone Duster" that
// the mod has listed for itself.
// Some code borrowed from the Space Engineers Visual Script Builder - http://dco.pe/vsb/
// Set name of Stone Duster to this name, or change this name to your stone duster's name
@ChuckSavage
ChuckSavage / battery_charge_and_drill_load_level.cs
Created Nov 3, 2018
Space Engineers Game - Battery Charge and Drill (miner) load level and balancer
View battery_charge_and_drill_load_level.cs
// dco.pe/vsb
const float MinValueToActivateRedLights = 5000f;
const float VolumeOfDrills = 33750f; // small ship drill (large is 234375f)
public Program()
{
Runtime.UpdateFrequency = UpdateFrequency.Update100;
}
@ChuckSavage
ChuckSavage / AppendImageExtension.cs
Created Aug 29, 2017
C# Is file an image and get its type
View AppendImageExtension.cs
// Includes a mini-program for checking and fixing files that have no extension
// Only checks for the most common types
// If you create a better version, please upload it here.
using System;
using System.Collections.Generic;
using System.IO;
namespace AppendJPG
{
@ChuckSavage
ChuckSavage / DisplaySize.cs
Last active Oct 29, 2016
NGUI DisplaySize
View DisplaySize.cs
/*
* Modified this guys code - http://www.zedia.net/2013/ngui-unity3d-getting-screen-size/comment-page-1/
*/
public static class DisplaySize
{
public static float ScreenHeight(this Transform t)
{
UIRoot root = t.root.GetComponent<UIRoot>() ?? NGUITools.FindInParents<UIRoot>(t);
float ratio = (float)root.activeHeight / Screen.height;
return Mathf.Ceil(Screen.height * ratio);
@ChuckSavage
ChuckSavage / MapMagic_AutoSave
Last active Oct 14, 2016
MapMagic v1.5 Setting up Auto-Save of Nodes data. Modify MapMagic at your own risk. There is no guarantee that the node file generated by this is useful. Be sure to test it for your own assurance.
View MapMagic_AutoSave
Edit MapMagicWindow.cs
Make the following method static, it doesn't reference internal class data, so it is ok.
private static Generator[] SmartCopyGenerators(Generator gen)
Then refactor the SaveGenerator method, extracting the file saving to a public static ExportToFile method
void SaveGenerator(Generator gen, Vector2 pos)
{
@ChuckSavage
ChuckSavage / ObservableValue
Last active Aug 29, 2015
Observe the changes in a value
View ObservableValue
public class ObservableValue<T> : INotifyPropertyChanged
{
public class MyArgs : PropertyChangedEventArgs
{
public MyArgs(string propertyName, T old, T @new)
: base(propertyName)
{
Old = old;
New = @new;
}
@ChuckSavage
ChuckSavage / ZipMultiple.cs
Last active Dec 18, 2015
It seems an oversight on the .Net team to not enable multiple arrays to be passed to Enumerable.Zip. So I've created up to seven overloaded Zip extensions that borrow from the code by Eric Lippert here: http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx
View ZipMultiple.cs
using System;
using System.Collections.Generic;
namespace ZipMany
{
/// <summary>
/// Zip multiple arrays (more than 2 since there is a built in Zip for 2 with .Net 4.0)
/// </summary>
public static class ZipMultiple
{
@ChuckSavage
ChuckSavage / XmlLinqConversionExtensions.cs
Created Feb 20, 2013
Convert To/From XmlDocument and XDocument/XElements
View XmlLinqConversionExtensions.cs
using System.Xml;
using System.Xml.Linq;
namespace XmlLib
{
/// <summary>
/// Provides extension methods for simple conversion between System.Xml and System.Xml.Linq classes.
/// </summary>
/// <remarks>From: http://brianary.blogspot.com/2010/02/converting-between-xdocument-and.html</remarks>
public static class XmlLinqConversionExtensions
@ChuckSavage
ChuckSavage / Paths.cs
Created Feb 10, 2013
Paths utility file for adding params to a string Combine.
View Paths.cs
public class Paths
{
/// <summary>
/// Apply Path.Combine(on path and list)
/// </summary>
/// <param name="path"></param>
/// <param name="list"></param>
/// <returns></returns>
public static string Combine(string path, params string[] list)
{
You can’t perform that action at this time.