Skip to content

Instantly share code, notes, and snippets.

// An example of how to bind a C++ class in four scripting languages: lua, squirrel, mruby, and angelscript.
// Written by James S Urquhart ( http://www.cuppadev.co.uk/ ). Feel free to experiment!
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
// Lua includes
extern "C"
{
@jamesu
jamesu / gist:8182306
Created December 30, 2013 13:51
Convert Notational Velocity notes into tiddywiki tiddlers suitable for inserting into a TiddlyWiki file
note_html = []
Dir["./notes/candidates/*.txt"].each do |file|
ftime = File.mtime(file)
name = file.split("/")[-1]
puts "FILE #{name} CREATED #{ftime}"
File.open(file) do |f|
timestamp = ftime.strftime("%Y%m%d%H%M")
note_html << "<div changecount=\"1\" created=\"#{timestamp}\" modified=\"#{timestamp}\" modifier=\"JamesU\" tags=\"notational\" title=\"#{name}\"><pre>#{f.read}</pre></div>"
end
@jamesu
jamesu / FTFont.cpp
Created October 9, 2013 16:22
FreeType Font code for Torque2D. Should also work with modifications for Torque3D
//-----------------------------------------------------------------------------
// Copyright(C) 2013 James S Urquhart.
// Derived from code from T2D MIT, Copyright (c) 2013 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// Torque3D example of how to intercept a callback in code.
// Callbacks in Torque3D are declared by the DECLARE_CALLBACK macro, and are implemented by IMPLEMENT_CALLBACK.
// Usually they invoke a function in TorqueScript, but there is also an option to invoke a function via a function pointer which
// can be obtained from mAddress in the relevant EngineFunctionInfo.
//
// You must add the following in EngineFunctionInfo:
//
// void* getAddress() { return mAddress; }
//
@jamesu
jamesu / generate_T3D_engineapi_bindings.rb
Created October 5, 2012 21:12
Generates bindings from a Torque3D engineAPI.xml export
#
# Generates engineAPI bindings for Torque3D taken from engineAPI.xml
# Outputs to ext_bindings.h and ext_bindings.cpp
#
# NOTE: Currently the generated code is not meant to be usable,
# and is more of a proof-of-concept. There is also a lot of
# unnecessary duplication.
#
# To export the engineAPI console.xml:
#
@jamesu
jamesu / example_engineapi.cpp
Created September 25, 2012 08:46
Using the EngineAPI in Torque3D
// Note you will need to create a "getFunctionAddress" function in EngineFunctionInfo unless you use
// getProcAddress() & getBindingName() on the function exports.
void *getFunctionAddress() { return mAddress; }
//
// This example demonstrates the following:
// * calling "generateUUID" which is exported as a global function in the API.
// * constructing an instance of ColorI and setting its exposed fields.
//
@jamesu
jamesu / perl5_benchmark.pl
Created September 21, 2012 09:41
TorqueScript Benchmarking Reference Code
#!/usr/bin/perl
use Time::HiRes qw ( time );
my $PR = 0;
my $P0 = 0;
my $P1 = 0;
print "ENTRY\n";
@jamesu
jamesu / TSFunctionsVsVariables.cs
Created September 17, 2012 14:09
TorqueScript: Function Parameters vs Variables
//
// TorqueScript: Function Parameters vs Variables
//
// This simple demonstration illustrates the speed difference in
// passing function parameters as variables vs using the string stack, in a simple function
// which adds two numbers together.
//
// scriptTest1 technically incurs a penalty of converting the input variables to strings, while
// scriptTest2 instead looks up and assigns global variables.
// scriptTest3 which re-assigns variables in the function call is included to gauge
@jamesu
jamesu / dtmf_generate.c
Created August 8, 2012 17:17
Generate DTMF tones
//
// Generate DTMF tones
//
#include <stdio.h>
#include <math.h>
float OutData[44100];
typedef struct ToneInfo {
@jamesu
jamesu / ticket.rb
Created April 26, 2012 19:46
Amiando ticket script.rb
# Script to automate reserving tickets from amiando.
# Polls the site using chromedriver, automatically selecting 1 ticket
# and moving to the next step.
#
# Please use responsibly.
#
require 'rubygems'
require "selenium/webdriver"