Skip to content

Instantly share code, notes, and snippets.

View hazzard993's full-sized avatar

Jason McKenzie hazzard993

View GitHub Profile
@hazzard993
hazzard993 / priority_queue.d.ts
Last active December 23, 2020 05:29 — forked from LukeMS/priority_queue.lua
Priority Queue implemented in lua, based on a binary heap.
declare function create<T>(this: void): PriorityQueue<T>;
interface PriorityQueue<T> {
empty(): boolean;
size(): number;
/**
* Swim up on the tree and fix the order heap property.
*/
swim(): void;
put(v: T, priority: number): void;
@hazzard993
hazzard993 / inspect.d.ts
Created November 26, 2020 23:20
TSTL import inspect
declare function inspect(this: void, value: any): string;
declare namespace inspect {
const prop: string;
}
export = inspect;

PICO-8 Transformer

  • Disallows LuaLibs
  • Disallows classes
  • Disallows iifes if (x = 0)
  • Disallows non-tuple return methods

for loops

Image Registry

LÖVE 2D can load images.

love.graphics.newImage("img/Player.png");

What is stopping you in TypeScript? The ImageRegistry.

Effect Registry

LÖVE 2D allows Effects to be added to the audio that is playing. Each effect is added with a name which can be used to obtain the audio effect later.

love.audio.setEffect("myEffect", {...});
love.audio.getEffect("myEffect");

To aid TypeScript, an EffectRegistry interface has been provided to keep track of the audio effects planned to be set.

Filepath Registry

LÖVE 2D can interact with the file system.

love.filesystem.getLastModified("file.txt");

However, there likely is a FileRegistry stopping you.

Registries

LÖVE 2D can interact with many things through the use of strings.

love.audio.getEffect("anEffect");
// Nothing crashes if anEffect didn't exist

love.filesystem.readFile("file.txt");
// No crash, just returns an error
@hazzard993
hazzard993 / pairs.ts
Created April 9, 2019 03:49
In TSTL, iterate using pairs, not Symbol.Iterator
// Works on 0.17.0
/**
* @tupleReturn
* @luaIterator
*/
declare function pairs(object: object): Iterable<[string, any]>;
declare const print: any;
@hazzard993
hazzard993 / luarocks-installation-windows10.md
Last active June 6, 2024 07:54
LuaRocks installation guide for Windows 10 users

Via Windows Linux Subsystem (WSL)

The luarocks package can be installed on a Windows Linux Subsystem.

Once installed, to use it, use luarocks inside a WSL shell or wsl luarocks within a Windows shell.

wsl                             # Enter WSL shell (if installed and enabled)
sudo apt-get update             # Update package lists (otherwise luarocks may not be found)
sudo apt-get install luarocks # Install luarocks