Skip to content

Instantly share code, notes, and snippets.

function generateWindow( %x, %y, %width, %height )
{
// Values.
%width_full = %width + 128;
%height_full = %height + 129;
%width_shape = %width + 2;
%height_shape = %height + 2;
// Base.
function HazeLauncher::onMouseMove( %this, %pos )
{
if ( getWord( %pos, 0 ) < getWord( %this.extent, 0 ) && getWord( %pos, 1 ) >= getWord( %this.position, 1 ) )
{
%this.prevMMInside = true;
%this.updateStatusAll();
}
else if ( %this.prevMMInside )
{
%this.prevMMInside = false;
function updateScreenOffset()
{
cancel( $updateScreenOffset );
if ( !isObject( %sc = nameToID( "serverConnection" ) ) )
{
$dofX = 0;
$dofY = 0;
return;
@qoh
qoh / index.html
Created January 24, 2013 15:06
I was messing around with stuff and then this happened.
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<style>
* {
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
@qoh
qoh / save.cs
Created February 13, 2013 06:32
function gameConnection::dups( %this, %path )
{
if ( !isObject( %base = %this.player.tempBrick ) && !%base.duplicationBrick )
{
return;
}
if ( !isObject( %stack = %base.stack ) )
{
return;
function simGroup::createBrickFromJSON( %this, %data, %offset, %plant )
{
if ( %data.hasKey( "position" ) )
{
%position = vectorAdd( %data.get( "position" ), %offset );
}
else
{
return -1;
}
@qoh
qoh / save.cs
Created February 14, 2013 08:49
function save_json_bricks( %path, %set, %data, %offset )
{
if ( !strLen( %offset ) )
{
%offset = "0 0 0";
}
if ( !strLen( %data ) )
{
%data = js_object();
%start = %this.getEyePoint();
%beam = vectorScale( %this.getEyeVector(), 2.5 );
%stop = vectorAdd( %start, %beam );
%ray = containerRayCast(
%start, %stop,
$TypeMasks::FxBrickObjectType, %this
);
if ( isObject( firstWord( %ray ) ) )
function r(){exec("./main.cs");}
function swarmFighterVehicle::onAdd( %this, %obj )
{
parent::onAdd( %this, %obj );
SwarmFJetCheck( %obj );
%obj.flyState = 0;
%obj.droneTick = %obj.schedule( 50, "droneTick" );
>>> t = ast.parse("""
... def foo(x, y):
... y = -y
...
... if x == 4:
... print 'hi'
... else:
... print 'bye'
... """)
>>> print tspy.to_torquescript(t)