Animalchemists for Tabletop Simulator

Project · Tabletop Simulator · 09/05/2020

tabletop simulatorluasteam workshopboard gamesanimalchemistsscripting
Project

Tabletop Simulator scripting for the card game Animalchemists, built on artemisww's original table upload. Players craft spells from ingredient cards; the mod automates the parts of the turn that are tedious to do by hand: refilling the ingredient and spell rows, recycling the discard pile into a new deck, seeding the game-ending Time Stop card, and totalling the scores.

The Animalchemists table in Tabletop Simulator

Setup

On load the mod offers to randomise the ingredient and spell zones so the rows are shuffled before anyone sees them. Set the turn order (or leave it automatic and press End Turn round to the starting player), then "Start Game" adds the Time Stop card to the bottom of the spell deck so the game ends when it surfaces.

Turns

Everything hangs off TTS's onPlayerTurn event. When a turn ends, any empty ingredient and spell slots are refilled from their decks. If the ingredient deck is empty, the discard pile is grouped into a new deck and moved into its place; there is also a "Create Ingredient Deck" button for when the deck runs out mid-turn.

function onPlayerTurn(color)
    dealToZones(ingredientDeckZone, ingredientZones,
                ingredientZonePositions, ingredientZoneRotation,
                function() recreateIngredientDeck() end)
    dealToZones(spellDeckZone, spellZones,
                spellZonePositions, spellZoneRotation, nil)
end

Scoring

Once Time Stop is crafted, players flip their spells face up and drop their remaining ingredients into their coloured zones. "Display Scores" reads the point values off every card in each player's zone and announces the totals, so nobody has to add up by hand.

Lessons

Small as it is (about 350 lines of Lua), this was the first TTS mod and taught the things the later The Mind script leaned on: scripting zones are the reliable way to find cards, group() of a single card returns a list rather than a deck and has to be special-cased, and anything that moves an object should be followed by a wait before you look for it again.

screenshots
Gameplay
links