Skip to content

Instantly share code, notes, and snippets.

View awstanley's full-sized avatar

A.W. Stanley awstanley

  • Sydney, Australia
View GitHub Profile
--[[-------------------------------------------------------------------
-- Platform detecting Lua initialisation code
-- Copyright (c) 2014 A.W. Stanley <[email protected]>
-- Released under the new BSD License
-------------------------------------------------------------------]]--
local lua_dir = "lua"
local lua_init = "lua/server.lua"
-- Pull the first directory
/*
* Copyright (c) 2006-2014 A.W. Stanley
* Released into the public domain as of
* http://awsta.nley.org/post/88514503005/c-steamid-conversion
*
* An assumption is made about "normal" string inputs.
* Note: 76561197960265728 = 0000 0001 0001 0000 0000 0000 0000 0001
* Universe: (0000 0001)
* Account Type: (0001)
* Instance: (0000 0000 0000 0001)
@awstanley
awstanley / blink1.cpp
Created June 13, 2014 06:32
Clean room hidapi based blink1 miniature library implementation. I didn't even realise hidapi was used in the official tool until someone mentioned it; my general disdain for dealing with the compile issues usually boiled down to dynamic library imports (dlopen, etc.) instead of trying to fix it.
/*
Copyright (c) 2014, A.W. Stanley
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
double delta = 0.0f;
double time_now = glfwGetTime();
double time_last = glfwGetTime();
while(my_running_boolean)
{
time_now = glfwGetTime();
delta = (time_now - time_last);
time_last = time_now;
#include <stdint.h> // uint8_t
class Scene
{
public:
virtual void Run() {}
Scene() {}
~Scene() {}
};
@awstanley
awstanley / SpeedTimeCoord.cs
Created January 4, 2015 03:54
Updated Space Engineers script for listing Speed|Time|Position.
void Main()
{
// Get blocks
var blocks = new List<IMyTerminalBlock>();
// Get the antenna
GridTerminalSystem.GetBlocksOfType<IMyRadioAntenna>(blocks);
if(blocks.Count > 0)
{
@awstanley
awstanley / DockShutdown.cs
Created January 4, 2015 23:56
Current working draft of autonomous docking code shutdown sequence. Untested.
// OnOff code seems to be global
ITerminalAction GetOnOffAction(IMyTerminalBlock block, bool enable)
{
ITerminalAction Action;
if (enable)
{
Action = block.GetActionWithName("Toggle block On");
}
else
{
@awstanley
awstanley / DockShutdown.cs
Created January 4, 2015 23:57
This is some old/test docking code which never got tested. There are potential limitations here, but the aim behind the system was to set flight mode on/off, so that the system could then trigger a "dock" command prior to connecting. The undock sequence would happen AFTER it had been released (connector goes off). Newer code is here: https://gis…
// OnOff code seems to be global...
ITerminalAction GetOnOffAction(IMyTerminalBlock block, bool enable)
{
ITerminalAction Action;
if (enable)
{
Action = block.GetActionWithName("Toggle block On");
}
else
{
@awstanley
awstanley / RefuseRefine.cs
Created January 5, 2015 08:32
Space Engineers "reactor sorting" programming block.
// Name Syntax: "<Friendly List Alias><Cfg_Separator><Resource(s)>"
// Valid resources (without quotation marks):
// "Energetic", "Cobalt", "Gold", "Iron",
// "Nickel", "Platinum", "Silver", "Uranium"
//
// Divide them using the 'Cfg_Separator_Internal' value. e.g.
// [1] Reactor§Uranium
// [2] TwigglyDeFooBarDeBopDeBoop Hrm? Yes, This is quite something§Nickel,Cobalt,Gold
// USE:
@awstanley
awstanley / Name_DetailedInfo.cs
Created January 6, 2015 06:09
Space Engineers script to get information from the block (CSV, but you need to parse it out)
void Main()
{
for (int block = 0; block < GridTerminalSystem.Blocks.Count; block++)
{
if (GridTerminalSystem.Blocks[block] is IMyTerminalBlock)
{
IMyTerminalBlock Block = GridTerminalSystem.Blocks[block];
StringBuilder Str = new StringBuilder(); Str.Append(Block.BlockDefinition.ToString());
Str.Append("[" + Block.DetailedInfo + "] ");
Block.SetCustomName(Str);