Skip to content

Instantly share code, notes, and snippets.

View awstanley's full-sized avatar

A.W. Stanley awstanley

  • Sydney, Australia
View GitHub Profile
@awstanley
awstanley / dom4_pretender.cpp
Last active March 30, 2016 11:30
Dominions 4 Pretender Parser (proof of concept)
#include <stdint.h>
#include <fstream>
#include <string>
#include <vector>
struct FileHeader
{
/* 0 */char header[6];
/* 6 */uint32_t serial;
@awstanley
awstanley / CMakeLists.txt
Created March 24, 2016 21:42
Tilemap example using the A5 builder ( https://github.com/awstanley/a5builder )
project("tilemapA5")
cmake_minimum_required(VERSION 3.4)
set(EXE_NAME "tilemapA5")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include("D:\\a5\\builder\\AllegroDependencies.cmake")
add_executable(${EXE_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
LINK_ALLEGRO(${EXE_NAME})
install(TARGETS ${EXE_NAME} RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/build")
@awstanley
awstanley / StrippedBackExample.cs
Last active August 29, 2015 14:13
Space Engineers related code. Stripped back example of the lag causing code. (Updated to include DateTime code, typed manually into it from newer code; it should work, and I tested the error-free nature of it briefly in creative on a random block).
//---------------------------------------------------------------------
// Configuration variables. Define this once, use it everywhere.
// (Save yourself the headache of rewriting it over and over again...)
//
// Two key points here:
// (1) All points should be out of standard usage (e.g. ☼ § « »);
// (2) Anything which MAY need to be typed (ever), should be available
// easily via ASCII or CharMap (for user access). Anything else
// (list delimiting) should be done sanely but copy+paste should
// be more than enough.
@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);
@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 / 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 / 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 / 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)
{
#include <stdint.h> // uint8_t
class Scene
{
public:
virtual void Run() {}
Scene() {}
~Scene() {}
};
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;