GithubHelp home page GithubHelp logo

nijikokun / sugarcube-starter Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 2.0 587 KB

Easy to use starter kit for creating stories with Tweego, Twine and SugarCube.

JavaScript 99.19% SCSS 0.20% HTML 0.41% TypeScript 0.20%
twine sugarcube interactive-fiction twee tweego

sugarcube-starter's Introduction

SugarCube Starter

The easiest starter kit for building SugarCube stories with Twine / Tweego.

๐ŸŽจ Features

  • Automatic Tweego & SugarCube Install โœ…
  • Fully Configurable โœ…
  • Automatic Builds โœ…
  • Local server with Live Reload โœ…
  • Directory for custom fonts โœ…
  • Directory for third-party scripts โœ…
  • Up to date packages and frameworks โœ…

๐Ÿ—ƒ Tech Stack

Built in to this template are a number of frameworks to get you going.

โ„น Requirements

๐Ÿš€ Getting Started

  1. Clone the repository
    npx degit nijikokun/sugarcube-starter <project-name>
    
  2. Install modules
    npm install
    
  3. Start developing
    npm start
    

New to SugarCube?

๐Ÿ‘ฉโ€๐Ÿ’ป Commands

  • npm start - Alias for npm run dev
  • npm run dev - Starts development server and watches src directory.
  • npm run dev:prod - Starts development server and watches src directory in production mode (NODE_ENV=production).
  • npm run build - Compiles and bundles the story in the dist directory.
  • npm run build:prod - Compiles and bundles the story in the dist directory for production.

๐Ÿ“ Directory Structure

Auto-Generated Directories

  • .tweego โ€” Tweego installation and story formats are installed here
  • .prebuilt โ€” Staging directory, files are processed and moved to dist
  • dist โ€” Compiled output directory

๐Ÿ™‹โ€โ™‚๏ธ How To

How do I update?

Before continuing make sure you back up your existing code!

  1. Download the latest release
  2. Copy over the package.json, config.json, tsconfig.json files and the .build directory.
  3. Run npm start

And that's it!

Note You might want to use something like jsondiff for the config.json if you have made changes.


How do I disable Debug View?

Debug View looks like this:

Option One (Production Mode)

Run development in production mode:

npm run dev:prod

Option Two

Create src/story/PassageReady.twee and put the following code inside:

:: PassageReady
<<run DebugView.disable()>>

Option Three

Open src/story/Start.twee and add the following code:

::StoryJavaScript[script];
predisplay["debug-disable"] = function (taskName) {
  DebugView.disable();
};

Option Four

Open src/story/Start.twee and add the following code:

::StoryJavaScript[script](function () {
  Setting.addHeader("Debug Settings");

  function initSettingDebug() {
    Config.debug = settings.debug;
  }
  Setting.addToggle("debug", {
    label: "Enable test/debug mode?",
    default: false,
    onInit: initSettingDebug,
    onChange: function () {
      initSettingDebug();
      window.location.reload();
    },
  });
})();


How should I initialize variables?

You should initialize your story variables using the StoryInit passage.

A good place to start is in src/story/Start.twee:

:: StoryInit
<<set $health = 100>>
<<set $maxHealth = 100>>

:: Start

HP: <<= $health>> / <<= $maxHealth>>


How do I install macros?

Macros scripts and styles go into src/assets/vendor


How do I link to media files?

To reference images and media at src/assets/media/<asset_path> you'll use media/<asset_path>. For eample:

  • src/assets/media/favicon.png โ†’ media/favicon.png

Here is an example in html (example):

<link rel="icon" type="image/png" href="media/favicon.png" />


How do I add Google Analytics?

Paste the following snippet into src/head-content.html:

<script
  async
  src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG_HERE"
></script>

and replace YOUR_TAG_HERE with your Google Analytics ID (UA-########).


How do I change the app directory name?

I don't suggest doing this, but if you really want to... You need to modify all instances of src/assets/app in two locations:

  • config.json
  • tsconfig.json

Good luck!

๐Ÿ›ฃ Roadmap

  • Automatically install tweego for users so they don't have to.
  • Add typescript support out of the box.
  • Add configuration, commands and build process for production.
  • Add command for testing build before distribution.
  • Add support for packaging dist directory.
  • Add support for compiling to Electron application.

๐Ÿค Helpful Resources

Starter Kit Resources

Official Resources

Third-Party Resources

๐Ÿ’œ Acknowledgements

We are grateful to these individuals for their ideas and contributions.

๐Ÿ“ License

Licensed under the MIT License.

sugarcube-starter's People

Contributors

dependabot[bot] avatar nijikokun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

arohman84 okzmo

sugarcube-starter's Issues

Add a 'cleanall' type of npm command for cleanup between builds.

This is a very cool system, but I have had trouble with updates. Each time it fails in some way that npm reports as unfixable. So what I usually need to do is re-download the entire updated repo in a new directory and than copy my files over top. This is the 3rd time since I started using this project.

I kind of want to have my files checked into local git repo, but even that won't solve this problem. Could we get an npm command to clean up the old built/downloaded version of code?

Live reload doesn't work after the first reload

Hello! I'm trying out this starter, but I noticed that the Live Reloading feature only works on the first rebuild, and not on subsequent rebuilds. I tried using the "--watch" option in the config file like this:

"tweego": {
  "dir": "./.tweego",
  "options": ["--watch"],
  โ€ฆ
}

โ€ฆ but the terminal stays stuck at this message when it's building the index.html file:

[builder] [init] Running build.

Watch mode started.  Press CTRL+C to stop.

Recursively watched paths: 3
  src\story
  dist\scripts
  dist\styles

BUILDING: dist\index.html

Is there any way to get both the Tweego rebuilding and style/js rebuilding processes to work at the same time?

Wrong version of tweego is pulled for macOS ARM platforms

Hi,

Decided to give this a spin and mess around with it a bit, got some spawnsync errors that it wouldn't run tweego however so decided to try to see if I can fix it. I am not sure which version gets downloaded really but whichever one it is it is the wrong version for macOS arm computers. The one that should be pulled is the tweego-2.1.1-macos-x64.zip (64-bit) version of tweego. I fixed it myself locally by just replacing the file but I thought I should at least give a headsup since twine and typescript seems like a great idea and I am very happy this project exists!

Add Snowpack

A new bundler with a bunch of features and lightning fast compilation.

Lack of error messages

[builder] [init] Running build.

PS Dir>

Sometimes the builder just ends without an explanation. And a build is not even constructed. Without an error message, it's hard to debug.

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.