DEV Community

A Modern Developer's Workflow For Twine

Em Lazer-Walker on January 16, 2020

I love Twine! Whether you're trying to prototype a larger work or make something on your own, it's such a powerful and easy-to-use tool to make hyp...
Collapse
 
fullmonkeypython profile image
S

Thank you for this tutorial ! It's a one of a kind. So helpful!

I used your workflow in this repo and adapted it after reading the comments as well --thank you all for those, especially tsaftaridis and Robert Lim. I see no more deprecation warnings for now.

I am also compiling a whole folder instead of a single .twee file.

Hoping this helps and/or saves time for others before things crash and burn again in node deprecation and javascript dependency hells :

name: Build

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Use Go 1.13
        uses: actions/setup-go@v5.0.1
        with:
          go-version: 1.13.x

      - uses: jaxxstorm/action-install-gh-release@v1.12.0 
        with:
          repo: tmedwards/tweego
          chmod: 0775
      - run : tweego story -o index.html

      - name: Deploy to Pages
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GH_PAGES_DEPLOY_TOKEN }}
          publish_branch: gh-pages
          publish_dir: ./
Enter fullscreen mode Exit fullscreen mode

Thank you again Em!

Collapse
 
tsaftaridis profile image
tsaftaridis

Thank you for putting this together! Confirming still works Aug 10th.

Collapse
 
burmashave profile image
burmashave

Thanks for this. Some notes from my experience following it:

  • The sample code wouldn't compile without a "StoryTitle" passage ("error: Special passage "StoryTitle" not found.")

  • I'm also using VS Code, and I really wanted syntax highlighting. The only extension I could find was "Twee2 tw2 Syntax," which supposedly accommodates files with either the .tw or .tw2 extension; I tried both, but only .tw2 worked. And since Tweego's docs say the 'official' extensions are .tw and .twee, I'm not sure if using .tw2 will cause headaches later

  • philome.la appears to be 'read-only' now, so might want to remove the reference to that

  • PlayFab-Twine sounded interesting: is it possible to get it working with formats other than Harlowe?

Collapse
 
lazerwalker profile image
Em Lazer-Walker • Edited

Thanks for this!

  • Just added a StoryTitle passage to the sample, and removed philome.la (as sad as it makes me!)

  • I'm also using the "Twee2 tw2 Syntax" extension. It's been working fine for me with ".twee" files without any configuration. Also worth noting that, even if it's not picking up .tw files, you can click the language name in the bottom-right corner of your VS Code window and manually select "Twee" to enable syntax highlighting for any file regardless of extension.

  • Building something like PlayFab-Twine depends on hooking directly into the internals of a story format. It's definitely possible to get it working with formats other than Harlowe, but it's a non-trivial amount of work. If there was a lot of interest, I'd consider making a new version for Snowman or Sugarcube.

Collapse
 
gamewise profile image
Gamewise

I'm definitely interested in a sugarcube version of PlayFab-Twine! It sounds amazing.
And thanks heaps for this informative blog post. I read it about 5 times before I could remotely understand it...but finally got tweego working yay! Next step Github actions!

Btw how did you get that AI collaboration working in VS??! Sounds so great

Collapse
 
katafrakt profile image
Paweł Świątkowski

Interesting... I have always thought that graphic editor is the only point of using Twine. If you don't use it, you may as well use Ink or ChoiceScript (license aside). But now maybe I'll try to bear with Twee and try to build something in it.

Collapse
 
lazerwalker profile image
Em Lazer-Walker

A huge benefit of Twine/Twee over other choice-based IF tools is that it can produce fully-playable games by itself, rather than you needing to e.g. embed Ink within a Unity game to produce something that others can play. There are plenty of ways to produce narrative games in Unity without needing to write code (tools like Fungus come to mind) but that’s all still a lot more complex than being able to go directly from a Twine node graph or Twee script to playable HTML.

Being able to embed raw HTML/JS/CSS into Twine games also gives a great on-ramp to more custom behavior. As someone without much/any code experience, it’s easy to start by copy/pasting a few macros made by the community and slowly work your way up to adding more complex functionality, in a way that more closely resembles the accessibility of the Geocities-era web than modern game dev.

Collapse
 
bobslim profile image
Robert Lim • Edited

Heya people,

I found it a little easier to use the compiled binary from github rather than compiling using go. I ran into a couple of issues with the dependencies there, and I wasn't sure how to proceed as a non-go-user.

Replace this:

- name: build game
  run: |
      go get github.com/tmedwards/tweego
      export PATH=$PATH:$(go env GOPATH)/bin
      tweego YOUR_TWEE_FILE.twee -o dist/index.html
Enter fullscreen mode Exit fullscreen mode

with this:

- uses: jaxxstorm/action-install-gh-release@v1.10.0 
  with:
      repo: tmedwards/tweego
      chmod: 0775
- run tweego YOUR_TWEE_FILE.twee -o dist/index.html
Enter fullscreen mode Exit fullscreen mode

for extra credit, I also managed my build scripts in a package.json. This lets the build server and my local dev environment use the same scripts. You still have to install tweego for yourself (this file is easiest)

"scripts": {
    "twee": "tweego --output src/pages/game.html twine",
    "dev:twee": "npm run twee -- --watch",
}
Enter fullscreen mode Exit fullscreen mode

If not included in tweego, remember to include your chosen storyformat in the repo in .storyformat/formatname-1

Collapse
 
kyrathasoft profile image
William.Miller • Edited

I've tried setting this up with my github using the OP's Yaml file contents, and the edits suggested by tsaftaridis; not having success

I'm trying to publish to page:
kyrathasoft.github.io/Stories/

using the following contents in my build.yml file...

`name: Build

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

  - name: Use Go 1.13
    uses: actions/setup-go@v1
    with:
      go-version: 1.13.x

  - name: build game
    run: |
      go get github.com/tmedwards/tweego
      export PATH=$PATH:$(go env GOPATH)/bin
      tweego Kyrathaba.twee -o dist/index.html

  - name: Deploy to Pages
    uses: peaceiris/actions-gh-pages@v3
    with:
      github_token: ${{ secrets.GITHUB_TOKEN }}
      publish_branch: gh-pages
      publish_dir: ./dist`
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tsaftaridis profile image
tsaftaridis

Thank you for the detailed explanations!

Build game fails, however, I can't see if I am doing anything wrong...

Anyone have the same problem?

Run go get github.com/tmedwards/tweego
go get github.com/tmedwards/tweego
export PATH=$PATH:$(go env GOPATH)/bin
tweego testcase.twee -o dist/index.html
shell: /usr/bin/bash -e {0}
env:
GOROOT: /opt/hostedtoolcache/go/1.13.15/x64
warning: path dist/index.html: lstat dist/index.html: no such file or directory
error: Starting passage "Start" not found.
Error: Process completed with exit code 1.

Collapse
 
tsaftaridis profile image
tsaftaridis • Edited

For anyone else using this guide, I got it to deploy to github pages by making the following changes in the config yaml file (workflow):

tweego YOUR_TWEE_FILE.twee -o dist/index.html to
tweego YOUR_TWEE_FILE.twee -o index.html

AND

publish_dir: ./dist
publish_dir: ./

Disclaimer: I am very much a newbie. Don't know if this breaks anything really important down the line.

Collapse
 
kyrathasoft profile image
William.Miller

I've not been able to find a copy of the very most recent Harlowe 3 format, the one used by Twine 2.6 desktop. Anyone know how I can get it? The best I could get Tweego to do was compile against, like, Harlowe 3.1

Collapse
 
coreydwillis profile image
Corey Willis

Thank you so much for this article! I was getting frustrated with using the Twine app to work on my game and this process is exactly what I was looking for!