This is web UI to play games written in a "scripting" language I created to make text game creation easier and faster.
The scripting language includes conditional statements, variables, ways to get game values and more.
A C++ application is constantly running on the server side, managing games. A nodejs server acts as a bridge between the C++ program and the client using web sockets.
This is a program that simplifies making text based games
'Storylines' are essentially functions. Each place, or storyline has a name. These names are text surrounded by semicolons Example: ;1;. The storyline tells the game where to go, and which parts of the game to read when.
To declare a storyline, just put the storyline name on a line in the game.txt file, and make sure to end it with 'end'
;1; info: You are at storyline ;1; end
The info declaration is the text that is read out to the player. In-game, this would look like:
You are at storyline ;1;
One of the things that you can add to storylines is options.
Options are declared by option: (text), and give users a choice of what storyline to go to next. If an option line if found, The game will prompt users for an option number to go to. Option numbers are decided by the order that the options are found in; if there are 2 options, the first option is option 1 and the second is option 2
If not otherwise specified, when an option is chosen, the option number is added to the current story. For example, if the storyline is ;1; and option 1 is chosen, the storyline becomes ;1.1;
;1; info: You are at storyline ;1; option: go to storyline ;1.1; end ;1.1; info: You are at storyline ;1; end
Conditional statements can be placed in the base of a storyline, and code is only evaluated if their condition is satisfied. Conditionals must end with an endif. Macros (part 5) are evaluated before conditions.
Note: Options are ended if a conditional is found
Boolean logic can also be applied to if statements. "&" is used for and, "|" for or, "==" to compare, and "!" to negate. Other comparators are "<=", ">=", "==", "!=", "<", and ">"
List of conditions that can be checked with explanations, syntax and examples:
if: (var(potatoquestion == true) & !var(crackerquest == NULL)) option: Tell cracker64 you have the potatoes for him. goto: ;cracker.givepotato; endif
Conditions are evaluated recursively, allowing nested conditions.
Actions are placed within a storyline. They can be placed after an option line to only be ran when that option is chosen, or they can be placed alone in a storyline to be ran when the storyline is read.
List of actions with explanation, syntax and examples:
This ends the game with a message to the user
This can be used to send the player to a certain storyline in the game
This is used to give the player an item. Items modifiers are '+', '-', '/', '*', '='
This randomly goes to one of the storylines provided. You can provide any number of storylines to choose from
Makes the player lose health. If the player dies, a message is shown. Health modifiers are '+', '-', '='
create / set a variable that can be used later.
Include a file
There are a few simple macros that can be used in the option line, and the action lines. When the line is read in macros are replaced with the value that they lead to
List of macros with explanation and example:
Returns item amount
Returns current storyline number
Returns current health
Returns value of a variable. Undefined variables will return NULL
Returns result of calculation
Returns integer value of number
include statements can go anywhere, and once they are reached their file is loaded. They allow you to 'include' other text files, meaning that they are added to the files that the interpreter searches when looking for story lines and options.
;126.96.36.199; info: He gives you a link to the script. option: Run script info: -1 SESSION_ID option: Ask how to run the script option: Ask what LUA is info: You ask mniip about LUA. He is so enraged that you spelled the language of the gods incorrectly that he hacks freenode and bans you from every channel. He then comes to your house, shoots your family, and burns your house down. info: -1 family$(ENDL)-1 house endgame: You learn IRC is a horrible place with many haters and never join again. You live a lonely life with no friends. endoption end ;188.8.131.52.1; info: You run the script. TPT closes. You aren't sure why. option: Continue back to #powder goto: ;1.2; endoption end
When a game is loaded, the interpreter reads through the given game script file and parses it, moving all the data to objects in memory. This allows files to be loaded both at load time and runtime.
The interpreter was made in C++. It can load games and have multiple games running at once. The interpreter uses an instance of the class GameController to store every game session. In this class the player data, variables, and all the storylines are stored.
Each storyline is an object which contains an array of options, and an array of commands to be run when the storyline is called. Inside of each of these options is another array of commands to be run of the option is chosen.