TuesdayJS visual novel engine Tuesday is a free open source engine to create visual novels, interactive stories and text-based adventure games. Written in JavaScript language without using third-party libraries. There is support for the Apache Cordova framework to create native applications for mobile devices and desktops. The engine uses standard HTML document elements like div and img, which makes it possible to use almost any media format supported by browser, including vector graphics in svg format, gif animation and extensive css styling capabilities. This structure allows you to easily extend the functionality with standard html methods. This documentation describes the structure of a JSON file and the capabilities of RunTime tuesday.js without using a visual editor. Compatibility Currently, there are compatibility issues with "Internet Explorer" and partially in "Microsoft Edge" When running locally, there may be a problem with browser protection cross domain web security the solution to this problem is described below. Any current version of FrameWorks will work for porting to a mobile device: Structure The project consists of 3 main elements. Html file (index.html) with tuesday.js engine file connected to it and the history script in json file or let array. The display of the script on the html page occurs through the div element with id="tuesday". Display options can be set in css style or any other suitable way. All content will be displayed subject to the parameters of this item. The story script with all elements is specified in the format structure JSON. This format can be read by almost any other programming language or engine(which allow, if is necessary, transfer the history to another engine). Script start function load_story( 'tip', file / array ) specifying the data type (data or file) and their source (file address or array) data: specifying a variable with a script array from JavaScript code file: path to the json file with the script (may not work locally if cross domain protection is enabled in the browser) Getting started Any text editor or IDE is suitable for work Recommended software: MS Windows: Notepad++ Mac OS: Xcode The base for displaying the script consists in 3 elements Step 1 - tuesday.js Engine file It can be downloaded from GitHub. Or directly from https://kirilllive.github.io/tuesday-js/tuesday.js
Step 2 - Index.html file with id='tuesday' elements to display the novel
Step 3 - Story.json script file
Download base example Possible startup problems and solutions If the script is not displayed, then there may be a problem with the cross domain web security limitation. This can be solved in different ways. 1. decision - Move content from json file to index.html as JavaScript array
Download base example array 2. decision - Cross domain protection can be disabled in some browsers (not recommended) FireFox - in the address bar, enter about:config in the settings that appear, find the element called security.fileuri.strict_origin_policy and set it to false to disable, or true to enable. Project parameters The main parameters and settings of the entire project are set in the "parameters" section. The default appearance of the project and some functions depend of it.
AutoSave The parameter is responsible for automatic saving of the script execution progress and values from the array variables in each dialog. This will allow the continue to script from the end of the last session.
The attribute is responsible for loading autosave. "tue_load_autosave" is specified in "name" or "go_to" Buttons A set of buttons and parameters for the main interface (dialog management, saving and loading). They will not appear in the block specified in launch_story.
"name" - button identifier (analogous attribute id in html), it defines the button functionality. The names and descriptions of all available buttons can be found in the System Buttons section
Adding third party functions to buttons using javaScript,
In the "buttons" section. Add all the buttons to the interface by adding them to an array in curly brackets, with all required elements separated by commas.
Working example "buttons"
Characters Global parameters for most characteristics can be found on "name_panel". By specifying id, character identifier and parameters required for it, including localization. Also, if you specify this id in the "name" dialog parameter, then, all values for this symbol will be taken from this array. Unless the dialog itself has its own parameters set in "name_panel".
Working example "characters"
In case of character change, there is no need to make changes to the whole script, it will be enough only to make changes to this array. Languages Array of supported project languages, English "en" is set by default. At the start, the engine automatically detects the browser language and, if there is a suitable localization, it automatically switches to it. Otherwise, the default language will be English if it is available, if not then the first language in this list. Language dialect values (like en_GB and en_US) are not supported.
All language codes can be found at: "HTML Language Code Reference" Working example "languages"
Launch story Id name of the block from which the script starts (for example, the block with the main menu). If this parameter is not specified, the script will start from the first block in the list.
Name panel Panel to display the name and avatar image of the character. Its location relative to the text panel parameters text_panel
Working example "name_panel"
Text panel Basic panel settings to display texts in the scene
"dialog_speed" is the speed apparition of text in the text panel, set in milliseconds, where 0 - the text appears immediately and 1000 -is one character per second.
"indent_bottom" is the text bar's indent from the bottom of the scene is 0 by default.
Working example "text_panel"
Sounds An array of sound files used in the project. Due to the specifics of the browser support for audio formats (mpeg or ogg), you need to specify a file without an extension, the engine itself will determine the supported format .ogg or .mp3. The project can use only mp3, it can be played in almost all browsers. But in case this is not the case, it is recommended to duplicate the audio data in .ogg format with the same name and in the same folder.
Title The name of the project to display in the page tab and other headings.
Localization is supported for the specified languages in the languages options.
Key Assigning functionality to keyboard keys via key ID event.code.
load_autosave - Continue from last autosave launch_story - Go to the block specified in parameters / launch_story (main menu) next - next line back - previous line save - save script stage load - load the last stage of the script (not autosave) full_screen - puts the Tuesday element in full screen mode Working example "key"
Variables Array of variables to store data. When you save the progress of the script, this data is also saved. These values are used in script elements such as "variables" to change the value and during script, and "legacy_choice" to automatically determine the next block of the script.
Working example "variables"
Variable values can be displayed in the text_panel specifying its name in angle brackets
In this case, the phrase "You have 100 health points left" will appear. Story script The script structure is divided into various elements. The main element is a "block" that is part of a narrative or a storyline, and their sequence will be determined by the user's choices (choosing to go left or right may mean that the player continues the current plot block or move on to another block with an alternative plot development). Blocks consist of scenes with a set of graphic and sound elements. And already inside the scene, a sequence of dialogues and other elements is indicated as a choice "choice" and "go_to", which can lead to another block.
Complete plot block structure with all elements
Scene elements Background music Launches looped background music in the scene.
Localization supported
Background image Analogue of the css parameter css background_image. Designed to display the background in the scene.
By default, it is aligned to the center of the scene and proportionally fills the entire background, regardless of the size of the scene or the file itself. Supports localization if there is a background image for the specific translation.
Dialogs An array of the sequence of dialogues in the scene and its attributes such as art and selection buttons Choice.
Dialogue elements Art Also "sprite" or "image". Analogue of the html tag <img>. Designed to display graphic elements in the scene such as characters or objects.
It supports localization if there are images created for a specific translation specified in the "parameters" / "languages" section.
You can add multiple images to the scene by creating additional elements in curly brackets in the array with all the necessary parameters.
Working example "art"
Text Character dialogue or other texts in a specific scene. Also, elements to change the "text_panel" in the text.
You can simply specify a replica, in this case, all missing parameters will be taken by default from the "parameters" / "text_panel" section.
It is possible to add a localized dialogue option for the specified languages in the "parameters" / "languages" section.
The dialog box can display the values of the variable from the "parameters" / "variables". section. If you specify the name of the variable in angle brackets, then the value from the variable of the same name will appear in the text instead.
In this case, the phrase "You have 100 health points left" will appear. One location may have more or fewer lines than another. In this case, you can specify the value 'skip', then this line will be automatically skipped.
In this case, the 2nd line will be skipped in the Japanese localization. Text add Analogous to the usual "text" element, except that the text from this element is added to the already existing text in the "text_panel". Basic element for visual novels
Working example "variables"
The text bar will first show "Hello!" then the whole phrase "Hello! will you go for a walk?" Name Parameter to display the name and avatar of the character in the text panel. This data can be specified in various forms. The easiest option is just provide his name. If this name does not match the id identifier in the "parameters" / "characters" section, then the name will be displayed as specified in this parameter.
In the "parameters" / "languages" section, you can specify a localized variant of the name for other lenguages.
If you often use the same name, you can specify it in the "parameters" / "characters" section. This greatly simplifies the name change process.
Parameters for changing "name_panel" can be specified both in "dialogs" for the current line, and in the "characters" array for a specific name.
If some element is not specified, then the default value from "parameters" / "name_panel" will be taken. If the name or its ID is not specified, then this panel will not appear in the scene. Choice Buttons to select the next block of the chart and changing values in the "parameters" / "variables". Same as "buttons" except that select buttons appear on a specific line.
The "go_to" parameter transfers further narration to the specified block. If the "go_to" parameter is missing, the current block will continue. The "variables" parameters make changes to the variables at the moment the select button is pressed. Working example "choice"
Variables Parameter to change values from "parameters" / "variables" section in specific "dialogs" or when choosing "choice"
Variable operation "set" - set a value in a variable (analog of the "=" operator in JavaScript) "add" - add a value to the already specified value in a variable (analog of the "+ =" operator in JavaScript) Working example "variables"
When starting the block "Example block 1" Events An element intended for external use in JavaScript. It marks the beginning of the moment on the script where this element is indicated. tusday - creation event
JavaScript - event response
Controll Hides the interface buttons in the dialogues specified in the ( parameters / buttons ) section. After a dialog with the "controll": "hidden" parameter is set, buttons will be hidden in all subsequent dialogs until the end of the block. To display buttons you need to specify "controll": "visible".
Legacy choice Automatic transition to another block of history when the specified conditions are met in variables (parameters / variables)
Important! This element is not part of the "dialogs" array. And run as part of a block next to the "dialogs" elements.
If the conditions do not match the values in the variables, then you can specify the "go_to" parameter, in this case the history will go to the specified block.
Working example "legacy_choice"
elements parameters "art" - Analogue of css style background_image. indicates a background picture.
Localization option supported
"art_size" - Sets the size of the image inside the element, otherwise it will be displayed at its original size. By setting the size of the height and width to 100%, the size of the image will fully match the size of the button (size option). replacing one of the values with "auto", then the image size will be proportional to the size of the specified height or width
"size_text" - The size of the text inside the element
"back_to" - Jump to the specified id of the block name (previous block along the storyline) by pressing the back button (tue_back)
"className" - The analogue attribute className allows to use standard css classes specified in the "style" section of the html document.
"go_to" - Go to the block with the specified id name, or you can specify the functionality of one of the System Buttons
"style" - optional parameter (analogue attribute style in html) personal css style for this image
"sound" - Runs the specified sound, you cannot specify the file address, only the id name from "parameters" / "sounds"
Localization option supported
"sound_stop" - Stops the specified sound
"position" - The position of the element relative to the edges of the scene. For example, values [0, 10px, 10px, 0] mean that the element will appear in the upper right corner with a 10px padding.
"url" - Specifies the path to a file or other resource (analogue attribute src in html).
"size" - Is an element size. It is possible to use proportional values relative to the scene size.
"size_text" - The size of the text inside the element
"color" - The background color of an element in hexadecimal format hex (#fff #ffffff) or in rgb (255,255,255) and rgba (255,255,255,1) formats. By default, the item is transparent
"color_text" - Text color, is an optional parameter, if is not specified, the color will be the default one, the color can be set in hexadecimal format hex (#fff #ffffff) or in rgb (255,255,255) and rgba (255,255,255,1) formats.
"html" - Displaying html elements inside a tuesday element
"indent_text" - Similar to the css padding parameter, determines the amount of padding from the edges of the element. You can use multiple values according to css filling rules. For different vertical and horizontal padding "10px, 5px". If you need padding for each side or just one "16px, 5px, 5px, 5px"
"text" - text to display inside the element
Localization option supported
System button "tue_load" - Loading stage "tue_save" - Saving stage "tue_home" - Go to the main screen specified in launch_story parameters "tue_next" - The next dialogue of history "tue_back" - Previous story dialogue "tue_load_autosave" - Loading a stage from autosave "tue_fullScreen" - puts the Tuesday element in fullscreen mode Function tuesday.js load_story(tip, url) - starting a history script, the tip parameter is responsible for the type of script tip "file" if the script is in a json file and in the "url" value you need to specify the path to the file tip "data" if the script is in the let array and in the "url" value you need to specify the name of the array go_story() - moves the story forward in the plot. Automatically advances to the next block, scene, and dialogue in strict sequence. go to the next block by parameter go_to back_story() - Rolls history back. Automatically moves to the previous block, scene and dialogue strictly according to their sequence. Is a transition to the echo sounder block by parameters back_to save_stag(tip) - Saving the current state of the history state, values such as the current scene dialog and all values from the variables section in the localStorage, the "tip" parameter will mean the name of the save. If you specify a "slot" then in localStorage it will be displayed as tue_slot_data. Occupied bookmark names for manual saving and auto for automatic saving. load_stag(tip) - Loading an array of history stages. The "hint" parameter is the name of the save, a bookmark for manual saving and auto for automatic saving. Or you can use any other name that was used when using the save_stag (tip) function go_to(go) - Go to an specified history block by specifying its name in the go parameter. full_screen() - puts the Tuesday element in fullscreen mode. Events dialog_end - Completing the appearance of text in text_panel (Can be used to determine the end of a character's conversation animation.)
save - Save manually (does not work with autosave)
load - Loading a previously saved state
script_loaded - History script loaded successfully
_add - Adding or subtracting from a specific variable, variable name with "_add" appended
_set - Modify specific variable, variable name with "_set" appended
creation_dialog - Finish creating a new scene or dialogue
Plugins Touch Swipe Allows you to switch dialogs by swiping your finger across the touchscreen. Mouse not supported
Toast A small message appears for a while
Customizing CSS by Toast ID
toast (message) - shows the message, the message parameter sets the message text. Example of use in javaScript (text output to progress loading event)
An example of use in tusday. used in the parameters "dialogs", "choice" and "legacy_choice"
|