Skip to content

How to author a new script

Jacob Karleskint edited this page Jul 30, 2013 · 6 revisions

Authoring new scripts for TurtleSim

TurtleSim is not some perfectly built game, nor is the coding solid, but it runs pretty good on just about anything I throw it on. Knowing this you can now start to learn how to author scripts for the game. The game can call for scripts to be read at any point in the game, it doesn't have to be at the press of a button on the action menu. The game is designed to run heavily off scripts so the author has much control over the flow of the plot without having to know a bunch of code.

The Script engine is constantly changing! Keep in mind you may have to learn new features as they're implemented!

Events

The first thing that you should know is that, though the game relies on scripts, the game still needs a trigger to read through a certain script. I call this an 'Event' in the game code. An Event is, as of currently, only able to be made inside the main game class. This requires you know a bit of code but not a whole lot. I will explain in full on how to create an event later on, as it is a bit detailed. But for now I'm going to explain how to author in comments that will tell a dev how to add the script into the story.

In the header of a new page in a script you should add some comments if you do not wish to learn how to add a new event to run the script. This is simply done with two forward-slashes. "//" For example, if you wish to have this certain script to be triggered by first have met Ellie, and must be between 6 and 9pm and when the player goes to eat. it will simply be:

//Title of script goes here. //if player has met Ellie //if time is between 6pm - 9pm //player is going to eat

These lines will tell another dev how to add this script into the game. The main drawback of using this method is you cannot instantly see if your script is properly configured how you wish it to run as when you compile your game there is no way of running it. BUT this will be changed in a future update where I will let you run the script direct as soon as the game starts.

How to properly setup a page in a script

When you work on a script you're actually working on individual pages. It is best described like this: page -> Script -> MasterBook A page is what holds all the dialogue and commands for the story. When you create a new script, you're actually creating a new page. Scripts are what holds all the pages (scripts are divided by characters.) This may sound a bit confusing, but the best way to know what is going on is just by knowing how to format a page. It's not hard. A page is formatted in this order "script name" then "header" then "body" then "pagebreak". I will try my best to show this:

//------------------------Meet Ellie--------------------
"ellie_meet_walking",                         //This is the name of the script.

//If time is between 7am to 9am               //these are the events that tell the dev how to add it
//If player is walking

"I find myself in a wooded area, it is vary calming to be out here.",         //the body
A great gust of wind rustles the leaves in the trees giving me a...",         //of the page

breakpage,           //this is what declares the end of the page.  breakpage

It's pretty simple really. Just follow that outline and it should keep the scripts nice and neat.

Adding dialogue to a page.

Dialogue is vary important to portray what a character feels, says, and does. So it is important you use plenty of it and try to get every detail of what is going on in any given scene as well. To add a line of Dialogue to a page is vary simple. You just write what you want the textbox to say between two "s. like this:

"I find myself deep in self thought, hating every outcome that my mind draws to",

This one line will be read in the textbox just as it shows. Please notice the comma at the end of the line. THIS IS DAMNED IMPORTANT! The Comma declares end of the line and to go on to the next. Every line of the page needs a comma, except comments.

Okay, now that you hopefully understand how to add a line, lets see on how to add Character dialogue. Lets say Ellie is talking to the player. It is done simply by this:

Ellie + "Hey! who are you? I'm Ellie!"",

Okay, so they're a couple new things in there. Big fucking deal! You declare that Ellie is talking by putting "Ellie" at the beginning, then you add "+" the dialogue. Simple, right? RIGHT. But wait, What the fuck is that cluster of fuck at the end of the line? Glad you asked. It is just a manual way of adding the " to the end of a spoken dialogue. " is an escape. You need this at the end of every spoken dialogue, or else the reader will think it is a chara thought. IT ADDS THE QUOTES IN GAME!

It adds the quote escape again, unless it wants a chara thought again.

Adding Commands to a page. Tell the chara what to do!

So far you should already know how to add lines of script to the page. So I'm just going to show the commands, how to use them, and what they do.

Make a character appear or change pose:

charaevent_show_1, "emi/emicas_happy",

Charaevents are pretty simple. These are handled in two lines. The first line tells the game that we are going to show a character in slot 1. the next line tells what character and what pose they will be doing. If you wish to change the pose of the chara, just do another charaevent_show command.

Move a character around:

charaevent_move_1, "direction",

The first line tells the game that we need to move the first chara somewhere. the second line says where. replace (direction) with either "left", "right", "offleft", "offright", or "center"

Dispose of the character (exit stage)

charaevent_exit //will dispose of all chara

or

charaevent_exit_x //will dispose of 1 or 2

This one is pretty self explanatory. where x = which character. 1 or 2

How to change the background:

bgchange, "newbackground",

first line says: hey, lets change the background. The second line say what background to change to.

play some music, or change it:

music, "nameofsong",

stop music:

music_stop,

Okay, now it is time for a couple more advance script commands. These can get a bit messy and are a bit buggy still. The first one is going to be a Fork. a Fork is a question that is asked to the player, or the player asks himself. Lets say Ellie wants to know if you will walk with her in the woods. She basically asks a yes or no question. What the player picks will split the script into two possible paths. if yes then go to page(x) if no then go to page(y). Put the breakpage right after a fork. anything after a fork is ignored.

fork,                              //declare a forked question
"Do you want to walk with me?",     //what the question will say in the textbox
"Uhh, sure.",                       //Response 1
"ellie_walk_accept",                //page to jump to if 1 is answered
"Not today, I'm sorry",             //Response 2
"ellie_walk_decline",               //page to jump to if 2 is answered

pretty easy actually. You need to create two new pages for the fork to jump to. or else the game will give a "FUCK! An error happened" debug message and halt the game resulting in a restart.

The next advance script command is pretty advanced. It requires you to add a trigger in the main game loop. I may change this to make it outside of the main loop, but time may refrain this. Welcome to Triggers. They can trigger ANY event from a script, usually following a forked question. You will need just a hint of coding knowledge to create a trigger. but I'm going to show you how to call one in the script:

trigger, "triggernamehere",

That's it! It's the easy part. Now you just need to create a trigger in the main game class. it is under the StorySwitches() function. To add a new trigger, just add a new If() statement. like this:

if (trigger == "triggernamehere") { //whatever you want it to do, probably turn a false bool to true.` }

It's not too hard really, just need to know your way around the games engine just a bit, and mainly know what bools, string, and integers are, and which ones are important to story.

Well that basically sums up a basic intro to how the scripts are built. I hope you're able to fully write scripts for turtlesim now.