TyranoDsl
A DSL to write visual novels games in Ruby using TyranoBuilder.
TyranoBuilder is a good tool has many features like native web export but I don't like to click-heavy interface to write.
The goal is to provide a simple syntax you can use directly or you can build upon.
You create your TyranoBuilder project with the specific options and the library is used to modify the content without touching the other things.
The project is a WIP: I add things as I need them, if you have any issue or need something please ask me.
If you use it for a published VN, please tell me: it would make me happy and I'll add a link to it in this page.
Example:
declare_character 'Shinji',
'default' => 'default_stance.jpg',
'angry' => 'angry.jpg'
declare_background 'School', 'background/school.jpg'
set_title_screen_background 'School'
start_scene 'First scene'
set_background 'School'
show_character 'Shinji', 'default', 434, 128
show_message_window
display_text 'Shinji', 'Hello!'
set_character_stance 'Shinji', 'angry'
display_text nil, 'Do you want to go in the eva ?'
ask_question [
{
'text' => 'Yes!',
'left' => 200,
'top' => 200,
'scene' => 'Second scene'
},
{
'text' => 'No!',
'left' => 200,
'top' => 300,
'scene' => 'Third scene',
'label' => 'a label'
}
]
start_scene 'Second scene'How to use it
The simples use case :
- Install TyranoBuilder
- Create a project in it
- Install the gem
- Execute
tyrano-dsl dsl tyrano PATH_TO_YOUR_RUBY_CODE.rb PATH_TO_YOUR_TYRANO_PROJECTin your project directory.
PATH_TO_YOUR_TYRANO_PROJECT should look like /Users/u/Library/Application\ Support/Steam/steamapps/common/TyranoBuilder/myproject/Test
If everything is OK it should update the files in your TyranoBuilder project.
You can then reopen the project in TyranoBuilder and see the changes.
If there is an error it should be displayed and the message should help you to fix the problem.
General format
tyrano-dsl import-format export-format import-path export-path
Imports formats
-
dslthe Ruby DSL,import-pathmust be the path to the main Ruby file -
tyranoimport from a Tyrano project,import-pathmust be the path to the Tyrano project
Export formats
-
dslthe Ruby DSL,export-pathmust be the path to the directory to export to -
graphprint the game as a graph in the console in the Graphviz format so you can visualize it -
tyranoexport the game to replace the current content of the Tyrano project,export-pathmust be the path to the Tyrano project -
textprint the text content of the game in the console so you can easily proofread it, in this caseexport-pathis not used
Current vocabulary
- Background
-
declare_backgroundDeclare a background -
set_backgroundSet the background
-
- Characters
-
declare_characterDeclare a character -
hide_characterHide a character -
set_character_stanceChange the stance of a character -
show_characterShow a character
-
- Content
-
ask_questionAsk a question
-
- Jump & Labels
-
declare_labelDeclare a label -
conditional_jumpJump to somewhere if a condition is met -
jumpJump to somewhere
-
- Variables
-
declare_variableDeclare a variable -
update_variableUpdate a variable
-
- Misc
-
clear_messagesClear all messages -
hide_message_windowHide the message window -
include_fileInclude a file -
show_message_windowShow the message window -
start_sceneStart a new scene
-
Background
declare_background Declare a background
declare_background(name, images_path)
-
nameis aStringrepresenting the background's name -
images_pathis aStringindicating the path to the background images
declare_background 'School', 'background/school.jpg'
set_background Set the background
show_background(name)
-
nameis aStringrepresenting the background's name
set_background 'School'Characters
declare_character Declare a character
declare_character(name, stances)
-
nameis aStringrepresenting the character's name -
stancesis aHash{String => String}providing a list of stances with the path to their corresponding images
declare_character 'Shinji',
'default' => 'default_stance.jpg',
'angry' => 'angry.jpg'
hide_character Hide a character
hide_character(name)
-
nameis aStringrepresenting the character's name
hide_character 'Shinji'
set_character_stance Change the stance of a character
set_character_stance(name, stance)
-
nameis aStringrepresenting the character's name -
stanceis aStringdefining the stance name -
duration(optional) is anIntegerdefining the duration of the transition, default is600
set_character_stance 'Shinji', 'angry'
set_character_stance 'Shinji', 'angry', 300
show_character Show a character
show_character(name, stance, left, top)
-
nameis aStringrepresenting the character's name -
stanceis aStringdefining the stance name -
leftis anIntegerdefining the left position -
topis anIntegerdefining the top position
show_character 'Shinji', 'default', 434, 128Content
ask_question Ask a question
ask_question(possible_answers)
-
possible_answersis a list of possible answers with the corresponding target-
textis aStringrepresenting the text of the answer -
leftis anIntegerdefining the left position -
topis anIntegerdefining the top position -
sceneis aStringindicating the name of the scene to jump if the answer is selected -
label(optional) is aStringindicating the name of the label in the scene to jump if the answer is selected
-
ask_question [
{
'text' => 'Yes',
'left' => 200,
'top' => 200,
'scene' => 'Second scene'
},
{
'text' => 'No',
'left' => 200,
'top' => 300,
'scene_name' => 'Third scene',
'label_name' => 'a label'
}
]Jump & Labels
declare_label Declare a label
declare_label(name)
-
nameis aStringrepresenting the label's name
declare_label 'my label'
conditional_jump Jump to somewhere if a condition is met
conditional_jump(variable, operator, value, scene, label)
-
variableis aStringindicating the name of the variable to be tested -
operatoris aStringindicating the comparison operator to use:<,==(equal),>,!=(different) -
valueis aStringor aFloatindicating the thing to compare the variable to, it can be a numerical value or the name of another variable -
sceneis aStringindicating the name of the scene to jump to -
label(optional) is aStringindicating the name of the label in the scene to jump to
conditional_jump 'variable_1', '<', 10, 'Scene two'
conditional_jump 'variable_1', '=', 'variable_2', 'Scene two', 'Label three'
jump Jump to somewhere
jump(scene, label)
-
sceneis aStringindicating the name of the scene to jump to -
label(optional) is aStringindicating the name of the label in the scene to jump to
jump 'Scene two'
jump 'Scene two', 'Label three'Variables
declare_variable Declare a variable
declare_variable(variable_name, initial_value)
-
variable_nameis aStringrepresenting the variable name -
initial_value(optional) is aFloator aStringrepresenting the variable initial value
declare_variable 'happiness', 25
update_variable Update a variable
update_variable(variable_name, operation, value)
-
variable_nameis aStringrepresenting the variable name -
operatoris aStringindicating the operation to apply-
=set the variable with the value -
+=add the value to the variable -
-=substract the value from the variable -
*=multiply the value with the variable -
/=divide the value with the variable -
%=set the variable with the reminder of the division with the value
-
-
valueis aStringor aFloatindicating the thing to use as a value, it can be a numerical value or the name of another variable
update_variable 'happiness', '=', 25
update_variable 'happiness', '+', 'calmness'Misc
clear_messages Clear all messages
clear_messages
clear_messages
hide_message_window Hide the message window
hide_message_window
hide_message_window
include_file Include a file
include_file(file_name)
-
nameis afile_namerepresenting the file to include
include_file 'other_scene.rb'
show_message_window Show the message window
show_message_window
show_message_window
start_scene Start a new scene
start_scene(name)
-
nameis aStringrepresenting the scene's name
start_scene 'First scene'How the thing works
The tool works like a compiler:
- the first pass parse the initial version into an intermediate version
- the intermediate pass create the world and validate the content
- the last pass generate the result
- the content is applied to disk
Links
Contributing
Bug reports and pull requests are welcome on GitHub.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The code is available as open source under the terms of the MIT License.