Giter Club home page Giter Club logo

ge_tts_demo's Introduction

ge_tts Demo Project

This is an example demonstrating some basic features of ge_tts, a library for developing Tabletop Simulator mods.

Running the Demo

You must use the official Tabletop Simulator Atom plugin to run this mod. At the time of writing, it’s the only IDE that support require(), which is necessary to use ge_tts.

Type Annotations

Having said the above…

Through-out this demo there are many comments that look like ---@shape <blah>, ---@field <blah> --[[---@type <blah>]] and so on. These are special type annotations. They have zero impact on how Tabletop Simulator runs your code. They’re just like regular comments except they provide useful hints to IDEs that support them. These hints allow IDEs to not just auto-complete Tabletop Simulator APIs, but also your own APIs.

They also add static type safety to your project. Which basically means the IDE will catch (and highlight) common mistakes in your code in real-time as you write your code.

Unfortunately, there’s presently also only one IDE that supports these annotations, and it’s not Atom.

If you wish to use these type annotations (and they are optional) then you must install Luanalysis, which is a Lua plugin for Jetbrains IDEA, both of which are also free.

Therefore, if you want to use type annotations (which are great), you must code in Luanalysis, but also have Atom so that you can push your game to Tabletop Simulator. Not ideal, however for now, this is the only solution.

There isn’t one.

This demo is all code. Read on.

Setup

  1. Install Atom.

  2. Install the Tabletop Simulator Atom plugin.

  3. (Optional) Install IntelliJ IDEA Community (Free) Edition.

  4. (Optional) Install Luanalysis.

  5. Download the ge_tts_demo_release.zip (not source code) from latest releases.

  6. Extract its contents directly into your Tabletop Simulator Atom #include directory, by default that’s %HOME%\Documents\Tabletop Simulator.

    NOTE: By directly I mean you should end up with multiple directories extracted. If you end up with a single directory titled ge_tts_demo_release, open it and move its contents up one level.

Getting Started

  1. Launch Atom.

  2. Launch Tabletop Simulator.

  3. Create a Single Player game in Tabletop Simulator. Dismiss the prompt when it asks you which mod to load.

  4. Create a save game with this empty scene. Just call it ge_tts_demo.

  5. Now, strangely enough, TTS and Atom don’t play nice with newly created saves. So please proceed to load the save you just created.

  6. Open Atom, and from the menu choose PackagesTabletop SimulatorGet Lua Scripts, press Get Scripts when prompted.

  7. Replace the entire file contents of Global.-1.ttslua with just:

require('ge_tts_demo/Main')
  1. From Atom’s menu choose PackagesTabletop SimulatorSave and Play.

Ta-da!

You’re now playing world’s worst card game.

There’s no game mechanics, but you’ll note the cards are separated into two piles, "Spells" and "Instants". If you try drag a card onto the other pile, it will be rejected.

What if you try trick it? Create a deck to the side containing cards from both piles, then try drag it into the drop zone. Give it a go.

Phwoar! It is magic.

Mod Overview

The code is heavily documented and should do a good job of explaining what is being done, and why. So please do peruse it. However, what follows is a very quick overview of the mod’s structure.

Mod Entry-point (Main)

The main Lua file is ge_tts_demo\Main.ttslua, and is a good place to start.

Zones

ge_tts provides a Lua API for TTS' scripting triggers/zones that provides common functionality. For example, ge_tts includes a DropZone, which behaves like a customizable snap point with a customizable size area to drop objects in.

This mod implements its own CardDropZone, which inherits all the behavior of a DropZone, but has added logic to only accept cards of a certain type, either "spell" or "instant" cards.

Instances

ge_tts has the concept of an "Instance". Unlike TTS objects, which are destroyed when entering a container, instances more closely resemble the concept of a real world game piece, and are only destroyed if you delete the object in TTS.

This mod has just one type of instance, a CardInstance. As the name would suggest, it represents a card. It has a reference to a TTS' object, which may be a TTS card object or a deck object, if the card is presently held within a deck.

ge_tts Instance class also provides some convenience methods that help you interact with TTS objects. reject() is one such method that is used within this mod. reject() knows how to return an object to wherever it previously came from, its previous zone, or if it has never been in a zone before, where it was picked up from.

Even if our CardInstance refers to a card that is within a TTS deck, reject() will automatically pull it out of the deck if necessary, and just reject that individual card (not the entire deck).

Cards

This demo mod has an example data model demonstrating how you might represent a card library. If you prefer a different approach, that’s just fine.

Card Types

As mentioned, we have just two types of cards in this example "spell" cards, and "instant" cards.

Card Library

As part of the mod we have a card library. There’s just 5 cards in the demo. However, you could easily edit ge_tts_demo\CardInstace.ttslua and add additional cards to the library. If you do the mod will know what to do, and automatically create TTS objects representing those cards.

Card Utilities

The card utilities just exposes the one method, which creates a TTS "object state" (or "object data") corresponding with a card from our card library. An object state is what TTS uses to spawn a TTS object i.e. this mod includes all the code necessary to dynamically spawn cards.

Editing / Learning

If you installed Luanalysis, launch it, if not use Atom. In either case, simply choose FileOpen and navigate to %HOME%\Documents\Tabletop Simulator.

Debugging

So ah…​ How do you feel about a third IDE?

Officially, Tabletop Simulator has no support for debugging. Unofficially there’s this.

ge_tts_demo's People

Contributors

benjamin-dobell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.