A new way to create CYOA and export them to various formats

I’m developping a system for creating documentations in LaTeX (can be exported to PDF) and HTML.

It’s using a very conveniant lightweight language markup called txt2tags.

It’s very easy to use:

for example a chapter will be like this:

== 45 ==

Write your description below, and then, to create a choice, write this:

- Description of the choice, and a number at the end: 21

That’s all.

I’ve adapted it so we can create CYOA games (with hypertext), and export them to several formats :

  • PDF (so you can print / publish them)
  • HTML, for web browsers. It can also use the RAMUS alternative rendering, see: felix.plesoianu.ro/index.php/page:Software:Ramus
  • EPUB, for ebook readers
  • HYENA and RENPY, specialised in CYOA and visual novels (the first one is used in project AON, the Lone Wolf CYOA)
  • And now it can create Inform7 code, with the help of the extension Adventure Book by Edward Griffiths

A sample game (used in the Indigo Speedif contest):
ifiction.free.fr/parchment/parch … e_death.z5

The Ramus HTML export to compare:
anamnese.online.fr/site2/textall … ramus.html

(the other ones are there: anamnese.online.fr/site2/textall … lue_death/)

The presentation on ifwiki: ifwiki.org/index.php/Textallion

Looking good, but wouldn’t it make more sense to have the author input labels rather than numbers, and generate the numbers from the labels automatically? (In the way that LaTeX handles all its references.) I.e., something like:

[code]== airfield ==

  • You buy the 20$ ticket for the local airline with the drunk pilot. [plane crash]
  • You buy the 120$ ticket for the international airline. [safe landing]

== plane crash ==

== safe landing ==
…[/code]
I have never written CYOA, but keeping track of those numbers would seem rather irritating to me.

Yes it’s possible. Yet, at the moment, if you do this, you’ll have problem to export into some of the output formats, so you have to use numbers because it’s easier to track down numbers instead of letters, which can be either words or sentences. For example in the txt2tags syntax, [plane crash] would display “plane”, and link to “crash”, while [plane crash #planecrash] would be better (and link to the #planecrash anchor, which can be reached by creating a ==Plane crash==[planecrash] heading).

Traditionally, CYOA where written using numbers as chapters, but if several people request it, I’ll try to make it more friendly for using keywords instead, even if it’s still possible at the moment (but you’ll be stuck to HTML).

This looks pretty awesome. It’d be cool to see an exporter to ChoiceScript and Undum.

choiceofgames.com/blog/choicescript-intro/
undum.com/

I got the impression Victor just meant your preprocessor should track the symbolic names and replace them by random node numbers automatically.

I’ve created a new project, based on the same source document from “textallion”.

Now you can edit and review your CYOA online (using php):

You can test and download this there: cyoa.hostzi.com

When clicking on the “edit” link, it will lead to the editor. You can access it with this password: “ldvelh” (it means cyoa in French…)

Now textallion can export to ChoiceScript (which was often requested) and Twee (Twine). So now with only 1 syntax (one single source) you can export to at least 8 different formats!

Undum seems complicated so I don’t think I’ll ever be able to export to this format, but the Ramus format is very close visually to the Undum effects.

Some samples on anamnese.online.fr/site2/textall … lue_death/

The latest exports are only in the devel version on code.google.com/p/textallion/, it’s not released as an archive yet.

If you can export to Ramus, you can certainly export to Undum. (You probably won’t support all of Undum’s features, but that’s a different matter.)

I don’t really see how I can do this, because as far as I can see, Undum is using a mix of html and js to produce the output, which is very verbose in comparison to other fomats. So I should export from one source to several files, it’s probably possible but quite difficult.

You can embed JavaScript code to an HTML file so you only need one file. I can make a sample file you can use as a template, if you’re interested.

yes, I’d check it gladly!

Here’s a couple of first pages of the example story implemented in Undum. You only need to edit the HTML file, but you need the media directory for the libraries (but you don’t need to edit anything there). Let me know how it looks like!
undum_template.zip (520 KB)

thank you for the template. I’ve begun to adapt it for Undum, but it’s much more difficult than for other systems.

thank you again Juhana, thanks to your template, I finally managed to make the export to undum too. It’s quite rough at the moment : no picture, no closing </ ul >, no automatically update of the title and author, some code are not detected at the moment (only pure cyoa with number are detected), but it’s basically working:

anamnese.online.fr/site2/textall … undum.html

i’ve updated my mercurial repository, and I’ll release a new version of textallion soon.

I’ve updated Textallion with new exports and features since this last post. Among them:

  • fixed many things in the twee (twine) export so it will work with named chapters
  • now it can export to the Ink (used in Inkle projects). So it should be possible to use it for Unity projects.

You can test the new Inkle version there: anamnese.online.fr/site2/textall … lue_death/

windows

[code]cd samples_cyoa
make cyoa-choicescript

for use with http://www.choiceofgames.com/

specifications: http://www.choiceofgames.com/make-your-own-games/choicescript-intro/

rm -fr the_blue_death_choicescript
mkdir -p the_blue_death_choicescript/media/
cp -fr …//templates/choicescript/* the_blue_death_choicescript
sed “s/ChoiceScript Game/sed q the_blue_death.t2t/” …//templates/choicescript/mygame/index.html > the_blue_death_choicescript/mygame/index.html
sed “s/ChoiceScript Game/sed q the_blue_death.t2t/” …//templates/choicescript/mygame/index_fr.html > the_blue_death_choicescript/mygame/index_fr.html
printf “comment Made using ChoiceScript and Textallion.\n" > the_blue_death_choicescript/mygame/scenes/textallion.txt
#printf "Welcome \n
page_break\n” > choicescript/mygame/scenes/textallion.txt
cat the_blue_death.t2t | perl -pe ‘s/^%(.)\n//’ | perl -pe 's/^%(.)\n//’ |
#sed can’t replace multiple newlines. So we remove them, and add them back later.
perl -pe ‘s/\n/NEWLINE/g’ |
perl -pe ‘s/NEWLINENEWLINE- /\n\nchoice\n- /g’ |
perl -pe ‘s/NEWLINE/\n/g’ |
perl -pe 's/(\d+)\n/\1\n\t\t
goto \1\n/’ |
perl -pe ‘s/- /\t# \1/’ |
perl -pe ‘s/== (\d+) ==/\nlabel \1\n[b]\1[/b]/g’ |
perl -pe 's/==(\d+)==[(.
)]/*label \1\n[b]\1[/b]/g’ |
perl -pe ‘s/==(\d+)==/*label \1\n[b]\1[/b]/g’ |\

end of game |\

perl -pe ‘s/FIN/FIN\nending/’ |
perl -pe 's/THE END/THE END\n
ending/’ |\

remove extra textallion syntax |\

perl -pe ‘s/TESTLUCK/[i]Am I lucky today? (throwing a dice, 5 or 6 means luck)[/i]/’|
perl -pe ‘s/¯/ /g’ |
perl -pe ‘s/[ ]{.{4}}[ ]//g’ |
perl -pe ‘s/[ ]{.{3}}[ ]//g’ |
perl -pe ‘s|//(.)//|[i]\1[/i]|’ |
perl -pe 's/[[(.
).jpg] 1]/image \1.jpg/’ |
perl -pe 's/[[(.
).png] 1]/image \1.jpg/’ |
perl -pe 's/[(.
).jpg]/image \1.jpg/’ |
perl -pe 's/[(.
).jpg]/image \1.jpg/’ |
perl -pe ‘s/…/media///’ |
perl -pe 's/[(.
).ogg]//’ |
perl -pe ‘s/rdv/rendez-vous/’ >> the_blue_death_choicescript/mygame/scenes/textallion.txt
Operator or semicolon missing before *label at -e line 1.
Ambiguous use of * resolved as operator * at -e line 1.
Backslash found where operator expected at -e line 1, near "label "
(Do you need to predeclare label?)
Backslash found where operator expected at -e line 1, near “1”
(Missing operator before ?)
Backslash found where operator expected at -e line 1, near “n”
Backslash found where operator expected at -e line 1, near “b”
Backslash found where operator expected at -e line 1, near “]”
(Missing operator before ?)
Backslash found where operator expected at -e line 1, near “1”
(Missing operator before ?)
syntax error at -e line 1, near "label "
Missing right curly or square bracket at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
cp .jpg the_blue_death_choicescript/mygame/
cp .png the_blue_death_choicescript/mygame/
cp …/media/
.jpg the_blue_death_choicescript/mygame/
cp …/media/
.png the_blue_death_choicescript/mygame/[/code]

[code]perl -version

This is perl 5, version 20, subversion 2 (v5.20.2) built for MSWin32-x86-multi-thread-64int
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2015, Larry Wall

Binary build 2002 [299195] provided by ActiveState http://www.ActiveState.com
Built Jul 20 2015 13:29:53
[/code]

Do you have a support for DVI, ZILF, and TAVERN?

@jkj yuio: I’ll have a look at the windows installer which hasn’t been updated for a while. It shouldn’t do that. Have you edited the sample game?

@zzo38:
for ZILF, if I’m not mistaken, it’s a different compiler than the Inform one. At the moment if I remember well, the Inform6 version is not finished, but the Inform7 works (I should include it in the showcase). Someone made a template for Inform6, but I don’t know if it will be easy to generate inform6 code from the textallion syntax. I7 is easier in this aspect. It’s on my todo list, because it’s indeed very cool to be able to create simple CYOA games for the Atari ST, Amiga ou C64! For ZILF, I don’t know anything about the ZIL language, but if someone helps to create an exporter, why not!

For DVI, do you mean the “Device independent file format”, used with TeX? I’m using pdflatex, so it doesn’t use DVI, it converts directly from .tex to .pdf.

For TAVERN, I see it’s a project of your (zzo38computer.org/fossil/tavern.ui/dir?ci=tip). I’ve had a quick look at it. If you think it would be possible to generate a simple source code for your system, I’ll add it gladly.

Bear in mind (probably you’ve already discovered it), Textallion stories don’t use objects, they only use “pages” or “chapters”. So it’s only a list of choices, there is no elements such as weapons and such. At the moment there is even no variables, because hey you can’t use them when you export to a printed book or an ePUB, the main target for textallion. Yet I want to add some kind of support for randomness, variables and such because they can be used in twine, inkle etc. The main problem is txt2tags (the parser and generator for textallion) is not able to deal with random numbers and data. I’m looking for a way to implement it in txt2tags first.

I agree that variables and so on should be added, even though in some cases it can’t work (those feature are only for some output formats, not for all formats; same with some other features).

I could try to figure out and make my own implementation of the converting into DVI (using either Plain TeX or writing a program to do making DVI directly), as well as TAVERN. (However I would use a JavaScript implementation of txt2tags if exists, but I think it doesn’t exists)

Also, in the install script why the capitalization of “Textallion” is inconsistent?

I can also to help with stuff converting to DVI and/or TAVERN if you do working too and so do I, even if other file is needed possibly

there is a js implementation of txt2tags, but obviously it only outputs to… html! github.com/farvardin/txt2tagsjs and like everything I do it’s more a quick hack rather than a real clean implementation.

It would be great to have more txt2tags parsers. For js, if it would support all the txt2tags (python) version, it could be useful for nodejs stuff.

I’m using txt2tags for the html and pdf outputs. For the other exports (twine, inkle, renpy, inform7 and such), it’s only perl regex into the makefile which do the conversions. I’m not against DVI, but what is the advantage of it over PDF? At the moment I can’t just compile to dvi using “latex output.tex” from what I get from textallion, because it’s supposed to use pdflatex.

However, if you create a sample file for using latex instead of pdflatex, I’ll add it gladly to textallion. It shouldn’t be difficult, just look into the “templates” folder.

Btw I’ve just edited my output.tex and removed the “\usepackage[pdftex]{graphicx}” line, and now I get a output.dvi file. There are still some errors, but it mostly works.

Hmm, now I see there are still some errors in the PDF output as well, I’ll have a look tomorrow.

no reason, first I wrote it TeXtallion because it is using TeX, but now I think it goes beyond that, so it’s just “textallion” (or Textallion). I should unify this.

For the TAVERN output, I find it interesting for this reason: as I said in another thread, I enjoy exotic and old systems, so if there is a way to compile the tavern parser to old 16 and 8 bit systems, I’m for it. Could you show me the source code of a simple and working choice based adventure for TAVERN?

Do you think it could be possible to compile TAVERN without relying on gcc? For example I’ve tried yesterday to compile fweep for the Atari ST, and the “pure c” compiler doesn’t work. I’ve cross compiled it for the MiNT unix system (which runs on Atari machines) and it works for it (here is a screenshot lut.im/0aK6RWemZo/kMC5U2pHCaXO0axY.png ). Yet it should be possible to output from the cross compiler to pure ST, I’m still looking for that.