Forge is now it's own project.

This commit is contained in:
Scott Duensing 2026-10-06 16:57:52 -05:00
commit ddec1696e2
236 changed files with 46289 additions and 0 deletions

90
.gitattributes vendored Normal file
View file

@ -0,0 +1,90 @@
#
# Image
#
*.xcf filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.bmp filter=lfs diff=lfs merge=lfs -text
*.avif filter=lfs diff=lfs merge=lfs -text
*.tiff filter=lfs diff=lfs merge=lfs -text
*.ico filter=lfs diff=lfs merge=lfs -text
*.jxl filter=lfs diff=lfs merge=lfs -text
*.pcx filter=lfs diff=lfs merge=lfs -text
*.pnm filter=lfs diff=lfs merge=lfs -text
*.pgm filter=lfs diff=lfs merge=lfs -text
*.qoi filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.webp filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.jbg filter=lfs diff=lfs merge=lfs -text
#
# Other Binary
#
*.exe filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
*.dat filter=lfs diff=lfs merge=lfs -text
#
# Singe game and menu descriptors are Lua text, not binary.
#
games.dat !filter !diff !merge text
menu.dat !filter !diff !merge text
#
# Fonts
#
*.ttf filter=lfs diff=lfs merge=lfs -text
#
# Audio
#
*.wav filter=lfs diff=lfs merge=lfs -text
*.flac filter=lfs diff=lfs merge=lfs -text
*.vgz filter=lfs diff=lfs merge=lfs -text
*.nsf filter=lfs diff=lfs merge=lfs -text
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.mod filter=lfs diff=lfs merge=lfs -text
*.it filter=lfs diff=lfs merge=lfs -text
*.itz filter=lfs diff=lfs merge=lfs -text
*.MOD filter=lfs diff=lfs merge=lfs -text
*.med filter=lfs diff=lfs merge=lfs -text
*.xm filter=lfs diff=lfs merge=lfs -text
*.oxm filter=lfs diff=lfs merge=lfs -text
*.raw filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
*.opus filter=lfs diff=lfs merge=lfs -text
#
# Document
#
*.odt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.docx filter=lfs diff=lfs merge=lfs -text
#
# Video
#
*.mkv filter=lfs diff=lfs merge=lfs -text
*.avi filter=lfs diff=lfs merge=lfs -text
*.mov filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.mpg filter=lfs diff=lfs merge=lfs -text
#
# Archive
#
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
#
# Model
#
*.glb filter=lfs diff=lfs merge=lfs -text
*.stl filter=lfs diff=lfs merge=lfs -text

9
.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
*~
build/
*.log
**/__pycache__/
# Written by Singe when it is run from here; never source.
/Singe/
/data/
screenshots/

241
CHANGELOG Normal file
View file

@ -0,0 +1,241 @@
FORGE 1.00
==========
Unreleased
New Features
------------
- Forge is a project of its own, apart from Singe. ./build.sh renders the
book and packs Forge.game with whichever Singe binary it is pointed at,
and testScripts/run.sh runs Forge's tests against the same binary. Forge
needs Singe 3.00 or later.
- A Forge game says who made it. The game's form has credits fields --
developer, publisher, year, platform, genre, creator, source, and
description -- and a release writes them into its games.dat, where the menu
shows them. Notes go into a CREDITS.txt beside the game, and licence
files named in the credits travel with it. A port of an existing game gets
its original author's credits filled in from the original's own games.dat
and script header.
- A game can be sent to the master service for review from Forge. Shift+P
in the editor exports, packs, and uploads it; an upload is not in the catalogue
until it has been reviewed, and Forge shows where each version of yours
stands. Behind it: singePack(directory, database) packs a game from
a script exactly as --pack does, and the network layer can send a request
body straight from a file, so a game is never held in memory whole.
- Forge gives every description a permanent GAME_ID the first time it is saved
and writes it into the games.dat it exports, so a Forge game can be
published and updated.
- Forge can judge a shot by the picture rather than by a hitbox. lightSensor
is a behaviour of the framework now, the way a home laserdisc gun works: a
spot on the picture flashes on the frames a target is shown, and a shot is
good when the picture under the gun changes the way the spot does. It began
as five games' own vocabulary and was general all along, so it moved in, and
those five name no vocabulary of their own any more. pictureAt came with it,
a condition any rule can ask -- is the picture at this point bright, dark, or
neither -- for a flash hidden in a game's own video, a colour cue, or a lamp
in a scene; a game with no disc reads dark everywhere. Both are in the
book's vocabulary tables, which are generated from the manifest, and scene
100 covers them.
- Publishing from Forge writes a new file beside the old one and releases
the old copy only once the new one is in place, so an interrupted write
cannot lose either.
- Forge has tutorials: ten sittings at the front of Forge.pdf, each
ending with a game that plays, with the kit of pictures, sounds, a clip,
and a model they use packed in Forge.game, and the finished description
of each in the chooser. Each tutorial's scene presses the keys the text
names and checks the result, so the book cannot drift from the editor.
On the way the editor gained the game's own form (title, players, vars,
verbs, layers, and each layer's parameters), the digits as panel keys,
DELETE to empty a field, X to release a game with every file it names,
a file picker that keeps an unset field unset, and a panel that steps
aside while a polygon is drawn. What an entity is made from is now a
type, not a kind: types = { hero = ... } in a description, type = "hero"
on an entity and in an event's filter, and the Types panel. Forge's
launcher takes every key (MODE_FULL), so ENTER and TAB reach it, and
its panel's rows and fields take clicks. A value is edited in place:
it starts selected, so typing replaces it, and the arrows put a caret
into it. A field whose values are a fixed set opens a dropdown of them
-- true and false, the scancodes, the switches, the looks, the events,
the words a parameter takes, the game's own types, rooms, entities,
states, tracks, and nodes -- opened on the value it has, under its own
row, upward when there is no room below. The panel's list and fields
box scroll, with bars, and keep the chosen row in view. The game's
name at the top of the panel, or a press on empty canvas, brings the
game's own form back. A waves track (W in the tracks) spawns a type
by count and interval at a moment, a disc frame, or a rail camera's
stop, from an entity or a list of them in turn, or at a point; and
soundDone says when a clip playSound or a sound behaviour started has
ended. Ports of the test library began (FORGE.md section 14): the
five light gun games of the VHS era are Forge descriptions written by
a porting script, and play the same as the emulator under
the same inputs (testScripts/ports/). On the way: a lightSensor
behaviour, a pointer behaviour, fonts and anchors on the text look,
sprites drawn in copies, discPlay and discPause, pointerX and pointerY
in expressions, an event belonging to the room it happened in, and a
built game finding files beside its description. A game can bring a
vocabulary of its own: a description names a file of Lua
(vocabulary = "Vocabulary.singe") that adds looks, behaviours,
conditions, actions, layers, or events to the manifest for that game
alone; the editor loads it when the game opens and forgets it when
the game closes, the compiler checks against it, and the built game
carries it into a release. Their light sensor lives in one now,
beside those five games, and not in Forge. The Hypseus library's
eleven Karis Framework 3.32b titles are ported by the same converter, which
finds the framework where a game keeps it and notes its version; the
rest of that library is surveyed in FORGE.md 14.9. A branch on the
branching track can want its move mashed (mash = 6) or held (hold =
20). The seven Kimmy Script Engine titles are ported by the same
converter and a kimmy behaviour that
plays that engine's loop, and play as their originals do (FORGE.md
14.11).
util/forgePorts.py
assembles the ported games into a project folder of their own
(~/claude/singePorts), one game to a folder with its description, the
compiled port, the runtime, its files, and a games.dat. A description is a
.forge file now (it was .game, which is the packed release's, and the
chooser had to sniff which was which). The seventeen KarisFramework
games are ported too: util/forgePortKaris.lua reads a game's own
script, and the qte behaviour plays the framework's loop over the
framework's tables, running the game's script and add-ons in a shim;
every one plays as its original under the same driver. Flat
bodies are the size their looks are drawn at (they were half), and a
platformer stands on its point.
- A game can be described rather than written. Forge/Author.singe and
Forge/AuthorCompile.singe take a table of layers, entities, behaviours
and rules and compile it into an ordinary Singe game: the rules become
real Lua, so nothing walks a table every frame and the result can be
read and edited by hand. There is no notion of genre in it -- a game
declares which of the engine's layers it uses, and that is the whole
difference between a platformer and a quick-time event over video. The
vocabulary of conditions and actions is declared in a table rather than
built into the compiler, so new kinds of game are entries rather than
releases, and the "lua" action is the deliberate way out when a rule
needs something the vocabulary cannot say. See the manual.
- Forge runs as a game rather than only as a library: started from the
menu it opens on a chooser (its own descriptions, a new game from a
starter, a copy of anything dropped into its directory), the keys, the
mouse and the pad reach the editor, P saves, builds and plays what is on
screen and comes back to it, and ESC closes or leaves. Entities can be
added, duplicated, deleted and typed field by field -- position, look,
behaviours and their parameters, all from the manifest -- and renaming
one renames it in every rule. Conditions and actions are picked from
the vocabulary with their help beside them, rules reorder, a rule's
note is editable, and U undoes forty steps. The compiler loads the
runtime from Forge/, where it lives, so it no longer fails looking for
a Singe/Author.singe that never shipped.
- An editor for those descriptions, Forge, which is itself
a Singe game: the canvas is the same overlay at the same coordinates the
game will be played in, so what is placed is what is seen. Entity list
and details are an RmlUi document, the canvas beside them is drawn into
the overlay and picked the way a light gun game picks a target, and the
two compose because a button is offered to the GUI first while pointer
motion is never consumed. A description survives a round trip through
it: load, save, load again, and it compiles to the same game. Forge is
distributed on its own and no part of it ships inside Singe -- not the
editor, not the compiler, not the runtime. A game Forge builds carries
its own copy of that runtime, so it runs on a machine that has never had
Forge on it and cannot change behaviour because the engine moved on.
- A game released from Forge is standalone. forgeExport writes the
compiled script, a games.dat, the description it came from and a copy of
the runtime into a directory of its own, taken out of Forge. --pack turns
that directory into a .game. The game locates its own directory with
debug.getinfo rather than trusting DIR, which names the directory of the
script the engine was launched with -- not this one when a game is reached
by dofile.
- The editor edits rules, not only entity positions: Tab swaps the panel
between the entities and the event sheet, the selected rule opens in
place with its conditions and actions under it, and conditions and
actions are added from the same manifest the compiler reads, so the rule
editor needs no change when the vocabulary grows. It is driven by keys
as well as the pointer, which is how the bundled menu has always worked
and what a cabinet needs. ENTER types a value into the selected
condition or action and moves to its next one, ESC puts it back; a
number typed in comes back a number.
- Forge's description format is new (FORGE.md section 4): kinds with
instances, rooms that remember themselves, rules triggered by events
(collisions between kinds, hits, deaths, timers, disc frames) as well as
every frame, vars and states on every instance, expressions where a
number goes, any-of groups, timers, sound, a HUD document bound to vars,
actions that take time run as coroutines, and hitbox tracks keyed to
disc frames or time. A shoot-em-up and a light gun game over video
prove it (testScripts/author, scenes 58 and 59). The editor gained
kinds, rooms, event pickers, and a timeline that scrubs the disc's video
under the cursor (scene 60). Nothing of the first slice's format loads;
it was never released.
- Forge builds 3D games (FORGE.md section 5): a scene3d layer, model,
mesh, light, billboard, and text looks, the character controller moving
relative to a camera that is fixed, follows, orbits, sits in first
person, or rides a rail of points with stops, enemies that seek, an
animator playing a clip per state, targets with zones on named bones so
a gun's ray says which part it hit, ragdolls on death, bodies and
triggers. A rail shooter in the manner of House of the Dead and a 3D
platformer prove it (scenes 61 and 62), and the editor shows a 3D room
as the scene itself under an orbiting camera (scene 63).
- Forge builds adventure games (FORGE.md section 6): rooms that remember
themselves, walk areas baked to a navigation mesh in a painted room or
a modelled one, hotspots, a verb line and a text parser with the most
specific rule winning, an inventory, dialogue trees, cut-scenes across
rooms with fades, depth sorting and scaling, and whole-game saves. The
same rules run a two-room adventure in 2D and in 3D (scenes 64 and 65).
- Forge builds racing games and tower defences (FORGE.md section 7):
vehicles on the engine's vehicle physics with an opponent that drives a
track on its own, walkers that follow a target or patrol a lane, turrets
that fire at what is in range, instances placed by a click on the floor,
thrust, and hinge, ball, and slider joints (scenes 66 and 67).
- Forge builds branching video games and carries the arcade plumbing
(FORGE.md section 8): windows on the disc that want a move, with the
disc sent to a success or a failure clip, the score bezel mirroring the
game's vars, coins, continues, a results card with the best score kept,
and scores sent to the master service's board (scene 68).
- Forge's editor gained a search in every picker, a file picker for any
field that names a file, polygon drawing for walk areas and hotspot
outlines, a dialogue outline panel, and play-from-this-room (FORGE.md
section 9, scene 69).
- Forge's long tail (FORGE.md section 10): sprite sheets stepped by
state, tile maps from a sheet, MIDI notes as events, water that bodies
float in, boats under their propellers, and soft bodies (scenes 70 and
71). Every kind of game in FORGE.md's catalogue now has its vocabulary.
- Forge's sprites turn (a var, a spin behaviour, or a projectile aiming
along its flight), a particles look streams from an instance, the
checker names misspelt fields, and 2D particle bursts are drawn at all
(they never had been).
- Forge builds painted rooms in 3D with occluders, and its 3D viewport
gained axis gizmos with a turn handle; entities carry a rotation, and
a sprite faces left through a frame range of its own (FORGE.md section
12, scenes 70, 79, and 80).
- Forge's catalogue is written out (FORGE.md section 11): a first-person
shooter, breakout, a maze, third-person action, a space shooter, a
rhythm game, and bowling join the samples (scenes 72 to 78), and what
they found is fixed: a gun's ray passes through what is not a target,
events raised while the first room is built reach the rules, and a
rule on a key or a room can run once per instance of a kind.
- Forge has its own manual, docs/Forge.adoc, built to Forge.html and
Forge.pdf beside the Singe manual; the engine's manual keeps a pointer.
The build packs Forge.game itself, with the manual and four samples
that need no art inside, and Forge's first run copies Forge.pdf out to
its data directory and says where.
R redoes what U undid, forty steps deep.

674
COPYING Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

5403
FORGE.md Normal file

File diff suppressed because it is too large Load diff

43
README.md Normal file
View file

@ -0,0 +1,43 @@
# Forge
Forge is an authoring tool for Singe: a game is described -- its types, rooms, rules, and tracks --
rather than written, and Forge compiles the description into an ordinary Singe game that can be
read and edited by hand. Forge is itself a Singe game. It is its own project: nothing of it ships
inside Singe, and a game it builds carries its own copy of the runtime.
Forge needs Singe 3.00 or later.
## Layout
| Folder | What is in it |
|---|---|
| forge/ | Forge itself: the editor (Forge.singe, Forge.rml), the runtime (Author.singe), the compiler (AuthorCompile.singe), its games.dat, the kit of art the tutorials use, and the tutorials' finished descriptions |
| docs/ | The Forge book (Forge.adoc), its vocabulary chapter (ForgeVocabulary.adoc, generated), and its pictures |
| testScripts/ | The test scenes, the sample descriptions (author/), the library port comparisons (ports/), and the files they load |
| util/ | Tools: the vocabulary chapter, the tutorial kit and pictures, credits, and the library converters |
| FORGE.md | The plan |
## Building
./build.sh
writes build/Forge.html, build/Forge.pdf, and build/Forge.game, the distributable. Packing is
Singe's own --pack, so the build needs a Singe binary: by default the newest one in a Singe tree
beside this one (../singe/.builddir), or whatever SINGE names:
SINGE=/path/to/Singe-v3.00-Linux-x86_64 ./build.sh
It also needs lua5.4, asciidoctor, and asciidoctor-pdf.
## Testing
testScripts/run.sh every scene
testScripts/run.sh 52 83 just these
runs the scenes headless against the same Singe binary (SINGE again) and reports each. Logs and
screenshots are kept in build/tests/.
## Licence
GPL version 3 (COPYING). The test files' and the kit's credits are in testScripts/README.md and
forge/kit/LICENSE.

1
VERSION Normal file
View file

@ -0,0 +1 @@
1.00.1.1

56
build.sh Executable file
View file

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Builds Forge: the vocabulary chapter from the manifest in forge/Author.singe, the book as
# build/Forge.html and build/Forge.pdf, and the distributable build/Forge.game -- forge/ with the
# book and four samples beside it, packed by Singe's own --pack. Singe is not part of this
# project: point SINGE at the engine binary to pack with, or leave it to find the newest build in a
# Singe tree beside this one.
#
# ./build.sh uses ../singe/.builddir/Singe-v*-Linux-x86_64
# SINGE=/path/to/Singe-v3.00-Linux-x86_64 ./build.sh
#
# Needs lua5.4, asciidoctor and asciidoctor-pdf. The version comes from VERSION: four numbers,
# patch 1 meaning a beta and tweak saying which, so 1.00.1.1 is "1.00b1", as Singe numbers itself.
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
out=$here/build
singe=${SINGE:-$(ls -t "$here"/../singe/.builddir/Singe-v*-Linux-x86_64 2>/dev/null | head -1)}
for tool in lua5.4 asciidoctor asciidoctor-pdf; do
if ! command -v "$tool" > /dev/null; then
echo "error: $tool not found" >&2
exit 1
fi
done
if [[ -z $singe || ! -x $singe ]]; then
echo "error: no Singe binary; set SINGE to the engine to pack with" >&2
exit 1
fi
read -r major minor patch tweak <<< "$(tr '.' ' ' < "$here/VERSION")"
if [[ $patch == 1 ]]; then
version="${major}.${minor}b${tweak}"
else
version="${major}.${minor}"
fi
mkdir -p "$out"
# The vocabulary tables come from the manifest itself, so the book cannot drift from it.
(cd "$here" && lua5.4 util/forgeVocabulary.lua > docs/ForgeVocabulary.adoc)
asciidoctor -a data-uri -a revnumber="$version" "$here/docs/Forge.adoc" -o "$out/Forge.html"
asciidoctor-pdf -a revnumber="$version" "$here/docs/Forge.adoc" -o "$out/Forge.pdf"
# The package: the scripts, the kit, the tutorials, the book, and the samples that need no art
# beyond what Singe ships, so the chooser has something to open on a fresh install. Packing
# refuses to overwrite, and it runs in the staging folder because Singe writes Singe/ and data/ into
# its working directory.
stage=$out/stage
rm -rf "$stage" "$out/Forge.game"
mkdir -p "$stage"
cp -r "$here/forge" "$stage/Forge"
cp "$out/Forge.pdf" "$stage/Forge/"
cp "$here"/testScripts/author/{platformer,breakout,qte,fmv}.forge "$stage/Forge/"
(cd "$stage" && "$singe" --pack "$stage/Forge" "$out/Forge.game")
rm -rf "$stage"
echo "Forge $version, packed with $singe:"
ls -la "$out/Forge.html" "$out/Forge.pdf" "$out/Forge.game"

1928
docs/Forge.adoc Normal file

File diff suppressed because it is too large Load diff

721
docs/ForgeVocabulary.adoc Normal file
View file

@ -0,0 +1,721 @@
// Generated by util/forgeVocabulary.lua from forge/Author.singe. Do not edit.
=== Layers
[cols="1,3,2"]
|===
| Name | What it does | Parameters
| `bezel`
| The arcade score panel around the picture, showing the vars score (and score2), lives (and lives2), and credits as they change.
| `twin` (boolean)
| `disc`
| The video the game is played over. The file is what the editor scrubs; games.dat names it when the game runs.
| `file` (file), `start` (number)
| `hud`
| An RmlUi document over everything. bind maps element ids to game vars, refreshed as they change.
| `bind` (table), `document` (file)
| `music`
| A track that plays from the start, looping.
| `file` (file), `volume` (number)
| `overlay`
| Flat drawing over everything: sprites, scores, prompts.
| --
| `parser`
| A text parser: a prompt the player types at, and words the game knows. What is typed raises the said event.
| `ignore` (table), `prompt` (string), `words` (table)
| `scene3d`
| The 3D scene: physics in three axes, a sun, a sky, fog. Positions are world units.
| `ambient` (table), `exposure` (number), `fog` (table), `fov` (number), `gravity` (number), `sky` (file), `sun` (table)
| `world2d`
| A flat world with gravity: physics in the XY plane, drawn into the overlay.
| `gravity` (number)
|===
=== Looks
[cols="1,3,2"]
|===
| Name | What it does | Parameters
| `billboard`
| A sprite in the scene, always facing the camera: a tree, a puff, a health bar.
| `d` (number), `file` (file), `h` (number), `height` (number), `w` (number)
| `box`
| A filled rectangle, centred on the instance -- or standing on it, with anchor feet.
| `anchor` (feet), `b` (number), `g` (number), `h` (number), `r` (number), `w` (number)
| `grid`
| A map of tiles from a sheet, its top left at the instance: columns is the sheet's width in tiles, tile the tile's size, map the rows of tile numbers (1 is the first; 0 is empty), rows separated by semicolons.
| `columns` (number), `file` (file), `map` (string), `tile` (number)
| `light`
| A point or spot light, or a sun, on the instance.
| `b` (number), `g` (number), `intensity` (number), `r` (number), `range` (number), `shadow` (boolean), `type` (point, spot, sun)
| `mesh`
| A box, sphere, cylinder, or plane with a colour or a texture. Floors, walls, crates, targets. An occluder is not seen but hides what is behind it: a pillar that is only in the painting.
| `b` (number), `d` (number), `g` (number), `h` (number), `metallic` (number), `occluder` (boolean), `r` (number), `roughness` (number), `shape` (box, sphere, cylinder, plane), `texture` (file), `unlit` (boolean), `w` (number)
| `model`
| A glTF model under the instance, scaled and turned, playing a clip. w, h, d say how big it counts as.
| `clip` (string), `d` (number), `file` (file), `h` (number), `rx` (number), `ry` (number), `rz` (number), `scale` (number), `w` (number)
| `none`
| Nothing drawn: a trigger, a spawner, a hitbox over video, a camera.
| `d` (number), `h` (number), `w` (number)
| `particles`
| A steady stream of particles from the instance: a fire, smoke, a thruster, rain. Colour, size, speed, and life as an emitter takes them.
| `b` (number), `g` (number), `gravity` (number), `life` (number), `r` (number), `rate` (number), `size` (number), `speed` (number), `spread` (number)
| `qteHud`
| The HUD of a quick-time-event game: what its qte behaviour's state says a player sees (the score and the record, the lives or the life bar, and the rest), drawn from the game's own pictures and font as the game lays them out.
| --
| `sprite`
| An image, centred on the instance -- or standing on it, with anchor feet. frames splits a sheet into that many columns; the var frame picks one. The var angle turns it, starting from the entity's rz. faces says which way the art looks (right unless said, or none): while the var facing is the other way the image is mirrored, so art drawn one way walks both. The var copies draws it that many times in a row, step pixels apart (a row of bullets, of hearts): negative steps go left.
| `anchor` (feet), `faces` (right, left, none), `file` (file), `frames` (number), `step` (number)
| `text`
| A line of text, its top left at the instance -- or centred on it, standing on it (feet), or hanging from it (top). The var text is what it says. A font file and size of its own, or the game's.
| `anchor` (centre, feet, top), `b` (number), `font` (file), `g` (number), `r` (number), `size` (number), `text` (string)
| `text3d`
| A line of text standing in the scene. The var text is what it says.
| `height` (number), `text` (string)
|===
=== Behaviours
[cols="1,3,2"]
|===
| Name | What it does | Parameters
| `animator`
| A clip per state: idle, walk, attack, hit, dead, or any state a rule sets. A clip that does not loop raises animationDone when it ends.
| `attack` (string), `dead` (string), `fade` (number), `hit` (string), `idle` (string), `loop` (string), `walk` (string)
| `body`
| A thing physics moves: a crate, a ball, debris. Mass, bounce, friction, and buoyancy as Jolt takes them.
| `bounce` (number), `buoyancy` (number), `friction` (number), `mass` (number), `shape` (box, sphere)
| `branching`
| Branch windows over the disc: a track of branches, each a disc frame window, the move it wants, and where the disc goes on success and on failure. A branch with mash wants the move that many times inside the window; one with hold wants it held that many frames. Raises branchOpen, branchTaken, and branchMissed.
| `track` (track)
| `camera`
| The scene is drawn from this instance. fixed looks at a point; follow keeps an offset from a target; first sits on a target's eyes and the mouse looks; orbit circles a target; rail rides a track of points with stops.
| `eye` (number), `lag` (number), `lookX` (number), `lookY` (number), `lookZ` (number), `mode` (fixed, follow, first, orbit, rail), `target` (string), `track` (track), `x` (number), `y` (number), `z` (number)
| `character`
| Walks, falls, and jumps in the scene: the engine's character controller. Moves by the vars dx and dy, relative to the camera.
| `height` (number), `jump` (number), `radius` (number), `speed` (number)
| `drift`
| Moves steadily, for a cloud, a platform, or a target.
| `vx` (number), `vy` (number)
| `frames`
| Steps a sprite look's frame: a range of frames per state, as "idle=1-1, walk=2-5", at a rate a second. A sheet drawn facing both ways names the other way's frames stateLeft or stateRight (walkLeft), used while the var facing is that way instead of mirroring the look.
| `fps` (number), `states` (string)
| `gun`
| The pointer as a gun for one player: a press of the trigger raises hit on what is under it, or miss. Ammo counts down; a shot off the screen reloads. With aim centre it fires from the middle of the picture -- a first-person gun.
| `aim` (centre), `ammo` (number), `player` (number), `reload` (offscreen), `trigger` (switch)
| `health`
| The var health; the damage action lowers it, and at zero the instance raises death and is destroyed unless keep is set. With ragdoll, a model falls limp instead and goes after linger seconds.
| `keep` (boolean), `linger` (number), `max` (number), `ragdoll` (boolean)
| `hitbox`
| The instance's hit shape comes from a track of boxes keyed by disc frame or time; between keys it is interpolated, outside them there is none. A track with step = true keeps a box only on the frames it keys.
| `track` (track)
| `hotspot`
| Something a verb can be used on: a name for the sentence line, a place to walk to first, and a polygon (x,y pairs) when its look's box will not do.
| `name` (string), `polygon` (table), `walkX` (number), `walkY` (number), `walkZ` (number)
| `joint`
| Joins this body to another's -- or to the world, with no other -- by a hinge, a ball, or a slider through a world point along an axis.
| `ax` (number), `ay` (number), `az` (number), `dx` (number), `dy` (number), `dz` (number), `other` (string), `type` (hinge, ball, slider)
| `keys`
| Reads a player's keys into the vars dx and dy (-1 to 1) and fire, so rules and movers read intent rather than hardware.
| `down` (scancode), `fire` (scancode), `left` (scancode), `player` (number), `right` (scancode), `up` (scancode)
| `lightSensor`
| Judges a shot by the picture rather than by a hitbox, the way a home laserdisc gun does: a spot on the picture (x, y) flashes bright or dark on the frames a target is shown, and a shot is good when the picture under the gun changes the way the spot does over the two frames after the trigger. A shot into the spot's own corner (left, top and beyond) is not judged, so the spot cannot be shot. Raises fire on the trigger, then hit or miss. For a game whose disc carries the targets in its own picture; a game with hitboxes wants gun and target instead.
| `high` (number), `left` (number), `low` (number), `player` (number), `top` (number), `trigger` (switch), `x` (number), `y` (number)
| `mover`
| Moves by the vars dx and dy at a speed, kept on the screen when clamp is set. Pair it with keys.
| `clamp` (boolean), `speed` (number)
| `patrol`
| Walks a list of points in turn -- a creep's lane, a guard's round -- looping or stopping, and raises patrolEnd at the last.
| `loop` (boolean), `points` (table)
| `platformer`
| Runs, falls, and jumps: the engine's character controller in 2D. Rules say which way with run and jump. Its point is its feet, so its look stands on it. Sets the var facing, and the var state to idle, walk, jump, or fall unless a rule set another.
| `jump` (number), `speed` (number)
| `pointer`
| Follows a player's pointer: a crosshair, a hand. Hidden when the engine says a real gun wants no crosshair drawn.
| `player` (number)
| `projectile`
| Flies at a velocity and is dropped past the edge (or far away, in 3D) or after life seconds. With aim, a sprite turns to point the way it flies.
| `aim` (boolean), `life` (number), `vx` (number), `vy` (number), `vz` (number)
| `qte`
| Plays a laserdisc quick-time-event game from the tables under game.qte: an attract loop, credits, levels of scenes with moves to answer in a window of frames, death clips, continues, the settings, and the game's own add-ons. qte.options.style says how its moves are judged and its levels run: windows (the default: a move answered in a window, compound moves too), held (moves judged by what is held together: combos, mashes, holds, sequences, paths, timed and yes/no branches, tilt, a life bar, die and retry, a new-game menu, a level select), segments (levels of segments, a map between them, the game's own level functions run as they are), checkpoints (checkpoints, a time-stop choice of three, a tally by deaths, a life per quota), or trophies (segmented levels judged the windows way, a difficulty select, a level-clear screen, trophies). The port converter writes the tables from an existing game's script.
| --
| `racer`
| Drives a vehicle round a track of points on its own: steering toward the next, throttling by how straight the road is.
| `reach` (number), `throttle` (number), `track` (track)
| `seek`
| Moves straight toward a target -- an entity's id, or "camera" -- and raises arrived within stopAt of it.
| `fly` (boolean), `speed` (number), `stopAt` (number), `target` (string)
| `shooter`
| Spawns a type from an offset while the var fire is set (or always, with auto), no faster than the rate.
| `auto` (boolean), `offsetX` (number), `offsetY` (number), `rate` (number), `spawns` (type)
| `soft`
| A mesh look made soft: a cloth, or a body inflated to a pressure.
| `mass` (number), `pressure` (number), `stiffness` (number), `type` (cloth, body)
| `solid`
| Immovable ground or a wall, in a world2d or a scene3d room. With moving, a body that follows wherever the instance is moved -- a paddle, a lift.
| `moving` (boolean)
| `sound`
| A clip per event: spawn, hit, miss, death, fire (a gun's trigger), or any event the instance sees. Values are file names. volume is the clips' own, 0 to 100, under the game's.
| `death` (file), `fire` (file), `hit` (file), `miss` (file), `pressed` (file), `spawn` (file), `volume` (number)
| `spawner`
| Makes instances of a type every so many seconds at its own position or at one of its points, up to max alive at once and total in all.
| `every` (number), `max` (number), `pick` (turn, random), `points` (table), `spawns` (type), `total` (number)
| `spin`
| Turns steadily: the var angle in 2D (a sprite turns with it), the node about Y in 3D, in degrees a second.
| `rate` (number)
| `target`
| Something a gun can hit. In 2D its look's box; in 3D a body the size of its look, plus zones -- boxes on named bones, so a shot says which part it hit.
| `zones` (table)
| `thrust`
| A body pushed along its nose by the var dy and turned by dx: a hovercraft, a ship, a plane without lift.
| `force` (number), `turn` (number)
| `timer`
| Raises the timer event with its name after some seconds, or every so many. start false waits for timerStart.
| `after` (number), `every` (number), `name` (string), `start` (boolean)
| `trigger`
| A volume that reports what enters and leaves it, as the enter and leave events. A checkpoint, a doorway, a prize.
| --
| `turret`
| Fires at the nearest instance of a type within range, no faster than the rate: spawns a projectile aimed at it, or, with no projectile, does the damage itself.
| `damage` (number), `range` (number), `rate` (number), `spawns` (type), `speed` (number), `targets` (type)
| `vehicle`
| A car, motorcycle, tank, or boat on the engine's vehicle physics, driven by the vars dy (throttle, up is forward) and dx (steering) from keys. Wheels hang at the four corners the sizes say; a boat needs none.
| `mass` (number), `radius` (number), `suspension` (number), `thrust` (number), `torque` (number), `type` (car, motorcycle, tank, boat), `wheelX` (number), `wheelZ` (number), `width` (number)
| `walker`
| Walks the room's walk areas (2D) or its floors (3D) on the navigation mesh: walkTo sends it, a click on the floor can, follow keeps it after an entity (or the camera), and it raises arrived. Its state is walk or idle as it goes.
| `every` (number), `follow` (string), `radius` (number), `speed` (number), `stopAt` (number)
| `water`
| Fills a mesh look with water: its top is the surface, and bodies inside float or sink by their buoyancy.
| `density` (number), `drag` (number)
|===
=== Events
[cols="1,3,2"]
|===
| Name | What it does | Parameters
| `animationDone`
| A clip that does not loop ended on self; event.state says which state it was for.
| `state` (state), `type` (type)
| `arrived`
| A seeking instance reached its target.
| `type` (type)
| `branchMissed`
| The window closed without the move and the disc went to the fail frame.
| --
| `branchOpen`
| A branch's window opened; event.move says what it wants, event.mash how many times, event.hold for how many frames.
| --
| `branchTaken`
| The move was made in time and the disc went to the success frame.
| --
| `collision`
| An instance of type a began touching one of type b (self is a, other is b).
| `a` (type), `b` (type)
| `death`
| self's health reached zero.
| `type` (type)
| `enter`
| An instance of type b entered a trigger of type a (self is the trigger, other what entered).
| `a` (type), `b` (type)
| `frame`
| Every frame.
| --
| `frameReached`
| The disc passed a frame.
| `frame` (number)
| `gameOver`
| The game ended.
| --
| `hit`
| A gun shot landed on self; other is the gun.
| `player` (number), `type` (type)
| `leave`
| An instance of type b left a trigger of type a.
| `a` (type), `b` (type)
| `midi`
| A MIDI note came in on the port the game opened; event.pitch and event.velocity say which and how hard. (pitch, since note is what a rule's comment is called.)
| `pitch` (number)
| `miss`
| A gun shot hit nothing; self is the gun. event.offscreen says whether it left the screen.
| `player` (number)
| `patrolEnd`
| A patrolling instance reached the last of its points.
| `type` (type)
| `pressed`
| A key or a switch went down.
| `key` (scancode), `player` (number), `switch` (switch)
| `railEnd`
| A rail camera reached the end of its track.
| --
| `released`
| A key or a switch came up.
| `key` (scancode), `player` (number), `switch` (switch)
| `roomEnd`
| A room is about to be left.
| `room` (room)
| `roomStart`
| A room has been entered.
| `room` (room)
| `said`
| A line was typed at the parser: its verb, noun, and second noun as the words table knows them, or unknown for a word it does not. The most specific rule wins.
| `noun` (string), `second` (string), `verb` (string)
| `soundDone`
| A clip that playSound or a sound behaviour started has ended; event.file says which, and self is the instance that played it.
| `file` (file), `type` (type)
| `spawn`
| self has just been made.
| `type` (type)
| `stopped`
| A rail camera reached a stop; event.name says which. pathNext moves it on.
| `name` (string)
| `timer`
| A timer on self went off; event.name says which.
| `name` (string), `type` (type)
| `verb`
| A verb was used on a hotspot (self), with an item or not: "use key on door". The most specific rule wins.
| `item` (string), `target` (string), `verb` (string)
|===
=== Conditions
[cols="1,3,2"]
|===
| Name | What it does | Parameters
| `below`
| An instance has fallen past a line -- a pit, or the bottom of the screen.
| `entity` (entity), `y` (number)
| `chance`
| True with a probability, 0 to 1.
| `p` (number)
| `discBetween`
| The disc is between two frames -- the window a QTE is answered in.
| `from` (number), `to` (number)
| `every`
| True once every so many seconds, for a rule that fires steadily.
| `seconds` (number), `tag` (string)
| `has`
| The inventory holds an item.
| `item` (string)
| `hitPart`
| The shot landed on a named zone of the target: head, weakspot.
| `part` (string)
| `hover`
| A player's pointer is over the named hotspot.
| `player` (number), `target` (string)
| `inState`
| An instance's state is this.
| `entity` (entity), `state` (state)
| `keyHeld`
| A key is down.
| `key` (scancode)
| `keyPressed`
| A key went down this frame.
| `key` (scancode)
| `onGround`
| A platformer has ground under it.
| `entity` (entity)
| `onScreen`
| An instance's box is at least partly on the overlay.
| `entity` (entity)
| `once`
| Only the first time this rule would run -- per instance and per room unless scope is "game".
| `scope` (string), `tag` (string)
| `pictureAt`
| The disc's picture at a point is bright, dark, or neither: a flash a game hides in its own video, a colour cue, or a lamp in the scene. A game with no disc reads black, since the engine answers zeroes when nothing is playing.
| `high` (number), `is` (string), `low` (number), `x` (number), `y` (number)
| `pointerIn`
| A player's pointer is over an instance.
| `entity` (entity), `player` (number)
| `pointerOffscreen`
| A player's pointer is off the picture, which is how a light gun reloads.
| `player` (number)
| `switchHeld`
| A pad, gun, or mouse switch is down.
| `switch` (switch)
| `test`
| An expression is true: self.health <= 0, count("zombie") == 0, score > 1000.
| `expr` (expression)
| `timeBetween`
| The game is between two moments, in seconds.
| `from` (number), `to` (number)
| `touching`
| Two instances overlap.
| `entity` (entity), `other` (entity)
| `waiting`
| A rail camera is held at a stop.
| `entity` (entity)
|===
=== Actions
[cols="1,3,2,1"]
|===
| Name | What it does | Parameters | Waits
| `addScore`
| Add to the score.
| `amount` (number)
|
| `addVar`
| Add to a var on an instance, or on the game with no entity.
| `amount` (number), `entity` (entity), `name` (string)
|
| `cameraCut`
| Draw the scene from another camera instance.
| `entity` (entity)
|
| `credit`
| A coin: one more credit.
| --
|
| `damage`
| Take from an instance's health; at zero it dies.
| `amount` (number), `entity` (entity)
|
| `destroy`
| Remove an instance.
| `entity` (entity)
|
| `die`
| A death: a message, then the game starts over.
| `text` (expression)
| yes
| `discPause`
| Hold the disc on its frame: a still behind a title.
| --
|
| `discPlay`
| Play the disc from where it stands.
| --
|
| `discTo`
| Send the disc to a frame -- the branch a QTE takes.
| `frame` (number)
|
| `emit`
| A burst of particles at an instance: an explosion, sparks, a puff.
| `b` (number), `count` (number), `entity` (entity), `g` (number), `r` (number), `speed` (number)
|
| `face`
| Turn a walker to face left or right, or toward an instance.
| `direction` (string), `entity` (entity), `target` (entity)
|
| `fade`
| Fade the picture to black, or back (with out false), and wait.
| `out` (boolean), `seconds` (number)
| yes
| `flash`
| Flash the screen a colour.
| `b` (number), `g` (number), `r` (number), `seconds` (number)
|
| `gameOver`
| End the game: rules stop, the gameOver event fires, restart begins again.
| --
|
| `give`
| Put an item in the inventory.
| `item` (string)
|
| `goTo`
| Go to a room, taking the named entity along and placing it at a point there -- or where the entity called at stands in that room.
| `at` (string), `entity` (entity), `room` (room), `x` (number), `y` (number), `z` (number)
|
| `jump`
| Ask a platformer to jump.
| `entity` (entity)
|
| `loadGame`
| Bring a slot back.
| `slot` (number)
|
| `lookAt`
| Turn an instance toward another.
| `entity` (entity), `target` (entity)
|
| `lua`
| Anything the vocabulary cannot say. The way out, and it is meant to be used.
| `code` (lua)
|
| `moveTo`
| Put an instance somewhere.
| `entity` (entity), `x` (number), `y` (number), `z` (number)
|
| `nextVerb`
| Cycle to the next verb in the game's list.
| --
|
| `pathNext`
| Send a rail camera on from its stop.
| `entity` (entity)
|
| `playAnimation`
| Play a model's clip, once or looping.
| `clip` (string), `entity` (entity), `loop` (boolean)
|
| `playMusic`
| Play a track, looping.
| `file` (file)
|
| `playSound`
| Play a clip, at a volume of its own (0 to 100) under the game's.
| `file` (file), `volume` (number)
|
| `push`
| Shove a body, or a ragdoll's bone, along a direction.
| `bone` (string), `entity` (entity), `x` (number), `y` (number), `z` (number)
|
| `reload`
| Fill a gun's ammo.
| `entity` (entity)
|
| `restart`
| Begin the game again from its first room.
| --
|
| `run`
| Drive a platformer left (-1) or right (1) this frame.
| `direction` (number), `entity` (entity)
|
| `saveGame`
| Keep the whole game -- room, positions, vars, inventory -- in a numbered slot.
| `slot` (number)
|
| `say`
| Show a line for a while, and wait for it. With a hud it goes in the element called say; otherwise it is drawn.
| `seconds` (number), `text` (expression)
| yes
| `setState`
| Change an instance's state.
| `entity` (entity), `state` (state)
|
| `setText`
| Change what a text instance says.
| `entity` (entity), `text` (expression)
|
| `setVar`
| Set a var on an instance, or on the game with no entity.
| `entity` (entity), `name` (string), `value` (expression)
|
| `setVerb`
| Choose the verb the next click uses.
| `verb` (string)
|
| `shake`
| Shake the camera for a moment.
| `amount` (number), `seconds` (number)
|
| `show`
| Show or hide an instance.
| `entity` (entity), `visible` (boolean)
|
| `spawn`
| Make an instance of a type at a point.
| `type` (type), `x` (number), `y` (number), `z` (number)
|
| `spawnAtPointer`
| Make an instance of a type where the player's pointer is: on the overlay in 2D, on the floor the ray meets in 3D.
| `player` (number), `type` (type)
|
| `stopMusic`
| Stop the track that is playing.
| --
|
| `submitScore`
| Send the score to the master service's board for this game, queued until it can go.
| `board` (string)
|
| `take`
| Take an item out of the inventory.
| `item` (string)
|
| `talk`
| Run a dialogue from the game's dialogues, and wait for it to end.
| `dialogue` (string)
| yes
| `timerStart`
| Start a named timer on an instance.
| `after` (number), `entity` (entity), `name` (string)
|
| `useItem`
| Choose an inventory item for the next click: "use key on ...".
| `item` (string)
|
| `wait`
| Wait some seconds before the next action.
| `seconds` (number)
| yes
| `walkTo`
| Send a walker to a point, and wait until it gets there.
| `entity` (entity), `x` (number), `y` (number), `z` (number)
| yes
| `walkToHotspot`
| Send a walker to a hotspot's walk point (the one the verb was used on, with self), and wait.
| `entity` (entity), `target` (entity)
| yes
| `walkToPointer`
| Send a walker where the player's pointer is, and wait.
| `entity` (entity), `player` (number)
| yes
|===

9
docs/images/preview.svg Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- The proofreading watermark: laid under every page of a PDF built with ./build-docs.sh
preview, and never under a release build. One word, diagonal, faint enough to read through. -->
<svg xmlns="http://www.w3.org/2000/svg" width="595" height="842" viewBox="0 0 595 842">
<text x="297" y="421" text-anchor="middle" dominant-baseline="middle"
font-family="Helvetica" font-weight="bold" font-size="150"
fill="#000000" fill-opacity="0.11"
transform="rotate(-50 297 421)">PREVIEW</text>
</svg>

After

Width:  |  Height:  |  Size: 565 B

BIN
docs/images/singeLogo.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-chooser.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-entities.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-moved.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-recoloured.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-rules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-saved.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/01-types.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/02-cave.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/02-coinType.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/02-coins.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/02-placed.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/02-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/02-rule.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/02-rules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/03-coinSpin.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/03-heroType.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/03-jumpRule.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/03-music.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/03-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/04-cleared.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/04-hitRule.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/04-placed.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/04-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/04-rules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/04-ship.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/04-types.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/05-disc.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/05-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/05-prompts.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/05-rules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/05-window.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/06-firstKey.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/06-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/06-rules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/06-tracks.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/06-types.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/07-dialogue.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/07-hall.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/07-hotspots.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/07-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/07-verbRules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/07-walkArea.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/08-hero.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/08-meshes.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/08-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/08-rules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/08-scene.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/08-viewport.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/09-hitRule.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/09-placed.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/09-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/09-rail.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/09-room.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/09-rules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/09-zombie.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/10-arcadeRules.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/10-bezel.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/10-playing.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docs/images/tutorials/10-released.png (Stored with Git LFS) Normal file

Binary file not shown.

20
docs/preview/docinfo.html Normal file
View file

@ -0,0 +1,20 @@
<!-- The proofreading watermark for the HTML books: ./build-docs.sh preview adds this to every
page's head, and a release build never does. Fixed to the window, so it is on every screen of
the document, and it lets clicks through. -->
<style>
body::before {
content: "PREVIEW";
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(-50deg);
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 22vw;
color: #000000;
opacity: 0.11;
pointer-events: none;
z-index: 1000;
white-space: nowrap;
}
</style>

14807
forge/Author.singe Normal file

File diff suppressed because it is too large Load diff

896
forge/AuthorCompile.singe Normal file
View file

@ -0,0 +1,896 @@
--[[
*
* Singe 3
* Copyright (C) 2006-2026 Scott Duensing <scott@kangaroopunch.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*
--]]
-- The compiler: a game description to a Singe game (FORGE.md).
--
-- A description is data -- types, rooms, and rules -- and what comes out is a Lua script that
-- calls the runtime in Author.singe. The rules become real functions: a condition is a Lua
-- expression, an action a statement, and a rule with an action that takes time a coroutine. The
-- description travels with the game so it can be opened again; nothing is lost in either
-- direction.
--
-- Written in Lua rather than as a util/ script because the editor is itself a Singe game and has to
-- compile what it is editing without leaving the engine. It lives with Forge rather than in Singe/
-- because only building needs it; Author.singe, the runtime a built game loads, travels with the
-- game -- a copy is written beside it when it is built -- so a game handed to someone who has never
-- installed Forge still runs.
-- Where the runtime is taken from when a game is built. Forge carries it; a game gets a copy.
AUTHOR_RUNTIME = "Forge/Author.singe"
dofile(AUTHOR_RUNTIME)
local INDENT = "\t"
-- ===== Expressions ============================================================================
--
-- A small, safe language where a number goes: numbers, strings, arithmetic, comparison, and, or,
-- not, self.var, other.var, event.field, an entity's field by name, the game's vars by name, and a
-- few functions. Anything else is a compile error naming the expression, and the lua action is
-- the way past it.
local FUNCTIONS = {
count = "authorCount",
random = "authorRandom",
distance = "authorDistance",
has = "authorHas",
abs = "math.abs",
min = "math.min",
max = "math.max",
floor = "math.floor",
time = "authorTime",
frame = "discGetFrame",
pointerX = "authorPointerX",
pointerY = "authorPointerY"
}
local NAMES = {
self = "self",
other = "other",
event = "event",
time = "authorTime()",
frame = "discGetFrame()"
}
local OPERATORS = {
["=="] = "==", ["~="] = "~=", ["!="] = "~=", ["<="] = "<=", [">="] = ">=", ["<"] = "<", [">"] = ">",
["+"] = "+", ["-"] = "-", ["*"] = "*", ["/"] = "/", ["%"] = "%", ["^"] = "^", [".."] = ".."
}
-- The keys of a table in name order, so anything written from one is written the same way each time.
local function sortedKeys(t)
local keys = {}
for key in pairs(t or {}) do
keys[#keys + 1] = key
end
table.sort(keys, function(a, b) return tostring(a) < tostring(b) end)
return keys
end
local function tokenize(text)
local tokens = {}
local at = 1
while at <= #text do
local c = text:sub(at, at)
if c:match("%s") then
at = at + 1
elseif c:match("[%d%.]") and text:sub(at):match("^%d") or text:sub(at):match("^%.%d") then
local number = text:sub(at):match("^%d*%.?%d+[eE][-+]?%d+") or text:sub(at):match("^%d*%.?%d+") or text:sub(at):match("^%d+")
tokens[#tokens + 1] = { kind = "number", value = number }
at = at + #number
elseif c:match("[%a_]") then
local name = text:sub(at):match("^[%a_][%w_]*")
tokens[#tokens + 1] = { kind = "name", value = name }
at = at + #name
elseif (c == '"') or (c == "'") then
-- A backslash escapes the next character, so a line can hold its own quote marks.
local value = {}
local scan = at + 1
while (scan <= #text) and (text:sub(scan, scan) ~= c) do
local ch = text:sub(scan, scan)
if ch == "\\" then
local escaped = text:sub(scan + 1, scan + 1)
value[#value + 1] = (escaped == "n") and "\n" or escaped
scan = scan + 2
else
value[#value + 1] = ch
scan = scan + 1
end
end
if scan > #text then
error("unterminated string in: " .. text)
end
tokens[#tokens + 1] = { kind = "string", value = table.concat(value) }
at = scan + 1
else
local two = text:sub(at, at + 1)
if OPERATORS[two] then
tokens[#tokens + 1] = { kind = "op", value = two }
at = at + 2
elseif OPERATORS[c] or c == "(" or c == ")" or c == "," or c == "." then
tokens[#tokens + 1] = { kind = "op", value = c }
at = at + 1
else
error("cannot read '" .. c .. "' in: " .. text)
end
end
end
return tokens
end
-- Recursive descent, lowest precedence first. Every level returns Lua source.
local function parser(text)
local tokens = tokenize(text)
local at = 1
local p = {}
local function peek(kind, value)
local token = tokens[at]
return token and (token.kind == kind) and ((value == nil) or (token.value == value))
end
local function take()
at = at + 1
return tokens[at - 1]
end
local function expect(kind, value)
if not peek(kind, value) then
error("expected " .. (value or kind) .. " in: " .. text)
end
return take()
end
function p.primary()
local token = take()
if token == nil then
error("expression ends early: " .. text)
end
if token.kind == "number" then
return token.value
elseif token.kind == "string" then
return string.format("%q", token.value)
elseif token.kind == "op" and token.value == "(" then
local inner = p.expression()
expect("op", ")")
return "(" .. inner .. ")"
elseif token.kind == "op" and token.value == "-" then
return "(-" .. p.unary() .. ")"
elseif token.kind == "name" then
local name = token.value
if name == "true" or name == "false" or name == "nil" then
return name
end
if name == "not" then
return "(not " .. p.unary() .. ")"
end
if peek("op", "(") then
local target = FUNCTIONS[name]
local args = {}
if target == nil then
error("no function called " .. name .. " in: " .. text)
end
take()
if not peek("op", ")") then
args[#args + 1] = p.expression()
while peek("op", ",") do
take()
args[#args + 1] = p.expression()
end
end
expect("op", ")")
return target .. "(" .. table.concat(args, ", ") .. ")"
end
if peek("op", ".") then
take()
local field = expect("name").value
if name == "event" then
return "event[" .. string.format("%q", field) .. "]"
elseif NAMES[name] and (name == "self" or name == "other") then
return "authorField(" .. name .. ", " .. string.format("%q", field) .. ")"
end
return "authorField(authorEntity(" .. string.format("%q", name) .. "), " .. string.format("%q", field) .. ")"
end
if NAMES[name] then
return NAMES[name]
end
return "AUTHOR_VARS[" .. string.format("%q", name) .. "]"
end
error("unexpected '" .. tostring(token.value) .. "' in: " .. text)
end
function p.unary()
return p.primary()
end
function p.power()
local left = p.unary()
while peek("op", "^") do
take()
left = "(" .. left .. " ^ " .. p.unary() .. ")"
end
return left
end
function p.product()
local left = p.power()
while peek("op", "*") or peek("op", "/") or peek("op", "%") do
local op = take().value
left = "(" .. left .. " " .. op .. " " .. p.power() .. ")"
end
return left
end
function p.sum()
local left = p.product()
while peek("op", "+") or peek("op", "-") or peek("op", "..") do
local op = take().value
left = "(" .. left .. " " .. op .. " " .. p.product() .. ")"
end
return left
end
function p.comparison()
local left = p.sum()
while peek("op") and OPERATORS[tokens[at].value] and tokens[at].value:match("[=<>~!]") do
local op = OPERATORS[take().value]
left = "(" .. left .. " " .. op .. " " .. p.sum() .. ")"
end
return left
end
function p.conjunction()
local left = p.comparison()
while peek("name", "and") do
take()
left = "(" .. left .. " and " .. p.comparison() .. ")"
end
return left
end
function p.expression()
local left = p.conjunction()
while peek("name", "or") do
take()
left = "(" .. left .. " or " .. p.conjunction() .. ")"
end
return left
end
local out = p.expression()
if at <= #tokens then
error("unexpected '" .. tostring(tokens[at].value) .. "' in: " .. text)
end
return out
end
-- An expression as Lua. A number or a boolean given as a value is itself.
function authorExpression(value)
if type(value) == "number" then
return tostring(value)
elseif type(value) == "boolean" then
return tostring(value)
elseif value == nil then
return "nil"
end
return parser(tostring(value))
end
-- ===== Parameters =============================================================================
--
-- A parameter's value as a Lua fragment, by the type the manifest declares for it.
local function fragment(kind, value)
if value == nil then
return nil
end
if kind == "number" or kind == "expression" then
return authorExpression(value)
elseif kind == "boolean" then
return value and "true" or "false"
elseif kind == "entity" then
if value == "self" or value == "other" then
return value
end
return "authorEntity(" .. string.format("%q", value) .. ")"
elseif kind == "scancode" then
return "SCANCODE." .. value .. ".value"
elseif kind == "switch" then
return value
elseif kind == "lua" then
return value
end
return string.format("%q", tostring(value))
end
-- A part's parameters as Lua. One the author left empty takes the manifest's default for it,
-- and one with neither becomes nil, which the checker has already pointed out.
local function fragments(entry, item)
local out = {}
for key, kind in pairs(entry.params or {}) do
local value = item[key]
if (value == nil) and entry.defaults then
value = entry.defaults[key]
end
out[key] = fragment(kind, value) or "nil"
end
return out
end
-- ===== Rules ==================================================================================
local function emitOne(set, item, what)
local name = item[1]
local entry = set[name]
if entry == nil then
debugPrint("Author: no " .. what .. " called '" .. tostring(name) .. "'; skipped")
return nil
end
return entry.emit(fragments(entry, item))
end
-- A condition list is an AND; an entry named any is an OR of what it holds, and an entry named
-- all an AND, nesting as deep as the author likes.
local function emitConditions(list)
local parts = {}
for _, item in ipairs(list or {}) do
local test = emitOne(AUTHOR.conditions, item, "condition")
if test ~= nil then
parts[#parts + 1] = test
end
end
if list and list.any then
local inner = {}
for _, item in ipairs(list.any) do
if item[1] then
local test = emitOne(AUTHOR.conditions, item, "condition")
if test then
inner[#inner + 1] = test
end
else
inner[#inner + 1] = emitConditions(item)
end
end
if #inner > 0 then
parts[#parts + 1] = "(" .. table.concat(inner, " or ") .. ")"
end
end
if list and list.all then
parts[#parts + 1] = emitConditions(list.all)
end
if #parts == 0 then
return "true"
end
return table.concat(parts, " and ")
end
local function ruleWaits(rule)
for _, item in ipairs(rule.act or {}) do
local entry = AUTHOR.actions[item[1]]
if entry and entry.waits then
return true
end
end
return false
end
local function emitRule(out, rule, index)
local event = AUTHOR.events[rule.on or "frame"]
local filter = {}
if event == nil then
debugPrint("Author: no event called '" .. tostring(rule.on) .. "'; rule " .. index .. " skipped")
return
end
for key, kind in pairs(event.filter) do
if rule[key] ~= nil then
filter[#filter + 1] = key .. " = " .. fragment(kind, rule[key])
end
end
out[#out + 1] = INDENT .. "{"
out[#out + 1] = INDENT .. INDENT .. string.format("note = %q, on = %q,", rule.note or ("rule " .. index), rule.on or "frame")
out[#out + 1] = INDENT .. INDENT .. "filter = { " .. table.concat(filter, ", ") .. " },"
out[#out + 1] = INDENT .. INDENT .. string.format("each = %s, room = %s, waits = %s, controls = %s, interrupt = %s, guarded = %s,",
rule.each and string.format("%q", rule.each) or "nil",
rule.room and string.format("%q", rule.room) or "nil",
tostring(ruleWaits(rule)),
tostring(rule.controls ~= false),
tostring(rule.interrupt == true),
tostring((rule.when ~= nil) and ((#rule.when > 0) or (rule.when.any ~= nil) or (rule.when.all ~= nil))))
out[#out + 1] = INDENT .. INDENT .. "run = function(self, other, event)"
out[#out + 1] = INDENT .. INDENT .. INDENT .. "if " .. emitConditions(rule.when) .. " then"
for _, item in ipairs(rule.act or {}) do
local statement = emitOne(AUTHOR.actions, item, "action")
if statement ~= nil then
out[#out + 1] = INDENT .. INDENT .. INDENT .. INDENT .. statement
end
end
out[#out + 1] = INDENT .. INDENT .. INDENT .. INDENT .. "return true"
out[#out + 1] = INDENT .. INDENT .. INDENT .. "end"
out[#out + 1] = INDENT .. INDENT .. INDENT .. "return false"
out[#out + 1] = INDENT .. INDENT .. "end"
out[#out + 1] = INDENT .. "},"
end
-- A dialogue: its start and its nodes; a choice's when is an expression and its act a list of
-- actions, compiled as a rule's are, with self and other absent.
local function emitDialogue(out, name, dialogue)
out[#out + 1] = INDENT .. string.format("[%q] = { start = %q, nodes = {", name, dialogue.start or "start")
-- Nodes in name order, so the same description compiles to the same text every time.
for _, nodeName in ipairs(sortedKeys(dialogue.nodes or {})) do
local node = dialogue.nodes[nodeName]
out[#out + 1] = INDENT .. INDENT .. string.format("[%q] = { name = %q, who = %s, text = %s, seconds = %s, next = %s, choices = {",
nodeName, nodeName,
node.who and string.format("%q", node.who) or "nil",
node.text and string.format("%q", node.text) or "nil",
node.seconds and tostring(node.seconds) or "nil",
node.next and string.format("%q", node.next) or "nil")
for _, choice in ipairs(node.choices or {}) do
local parts = { string.format("text = %q", choice.text or "..."), "next = " .. (choice.next and string.format("%q", choice.next) or "nil"), "once = " .. tostring(choice.once == true) }
if choice.when then
parts[#parts + 1] = "when = function() local self, other, event = nil, nil, {} return " .. emitConditions(type(choice.when) == "table" and choice.when or { { "test", expr = choice.when } }) .. " end"
end
if choice.act then
local body = {}
for _, item in ipairs(choice.act) do
local statement = emitOne(AUTHOR.actions, item, "action")
if statement then
body[#body + 1] = statement
end
end
parts[#parts + 1] = "run = function() local self, other, event = nil, nil, {} " .. table.concat(body, " ") .. " end"
end
out[#out + 1] = INDENT .. INDENT .. INDENT .. "{ " .. table.concat(parts, ", ") .. " },"
end
out[#out + 1] = INDENT .. INDENT .. "} },"
end
out[#out + 1] = INDENT .. "} },"
end
-- ===== Reading and writing a description ======================================================
--
-- The editor produces descriptions, so the format has to survive a round trip: load, change
-- nothing, save, and the result must compile to the same game.
local function literal(value)
if type(value) == "string" then
return string.format("%q", value)
end
return tostring(value)
end
local function indentOf(depth)
return string.rep(INDENT, depth)
end
-- Whether a table holds only leaves, in which case it is written on one line. A condition reads
-- far better as { "keyHeld", key = "LEFT" } than as six lines, and it is what an author typed.
local function isLeaf(t)
for _, value in pairs(t) do
if type(value) == "table" then
return false
end
end
return true
end
-- A value written back as Lua source. A condition or an action is a mixed table -- an array part
-- naming it, plus named parameters -- so both parts have to be written or the name survives and
-- the parameters do not. The array part keeps its order; the named keys are sorted, because a
-- description that reorders itself on every save makes every diff unreadable.
local function valueSource(value, depth)
local parts = {}
local keys = {}
local count = 0
if type(value) ~= "table" then
return literal(value)
end
count = #value
for _, item in ipairs(value) do
parts[#parts + 1] = valueSource(item, depth + 1)
end
for key in pairs(value) do
-- Skip the array part, which has already been written in order.
if not (type(key) == "number" and key >= 1 and key <= count and key == math.floor(key)) then
keys[#keys + 1] = key
end
end
table.sort(keys, function(a, b) return tostring(a) < tostring(b) end)
for _, key in ipairs(keys) do
local name = tostring(key)
if not name:match("^[%a_][%w_]*$") then
name = "[" .. literal(key) .. "]"
end
parts[#parts + 1] = string.format("%s = %s", name, valueSource(value[key], depth + 1))
end
if #parts == 0 then
return "{}"
end
if isLeaf(value) then
return "{ " .. table.concat(parts, ", ") .. " }"
end
return "{\n" .. indentOf(depth + 1) .. table.concat(parts, ",\n" .. indentOf(depth + 1)) .. "\n" .. indentOf(depth) .. "}"
end
function authorLoad(path)
local chunk, problem = loadfile(path)
if chunk == nil then
debugPrint("Author: cannot read " .. tostring(path) .. ": " .. tostring(problem))
return nil
end
return chunk()
end
function authorSave(game, path)
local file = assert(io.open(path, "w"))
local copy = {}
-- source says where a description came from and is set by the loader, so writing it back out
-- would make a description that had been through the editor differ from one that had not.
for key in pairs(game) do
if key ~= "source" then
copy[key] = game[key]
end
end
file:write("-- Written by Forge/AuthorCompile.singe. Edit by hand or in the editor; either is fine.\n")
file:write("return " .. valueSource(copy, 0) .. "\n")
file:close()
return path
end
function authorCopy(fromPath, toPath)
local input = io.open(fromPath, "rb")
local output
if input == nil then
return false
end
output = io.open(toPath, "wb")
if output == nil then
input:close()
return false
end
output:write(input:read("a"))
input:close()
output:close()
return true
end
-- ===== Checking ===============================================================================
--
-- What the compiler can tell an author before the game runs: a type that is not declared, a
-- condition the manifest does not have, an expression that does not parse. Returns a list of
-- messages, empty when the description is sound.
function authorCheck(game)
local problems = {}
local types = game.types or {}
local function problem(text)
problems[#problems + 1] = text
end
local function checkItems(set, list, what, where)
for _, item in ipairs(list or {}) do
local entry = set[item[1]]
if entry == nil then
problem(where .. ": no " .. what .. " called '" .. tostring(item[1]) .. "'")
else
for key, kind in pairs(entry.params) do
if (kind == "number" or kind == "expression") and (type(item[key]) == "string") then
local ok, err = pcall(parser, item[key])
if not ok then
problem(where .. ": " .. tostring(err))
end
elseif (kind == "type") and (item[key] ~= nil) and (types[item[key]] == nil) then
problem(where .. ": no type called '" .. tostring(item[key]) .. "'")
elseif (item[key] == nil) and (kind ~= "entity") and ((entry.defaults or {})[key] == nil) and not (entry.optional or {})[key] then
problem(where .. ": " .. key .. " is empty")
end
end
end
end
end
-- A field the manifest does not declare is a misspelling nine times in ten, and it is
-- otherwise silently ignored.
local function checkFields(t, declared, skip, where)
for key in pairs(t or {}) do
if (type(key) == "string") and (declared[key] == nil) and not skip[key] then
problem(where .. ": '" .. key .. "' is not something it takes")
end
end
end
for name, entityType in pairs(types) do
local look = entityType.look and AUTHOR.looks[entityType.look.kind] or nil
if entityType.look and (look == nil) then
problem("type " .. name .. ": no look called '" .. tostring(entityType.look.kind) .. "'")
elseif look then
checkFields(entityType.look, look.params, { kind = true }, "type " .. name .. "'s look")
end
for _, b in ipairs(entityType.behaviours or {}) do
local behaviour = AUTHOR.behaviours[b.kind]
if behaviour == nil then
problem("type " .. name .. ": no behaviour called '" .. tostring(b.kind) .. "'")
else
checkFields(b, behaviour.params, { kind = true }, "type " .. name .. "'s " .. b.kind)
end
end
checkFields(entityType, { look = true, vars = true, behaviours = true }, {}, "type " .. name)
end
if #(game.rooms or {}) == 0 then
problem("the game has no rooms")
end
for _, room in ipairs(game.rooms or {}) do
for _, entry in ipairs(room.entities or {}) do
if types[entry.type] == nil then
problem("room " .. tostring(room.name) .. ": no type called '" .. tostring(entry.type) .. "'")
end
end
-- A waves track's keys name a type, and are at a moment -- or at a stop, when keyed by one.
for _, track in ipairs(room.tracks or {}) do
for index, key in ipairs(track.spawns or {}) do
local where = "room " .. tostring(room.name) .. ", track " .. tostring(track.name) .. ", wave " .. index
if types[key.type] == nil then
problem(where .. ": no type called '" .. tostring(key.type) .. "'")
end
if (track.key == "stop") and (type(key.at) ~= "string") then
problem(where .. ": at should name a stop")
elseif (track.key ~= "stop") and (type(key.at) ~= "number") then
problem(where .. ": at should be a number")
end
end
end
end
for index, rule in ipairs(game.rules or {}) do
local where = "rule " .. index .. " (" .. tostring(rule.note or "") .. ")"
if rule.on and (AUTHOR.events[rule.on] == nil) then
problem(where .. ": no event called '" .. tostring(rule.on) .. "'")
elseif AUTHOR.events[rule.on or "frame"] then
checkFields(rule, AUTHOR.events[rule.on or "frame"].filter, { note = true, on = true, each = true, room = true, when = true, act = true, controls = true, interrupt = true }, where)
end
if rule.each and (types[rule.each] == nil) then
problem(where .. ": no type called '" .. tostring(rule.each) .. "'")
end
checkItems(AUTHOR.conditions, rule.when, "condition", where)
checkItems(AUTHOR.conditions, rule.when and rule.when.any, "condition", where)
checkItems(AUTHOR.actions, rule.act, "action", where)
end
return problems
end
-- ===== The whole game =========================================================================
-- The whole game, as source. Returns a string; the caller decides where it goes.
--
-- Every built game loads the runtime sitting beside it. There is no other copy to load: nothing
-- of Forge ships inside Singe, so Author.singe travels with the game that needs it. Framework is
-- the engine's, as it is for every game ever written for Singe.
function authorCompile(game)
local out = {}
local data = {}
for key, value in pairs(game) do
if (key ~= "rules") and (key ~= "source") and (key ~= "dialogues") then
data[key] = value
end
end
-- A type's empty vars table says nothing the runtime does not assume; left out, so a
-- description that has one and one that has none compile the same.
if game.types then
data.types = {}
for name, entityType in pairs(game.types) do
local copy = {}
for key, value in pairs(entityType) do
if not ((key == "vars") and (type(value) == "table") and (next(value) == nil)) then
copy[key] = value
end
end
data.types[name] = copy
end
end
out[#out + 1] = "-- Generated by Forge/AuthorCompile.singe from " .. (game.source or "a game description")
out[#out + 1] = "-- " .. (game.title or "Untitled")
out[#out + 1] = "--"
out[#out + 1] = "-- This is an ordinary Singe game and can be edited by hand. Doing so and then"
out[#out + 1] = "-- recompiling the description will overwrite it, so keep one or the other."
out[#out + 1] = ""
out[#out + 1] = 'dofile("Singe/Framework.singe")'
-- The game finds its own directory rather than trusting DIR. Framework sets DIR from the
-- script the *engine was launched with*, which is this file only when the game is played
-- directly; a game reached by dofile -- a test, a launcher, a menu that previews it -- would
-- otherwise look for its runtime beside the caller and not find it. debug.getinfo names the
-- chunk actually running, either way.
out[#out + 1] = 'local here = ((debug.getinfo(1, "S").source:gsub("^@", "")):match("^(.*[/\\\\])") or "")'
out[#out + 1] = 'dofile(here .. "Author.singe")'
out[#out + 1] = "AUTHOR_DIR = here -- Files the description names are looked for here first."
-- A description built where it lives -- a port beside its game's own files, a test -- names
-- files beside itself, which is not where the built script sits; they are looked for there
-- second. A released game has them beside the script, and a packed one inside the pack.
local sourceDir = game.source and string.match(game.source, "^(.*[/\\])") or ""
if sourceDir ~= "" then
out[#out + 1] = "AUTHOR_SOURCE_DIR = " .. string.format("%q", sourceDir) .. " -- Then beside the description this was built from."
end
if game.vocabulary then
out[#out + 1] = "authorVocabulary(" .. string.format("%q", game.vocabulary) .. ") -- The game's own looks, behaviours, conditions, and actions."
end
out[#out + 1] = ""
out[#out + 1] = "-- The description, as the runtime wants it: everything but the rules, which follow as code."
out[#out + 1] = "authorBegin(" .. valueSource(data, 0) .. ")"
out[#out + 1] = ""
out[#out + 1] = "-- The rules. Each is a trigger, its filter, and a function that tests the conditions and"
out[#out + 1] = "-- does the actions; one with an action that waits runs as a coroutine."
out[#out + 1] = "authorRules({"
for index, rule in ipairs(game.rules or {}) do
emitRule(out, rule, index)
end
out[#out + 1] = "})"
out[#out + 1] = ""
if game.dialogues then
out[#out + 1] = "-- The dialogues: nodes of a line and choices, each choice's condition and actions as code."
out[#out + 1] = "authorDialogues({"
for _, name in ipairs(sortedKeys(game.dialogues)) do
emitDialogue(out, name, game.dialogues[name])
end
out[#out + 1] = "})"
out[#out + 1] = ""
end
out[#out + 1] = "onKeyPressed = authorKeyDown"
out[#out + 1] = "onKeyReleased = authorKeyUp"
out[#out + 1] = "onInputPressed = authorSwitchDown"
out[#out + 1] = "onInputReleased = authorSwitchUp"
out[#out + 1] = "onMouseMoved = authorMouseMoved"
out[#out + 1] = "onCollision = authorCollision"
out[#out + 1] = "onTrigger = authorTrigger"
out[#out + 1] = "onNavArrived = authorNavArrived"
out[#out + 1] = "onMidiMessage = authorMidi"
out[#out + 1] = "onSoundCompleted = authorSoundDone"
out[#out + 1] = ""
out[#out + 1] = "function onOverlayUpdate()"
out[#out + 1] = INDENT .. "authorFrame()"
out[#out + 1] = ""
out[#out + 1] = INDENT .. "return OVERLAY_UPDATED"
out[#out + 1] = "end"
out[#out + 1] = ""
return table.concat(out, "\n")
end
local function directoryOf(path)
return (string.match(path, "^(.*[/\\])") or "")
end
-- Compiles a description file to a game beside it, with the runtime beside that, because that is
-- what the result loads. Returns the path written.
function authorBuild(descriptionFile, outputFile)
local chunk = assert(loadfile(descriptionFile))
local game = chunk()
local file
game.source = descriptionFile
-- The game's own vocabulary, before the checker reads the manifest.
if game.vocabulary then
authorVocabulary(game.vocabulary, string.match(descriptionFile, "^(.*[/\\])") or "")
end
for _, problem in ipairs(authorCheck(game)) do
debugPrint("Author: " .. problem)
end
file = assert(io.open(outputFile, "w"))
file:write(authorCompile(game))
file:close()
authorCopy(AUTHOR_RUNTIME, directoryOf(outputFile) .. "Author.singe")
return outputFile
end

63
forge/Forge.rml Normal file
View file

@ -0,0 +1,63 @@
<rml>
<!--
Singe 3
Copyright (C) 2026 Scott Duensing <scott@kangaroopunch.com>
Forge's chrome. Only the panels are RmlUi; the canvas beside them is drawn
into the overlay, because that is where Singe already tracks a pointer against rectangles.
pointer-events keeps the canvas clickable through the document.
Licensed under the GNU General Public License, version 3 or later.
-->
<head>
<title>forge</title>
<link type="text/rcss" href="Singe/gui.rcss"/>
<style>
/* The body is the whole overlay, so the panel's 100% is a height: without it the panel
was nothing tall, everything in it overflow, and overflow: auto on it hid it all. */
body { pointer-events: none; width: 100%; height: 100%; font-family: FreeSans; font-size: 13px; color: #e6e6ee; }
/* Rows stay focusable: RmlUi delivers a click to the nearest focusable element under the
pointer, so a row that could not take focus could not be clicked either. ENTER and SPACE
on a focused element only become a click when its tab-index is auto, and no row's is. */
/* The panel is a column: the grip and the title, then the list and the fields box, which
share what is left and each scroll (the wheel, or the bar) rather than pushing the other
off the screen. */
#panel { pointer-events: auto; position: absolute; left: 0px; top: 0px; width: 190px; height: 100%; background-color: #161620ff; display: flex; flex-direction: column; }
#grip, #title { flex: 0 0 auto; }
#list { flex: 0 1 auto; min-height: 0px; overflow-y: auto; }
scrollbarvertical { width: 5px; }
scrollbarvertical slidertrack { background-color: #1b1b28ff; }
scrollbarvertical sliderbar { background-color: #6a5a9aff; }
#grip { pointer-events: auto; background-color: #2a2a3cff; padding: 6px 10px; color: #ffcf4a; font-size: 15px; }
#grip:hover { background-color: #3a3a52ff; }
#title { margin: 0px 10px 8px 10px; color: #9aa0b4; }
.row { margin: 2px 8px; padding: 4px 6px; background-color: #242433ff; }
.row:hover { background-color: #32324aff; }
.row.selected { background-color: #c03c96ff; color: #ffffff; }
.thumb { display: inline-block; vertical-align: middle; margin-right: 6px; width: 24px; text-align: center; color: #ffcf4a; }
.thumb.dim { color: #6a6a80; }
.thumb.swatch { height: 16px; width: 16px; margin-left: 4px; margin-right: 10px; }
.part { margin: 1px 8px 1px 18px; padding: 2px 5px; background-color: #1b1b28ff; color: #aeb4c8; font-size: 12px; }
.part:hover { background-color: #2a2a40ff; color: #e6e6ee; }
.picked { background-color: #6a5a9aff; color: #ffffff; }
#title:hover { color: #ffcf4a; }
.part.here { background-color: #4a3a6aff; color: #ffffff; }
/* A field's list, unfolded under its row and floating over the rows beneath, as a dropdown
does: absolute with no top or left takes the place it would have had in the flow. */
.drop { position: absolute; z-index: 2; clip: none; width: 140px; margin: 0px 0px 0px 26px; padding: 2px 0px; background-color: #0b0b12ff; border-width: 1px; border-color: #6a5a9aff; }
.choice { margin: 0px; padding: 2px 8px; color: #aeb4c8; font-size: 12px; }
.choice:hover { background-color: #32324aff; color: #e6e6ee; }
.choice.selected { background-color: #c03c96ff; color: #ffffff; }
.choice.more { color: #6a6a80; }
.choice.more:hover { background-color: #0b0b12ff; color: #6a6a80; }
#detail { flex: 0 1 auto; min-height: 0px; overflow-y: auto; margin: 14px 8px; padding: 6px; background-color: #10101aff; color: #b9bfd4; }
</style>
</head>
<body id="forge">
<div id="panel">
<div id="grip">&#8801; Entities</div>
<div id="title"></div>
<div id="list"></div>
<div id="detail"></div>
</div>
</body>
</rml>

5248
forge/Forge.singe Normal file

File diff suppressed because it is too large Load diff

26
forge/games.dat Normal file
View file

@ -0,0 +1,26 @@
-- Forge appears in the menu like anything else, so it is reached the same way a game is and packs
-- to Forge.game with -P. It needs no disc of its own; the menu background stands in, because the
-- engine wants a video and Forge draws over all of it anyway.
GAMES = {
{
TITLE = "Forge",
SCRIPT = "Forge/Forge.singe",
REQUIRES = { "GUI" },
LEGACY_SPRITE_ARGS = false,
VIDEO = "Singe/menuBackground.mkv",
STRETCH = false,
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = "",
ATTRACT = "Singe/menuBackground.mkv",
ATTRACT_START = 180,
ATTRACT_END = 359,
YEAR = 2026,
PLATFORM = "Singe",
DEVELOPER = "Kangaroo Punch Studios",
PUBLISHER = "Kangaroo Punch Studios",
GENRE = "Tool",
DESCRIPTION = "Build a game by describing it: place things, write rules, press play. Forge writes ordinary Singe Lua, so nothing it makes is locked inside it."
}
}

8
forge/kit/LICENSE Normal file
View file

@ -0,0 +1,8 @@
The Forge tutorial kit.
Everything here except fox.glb was drawn or synthesised by util/forgeKit.py in the
Singe source tree and is released under CC0: use it in your own games as you like.
fox.glb is the Fox from the Khronos glTF sample models, CC-BY 4.0: model by PixelMannen,
rigging and animation by tomkranis, glTF conversion by AsoboStudio and scurest.
A game that ships it should carry this credit.

11
forge/kit/README.txt Normal file
View file

@ -0,0 +1,11 @@
The Forge tutorial kit, addressed from a game as Forge/kit/<name>.
hero.png a sprite sheet, 8 columns of 32 x 48, facing right: idle, walk x4, jump, fall, hit
enemy.png a sheet, 4 columns of 32 x 32, flapping
tiles.png a tile sheet, 4 columns of 32 x 32: grass, dirt, stone, brick
coin.png key.png crate.png door.png spike.png ship.png shot.png rock.png target.png stills
yard.png hall.png painted rooms, 720 x 480, for the adventures
jump.wav coin.wav shot.wav hit.wav click.wav door.wav clips
loop.ogg eight seconds of music that loops
clip.mkv twelve seconds of 720 x 480 video at 24 frames a second: a door opens at 3 s, a target rises at 6 s, a hand reaches at 9 s
fox.glb an animated model (see LICENSE)

BIN
forge/kit/click.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/clip.mkv (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/coin.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/coin.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/crate.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/door.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/door.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/enemy.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/fox.glb (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/hall.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/hero.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/hit.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/jump.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/key.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/loop.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/rock.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/ship.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/shot.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/shot.wav (Stored with Git LFS) Normal file

Binary file not shown.

BIN
forge/kit/spike.png (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more