Skip to content

Instantly share code, notes, and snippets.

View chrisjbrown's full-sized avatar

Christopher Brown chrisjbrown

  • Amsterdam, Netherlands
View GitHub Profile
@chrisjbrown
chrisjbrown / name giver macro
Last active March 27, 2024 08:53
foundryvtt name giver macro
async function setName(type) {
const token = canvas.tokens.controlled[0]
if (!token) {
return;
}
if (type === "Dragon") {
const dragonTable = game.tables.getName(`Dragon Name`);
let dragonName = await dragonTable.roll();
return token.document.update({name: `${dragonName.results[0].text}`});
@chrisjbrown
chrisjbrown / machine.js
Created January 17, 2023 17:36
Generated by XState Viz: https://xstate.js.org/viz
const searchMachine = Machine({
id: 'search',
initial: 'idle',
context: {
results: [],
errorMessage: null,
},
states: {
idle: {
on: { FETCH: 'loading' },
[alias]
##
# One letter alias for our most frequent commands.
#
# Guidelines: these aliases do not use options, because we want
# these aliases to be easy to compose and use in many ways.
##
a = add
const tsA = [[1, 'a'], [3, 'c'], [4, 'c'], [8, 'b'], [9, 'a']]
const tsB = [[1, 'c'], [2, 'b'], [3, 'c'], [4, 'a'], [5, 'b'], [7, 'a'], [9, 'a']]
function getNext(A, B) {
let smallestA = A[0];
let smallestB = B[0];
if (!smallestB && smallestA) {
return A.shift()
}