Generic text asset for Superpowers, the extensible HTML5 2D+3D game engine.
JavaScript Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
data
editors/fText
node_modules/operational-transform
project/ftext
public
runtime
settingsEditors
typescriptAPI
typings
.gitattributes
.gitignore
LICENCE
index.d.ts
package.json
readme.md
tsconfig.json
tsd.json

readme.md

Superpowers Game fText plugin

This plugin brings a generic text asset of type fText to the Superpowers Game system for Superpowers, the extensible HTML5 2D+3D game engine.

Installation

  • Download the latest release,
  • unzip it then rename the folder to fText,
  • delete the project folder if you want,
  • move it inside core/systems/game/plugins/florentpoujol/,
  • then restart your server.

Creating a new asset

When creating a new asset in Superpowers' client, select the fText type.

Editor features and settings

The editor's theme, tab size and some other settings can be set through the "Text Editor" settings.

fText introduce some other settings :

Setting Action / Effect
Auto close brackets Automatically add the closing character when writing the following characters { ( [ " '
Highlight - active line: Makes the current line stand out.
- trailing spaces: in red.
- matching tags: in languages that have pairs of tags -like HTML- having the mouse cursor over one will highlight the other one.
Pressing Ctrl/Cmd+J will jump to the matching tag.
- matching words: when a word is selected, this highlight all other occurrences in the document.
Linting Enable/disable linting of the syntaxes (not all syntaxes can be linted)

Syntactic coloration and linting

The syntactic coloration and linting kicks in when the asset's extension is recognized.

The asset's extension can be any of CodeMirror's loaded modes or MIME type, some having standard short version.

Supported modes and extensions are :

Mode Short extension is linted
javascript js
json (application/json MIME type)
yes
coffeescript cson yes
yaml yml yes
xml
htmlmixed html
pug yes
css yes
stylus styl yes
markdown md
clike shader (x-shader/x-fragment MIME type)

Examples of asset name :

changelog.md
data.cson
template.pug

Includes

You can include a text asset's content into another with the include instruction.
Just write in your asset :

ftext:include:path/to/the/asset

Replace path/to/the/asset by the path to the asset to include inside this one.

The specified asset content will then be included when the asset is parsed with the fText.parse() method.

Since assets are usually parsed before the inclusion is performed, it is best to have comment characters immediately before the command.

Ie:

//ftext:include:path/to/the/asset

In-game usage

fText is the type of the text assets inside your game's code. Get an asset like this:

let asset = Sup.get( "My Text Asset", fText );
// or
let asset = Sup.get( "My Text Asset" ) as fText;

You can access the raw text content of the asset via the getText() method :

let asset = Sup.get( "My Text Asset", fText );
let data = asset.getText();

You can parse the asset's content with the parse() method as well as access all parsers through the static property fText.parsers :

Ie:

let asset = Sup.get( "My Jade Asset", fText );

let html = asset.parse();

let elt = fText.parsers.domify( html );

document.body.appendChild( elt );
// note that document is not accessible inside your game's code
// without the DOM plugin you can find at:
// https://github.com/florentpoujol/superpowers-dom-plugin
  • json, cson and yml are parsed to JS object.
  • pug and md > HTML string
  • html > DOM object
  • styl > CSS string

Test/Demo project

The project folder contains a test/demo project.

To run it, put the project's fText folder in Superpowers' projects folder, and (re)start the server.