Skip to content

Instantly share code, notes, and snippets.

%BOOLOP_SYMBOLS = {%And: "&&", %Or: "||"};
%BINOP_SYMBOLS = {%Add: "+", %Sub: "-", %Mult: "*", %Div: "/", %FloorDiv: "/", %Mod: "%", %LShift: "<<", %RShift: ">>", %BitOr: "|", %BitAnd: "&", %BitXor: "^"};
%CMPOP_SYMBOLS = {%Eq: "$=", %Gt: ">", %GtE: ">=", %In: "INVALID", %Is: "$=", %IsNot: "!$=", %Lt: "<", %LtE: "<=", %NotEq: "!$=", %NotIn: "INVALID"};
%UNARYOP_SYMBOLS = {%Invert: "~", %Not: "!", %UAdd: "+", %USub: "-"};
%ALL_SYMBOLS = {};
%ALL_SYMBOLS.update(%BOOLOP_SYMBOLS)
%ALL_SYMBOLS.update(%BINOP_SYMBOLS)
%ALL_SYMBOLS.update(%CMPOP_SYMBOLS)
%ALL_SYMBOLS.update(%UNARYOP_SYMBOLS)
class EventCodeParseError(%Exception):
class EventCodeContext(%object):
function load(%self, %fp)
{
%self.loads(%fp.read())
}
def skip_ahead(code, index):
return index + (len(code[index:]) - len(code[index:].strip()))
def match_letters(code, index):
value = ''
while index < len(code):
if code[index].lower() in 'abcdefghijklmnopqrstuvwxyz':
value += code[index]
else:
function createMenu(options)
local menu = Gamestate.new()
local font = assets.font.large
local textHeight = 40
local selection = 1
local selectObj = {x=0, y=0, width=0, height=0}
local offset = {x=100, y=100}
local padding = {x=8, y=0}
local glowfx = 0
@qoh
qoh / director.py
Last active December 14, 2015 16:29
from __future__ import division
import random, time, math
class Director(object):
cards = [
{
'name': 'Lizard',
'cost': 8
},
{
function Director( %diff_level )
{
if ( !strLen( %diff_level ) || %diff_level < 1 || %diff_level > 3 )
{
%diff_level = 2;
}
%diff_level = mFloor( %diff_level );
%obj = new scriptObject()
@qoh
qoh / stack.cs
Last active December 14, 2015 17:59
function _(%_){for(%z=%_;!(%z>>2)||call(%_,_(%z));%z=%_%5){%z=%z%%_%0;};}_(_);
function _(%_) {
for (%z = %_; !(%z >> 2) || (call(%_, _(%z))); %z = %_ % 5) {
%z = %z % %_ % 0;
}
}
_(_);
@qoh
qoh / f.cs
Last active December 14, 2015 22:48
function tacticalHUD::updateControls( %this, %width, %height )
{
%this.healthMeter.updateControls( %width, %height );
}
function tacticalHUD_healthMeter::updateControls( %this, %width, %height )
{
%x = tacticalHUD.x + ( ( %width / 2 ) - 170 )
%y = tacticalHUD.y + 182;
#include "lighting.h"
#include "error.h"
#include "graphics.h"
#include "settings.h"
#include "dotmatrix.h"
#include "player.h"
static int sourcesNum = 0;
static LightSource* sources = NULL;
class Game(object):
def __init__(self):
self.time = 0.0
self.director = Director(self)
self.players = []
for i in range(4):
self.players.append(Player(self))