Pezna Story Engine - A tool for creating non-linear, complex stories for games.


http://pezna.com/story-engine/images/romeo-juliet.png

A PSE story called "The Concise Tragedy of Romeo and Juliet

When creating a game with a story, creating and implementing the dialogue into the game can be very tedious. This was a problem I faced when I wanted to make a game with branching dialogues that could alter the course of the story depending on the player’s choices.

I searched for tools that could do what I needed, but they always fell into these categories:

  • Crappy - Did not have as many features as I needed.
  • Overkill- Was too expensive and had many features, but not the features I needed.
  • Tedious- Repetitive dragging and dropping and clicking, constantly moving the mouse to click buttons and menus, etc.

There was no program that fell into just one category; each met at least two categories. The only reasonable thing to do was to build my own. Thus, Pezna Story Engine was born.


http://pezna.com/story-engine/images/test-story.png

A portion of a story file that was used to rigorously test PSE.

I needed a program that would let me create characters, variables, choices for the player, and dialogue branching. I needed the program to be like a text editor that I could simply start writing in, and not have to painstakingly drag, and drop, and click, and arrange. In some of the programs that I found, by the time you finish clicking, dragging, and arranging, you’ve forgotten important details about the story you want to write. If your mind is anything like mine, you can get a dozen different ideas a day, and when trying to flesh out an idea, a bad user experience is not ideal. For the amount of flexibility and customisability that I needed, I had to create my own scripting language.

That is essentially what Pezna Story Engine is, a tool that interprets a simple scripting language designed for creating non-linear, complex stories for games.

Created with non-programmers in mind, it is extremely straightforward and easy to learn.

For the list of current and planned features, please visit the features page. PSE is still under development, and has not been released yet because there are many features that still need to be added.

I will talk more on the syntax and structure of a story file in later blog posts. Hopefully, I’ll be able to release a demo within a month. Please follow me on twitter @pezna_official


http://pezna.com/story-engine/images/typing_1.gif

Typing out an example story.


http://pezna.com/story-engine/images/running_1.gif

Test running the example story within PSE.

Website: http://pezna.com
Twitter: http://twitter.com/pezna_official

Very nice tool, I like the script language but how do you expect people to use it? Is there a runtime to integrate into your own game? :slight_smile:

Are the variables you can set on a character dynamic? Or are you limited to a subset specified by you? Nice work, however.

No, the character variables are not dynamic. Their type is determined by the initial value set to it.
If you give a character the property name=“James”, you can’t later set it to a number, like name=15.
Currently, there are only 4 variable types: integer, string, boolean, and character. I’m going to add a float type later on.

Yes, there will be runtimes to integrate the exported file into your game. I’m working on the Java and Python runtimes concurrently with PSE.
The thing is that I’ll need volunteers to port the Java and Python runtimes to other languages. I’ll get over that hurdle after I implement all the necessary features.

I guess h meant dynamic like “don’t need to be previously defined for a scope”, what you describe is type inference on assignment :slight_smile:

About ports: Well I could do it, unfortunately I won’t have time - have my own multi-language project running ^^

Oh, right. The variables will be dynamic. Currently, all variables are global variables. I’m planning on creating local variables for act and scene blocks in the future.

This is kinda neat. Will the entire story be in one file?

How exactly is this supposed to work? It sounds like a perfect fit for a visual novel engine, but how would I (theoretically) integrate it into one?

The entire exported story will be in one file.
But during development of the story, you will be able to split it apart into stub files. This will also enabled more than one person to work on different parts of the story at the same time.

How would you integrate it into a visual novel engine? or a game?
Either way, it will be the exact same way: with events.


# create an event variable
event show_image "default value"

#later on, trigger event
trigger show_image

# or
trigger show_image "new value"

Events are not yet available in PSE, but will be available when the demo is released.
PSE is simply designed as an engine to create the text and flow of a story. After it is exported to a JSON file, and imported into your game with the use of a runtime, you will use listeners to be alerted when an event occurs. You’ll create code to navigate through the story.

A basic story implemented in a game could be as simple as:


while (story.advance()) {
	showLine(story.getCurrentLine()); //showLine will display the line and any choices it has, it will send the selected choice back to the story.
}

Update 1 - (Website blog post)

Stack Overflow Error in Loops

Update 2 fixed this problem by implemented while-loops.
Currently, in PSE, there are no while-loops. To imitate a while loop, you would need to use an if-statement with goto and label statements. For example:

label start
if (num < 50):
    num += 1
    goto start
end if

I thought that something like this would be sufficient for everyone’s needs, but while running some tests yesterday I discovered a problem with this code:


http://pezna.com/blog/wp-content/uploads/2015/07/infinite-loop1.png

After creating and exporting a story, you load the story file into your game using a runtime library. It reads the exported file, and let’s you navigate through the story. Because of the way I created the Java library, with recursive function calls, a stack overflow error was produced after about 2000 loops. This was because it never had a chance to “return”. I then replaced the recursive function calls with a loop, but a stack overflow error now occurred after about 4000 loops. This happens because of the way “goto” statements are implemented. Explaining everything in text is going to be difficult, so I’ll just leave it at that.

To solve this problem, I’m going to have to create while-loops in PSE, so that users do not have to use gotos to make loops. I’ll still look for a way to solve the problem with if-statement loops, but if there is no practical solution, I’ll simply discourage people from making loops with ifs, labels, and gotos (at least, loops with over 4000 iterations).

New GUI

I’ve worked on the GUI a lot in the last 2 days. When compiling and running a story within PSE, a new window would appear with the Run Console. Not anymore. Now, the Run Console is below the text editor.


http://pezna.com/blog/wp-content/uploads/2015/07/entire-gui1.png

The current look of PSE’s GUI.

The panel on the left is the variable panel. It shows all the variables within the game, and their history (what values they previously held).

The panel to the right of the text editor will be the auto-generated flowchart that will help you visualize the flow of your story.

Update 2 - (Website blog post)

Events

This is something I’ve been putting on the back burner for a while, but today I decided I would finally implement this into PSE. You can use events to alert your game if an important action needs to occur. For example, if you want a transition after a line is displayed, you could do something like this:

line: person "Hello, World!"
event "transition 1"
# or, if a variable (string, number, boolean) has been initialized
# you can send its value with the event
event variableName

While-loops

The problem I had in the previous update with a stack overflow error has been fixed with the introduction of while-loops.

line: person "I will count to 10!"
while (var <= 10):
    var += 1
    line: person var+"!"
end while


http://pezna.com/blog/wp-content/uploads/2015/07/event-and-while.png

Using events and a while-loop in PSE.

What are your thoughts?

Be sure to follow me on twitter: @pezna_official

Your event should not just have a name (variablename) but also parameters, that way you could (for example) notify the game of choices made inside the the questions, to hand out items or stuff. WDYT?

syntax could be as simple as:

event varname param1 param2 param3

That’s a good idea. I’ll put it on my list of things to do.

A Tragedy Occurred

I lost everything in a hard drive crash about a month ago.
Luckily, I made backups in June 8.
However, those backups do not contain major progress that I made in the months of June and July. I have just gotten a new, crappy laptop and I’m just beginning the process of recreating what was lost. Pray for me.

Your not using a code repository like github? oO

TBH that would be a reason not to buy the software, very unprofessionell :slight_smile:

I am now, not making that mistake again. Not sure why I didn’t before.

Well I would call this Pain-Driven-Development :wink:

http://s30.postimg.org/4zb8rsccx/provoke.png

Just passing by…
I have a similar project :smiley:

Personaly i like projects like this.
even if I do not use them for self,
I like ideas that stand behind them, how they evolve and what they have become )

I’m making a full text engine plus a compiler and a language for that engine.
I plan to post in this forum soon, but I need to make the web system first. ;D
All started trying to make a text game…