Skip to content

Instantly share code, notes, and snippets.

View jorgen99's full-sized avatar

Jörgen Lundberg jorgen99

View GitHub Profile
@jorgen99
jorgen99 / sample.lua
Created December 7, 2020 01:14
changeColor bug in Tabletop Simulator
--
-- Workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=2311549480
--
setup_button_guid = "d6b9ab"
function onLoad()
button_setup("Randomize Players", setup_button_guid, 'setUp', 7000, 2000, 800)
end
function setUp()
@jorgen99
jorgen99 / tabletop.lua
Created February 5, 2020 01:05
Example on drawing random dice from a bag in Tabletop Simulator
-- Example on how to take a die from a shuffled bag
-- and put the die on its space.
-- A reply to this question on Reddit:
-- https://www.reddit.com/r/tabletopsimulator/comments/eft9h6/scripting_how_to_randomly_choose_objects_in_a_bag/
d20_guid = "2f4af6"
d12_guid = "d90df3"
d10_guid = "327eec"
d8_guid = "213698"
d4_guid = "0b8595"
@jorgen99
jorgen99 / agricola.lua
Created June 14, 2018 07:12
Lua script for use with Agricola in Tabletop Simulator
--
-- This script assumes that you're playing with three players
-- Blue, Yellow and Green.
--
-- All the guids are from the save-file that I used
-- to the develop this scipt. Some of the guids, like the bags
-- are probably the same, but the decks will surely be different
--
-- Use this file as inspiration for your own hacking.
--
@jorgen99
jorgen99 / gist:bf0fa6f6de79922e0c9a
Created March 4, 2015 10:24
git log pretty graph
git config --global alias.lg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%a>%Creset' --abbrev-commit --date=short --branches -20"
@jorgen99
jorgen99 / hack.sh
Created March 31, 2012 10:37 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jorgen99
jorgen99 / Game.scala
Created December 30, 2010 23:49
Kata Monty Hall in Scala, take two
import scala.util.Random
import scala.collection.mutable.ListBuffer
abstract class Door
case class Car() extends Door
case class Goat() extends Door
class Game(val doors:List[Door] = Random.shuffle(List(Goat(), Goat(), Car()))) {
var playerDoor = -1
var montyDoor = -1
@jorgen99
jorgen99 / Game.scala
Created December 12, 2010 02:43
The Monty Hall kata in scala
import scala.util.{Random}
import scala.collection.mutable.{ListBuffer}
class Game(doors: ListBuffer[Symbol] = Random.shuffle(ListBuffer('Car, 'Goat, 'Goat))) {
var playerDoor:Symbol = _
var montyDoor:Symbol = _
if (doors.count(_ == 'Car) != 1 || doors.count(_ == 'Goat) != 2) {
throw new IllegalArgumentException("Should be one Car and two Goats")
}