Skip to content

Instantly share code, notes, and snippets.

@blam23
blam23 / word_search_times.gd
Created May 29, 2025 14:25
A crappy way to compare different word search algorithms.
extends Node2D
func load_str_array() -> PackedStringArray:
var packed_str_array : PackedStringArray = []
var file = FileAccess.open("res://dictionary.txt", FileAccess.READ)
var content = file.get_as_text()
packed_str_array = content.split("\n", false)
return packed_str_array
func load_dict() -> Dictionary:
@blam23
blam23 / GenericClass.cs
Created February 26, 2023 18:35
Generic Class Factory
using System.Reflection;
namespace GenericInitialiserTest
{
public static class GenericClassFactory
{
public static readonly Dictionary<Type, Type> Classes = new();
public static void RegisterAllGenerics(Assembly assembly)
{
@blam23
blam23 / TableTop Simulator Shuffle+.lua
Created March 29, 2021 19:36
Better shuffle for TableTop Simulator for decks users spawn in
shufflePlusTag = "shuffle+"
function onObjectSpawn(obj)
if (obj.type == "Deck") then
obj:addContextMenuItem("Shuffle+", function(player_color)
if (obj:hasTag(shufflePlusTag)) then
return
end
obj:addTag(shufflePlusTag)
newDecks = obj:split(4)
--[[
Blam's Chess Script
]]--
-- Define these completely *globally* so that other scripts can see them.
local engine_manager = {
engines = {}
}
@blam23
blam23 / BinarySearch.cs
Created November 23, 2016 20:41
"Binary" Search for a double in C#. Uses difference from needle for midpoint as opposed to halving sum
private static int BinarySearch(List<double> haystack, double needle, double tolerance = 0.0000001)
{
var left = 0;
var right = haystack.Count - 1;
while (needle <= haystack[right] && needle > haystack[left])
{
var leftDiff = needle - haystack[left];
var rangeDiff = haystack[right] - haystack[left];
var count = right - left;
@blam23
blam23 / gist:c79e0a92f37e8ad94311
Created July 12, 2014 19:13
Gifsound Auto Image Expander Script
// ==UserScript==
// @name Auto Image Expander
// @namespace Gifsound
// @description Automatically shows expanded image on page load instead of on click.
// @include http://gifsound.com/?gif=*
// @version 1
// @grant none
// ==/UserScript==
showmaxgif();
@blam23
blam23 / animations.lua
Created July 21, 2013 19:36
A little and basic animations library and example usage.
-- (c) 2013 Blam
-- Animations.lua
animation = { }
animation.__index = animation
animation.all = { }
function animation.delay(frames)
local a = animation:new{
a = 0,

Toribash Scripting Tutorial

Programming Basics Part Two

In this tutorial I am going to be going to present another simple script, and then go through step by step how it works, breaking it down and explaining it.

This time I will be explaining about Conditional Statements, Loops, Array Types and Comments.

-- Run this script in multiplayer!
people = get_bouts()

for i = 1,#people do

While

A while loop will keep going round and round until it's condition is met. Conditions are explained in the "Conditional Statements" section of the [main tutorial][tut].

Here is an example of a while loop:

x = 1
while(x < 20) do
    x = x * 2
    echo("X: " .. x)

end

@blam23
blam23 / Toribash-Tutorial-Inserts-ConditionalOperators.md
Last active December 20, 2015 00:28
Conditional Operators Segment

I took this out of the main tutorial to keep the size down, and keep this accessible.

This is part of the Toribash Scripting Tutorial.

  • > - Greater Than - If the variable on the left is greater than the variable on the right, it's true. If they are equal or the left is smaller it's false.

      10 > 20 = false
      20 > 20 = false
      30 > 20 = true