# Script Writer
There could be confusion with [Story Editor](../../wiki/docs/Story-Editor.md).

Script Writer is the Text editor to write the scenes used in the story. It's developed for easy writing of scripts. With features like Dialogue insertions. And features more toward the organization like Shot management. And assets marking. 

![](https://notabug.org/jyamihud/update_manager/raw/master/vcstudio/52.png)


### Chapters:

 - [User Guide](#user-guide)
 - [Source Code](#source-code)

# User Guide

You enter the Script Writer by double clicking on a scene in the [Story Editor](../../wiki/docs/Story-Editor.md).

As you can see the window is devided into 3 parts. The left side, the bigger middle part and the right side. This kind of layot will be in multiple places in the VCStudio. Usually it's because on the right there are checklists.

**The middle**

The middle part is the most important. In the Script Writer the middle part is your scene text. Think of it as a simple text editor. But as you can see this one is a bit more colorful and interesting then usual text editors.

VCStduio is not your typical screenplay writer program. It's not there to make you print a document. It's there to help you make the **entire movie.** Please keep this in mind as we dive in this colorful madness. 

On the top, above the text you can see a panel. In this pannel there a couple of things. Let's go over them.

![](../../settings/themes/OldSchool/icons/shot_new.png) `Ctrl-S` Will mark selected part of the text as a shot. Each shot will have it's own color. From set of 5 colors. If you don't manually choose the color. It will cycle through the colors by it self. But you have the ability to choose the color manually from the shot editor on the left side. Clicking on the shot in the shot editor or in the text will open it's options and files.

![](../../settings/themes/OldSchool/icons/obj_link.png) `Ctrl-L` Will mark a selected part of the text as a link to an asset. The part of the text will be marked purple. The part of the text also will become a clickable link. To be transferred to the asset.

![](../../settings/themes/OldSchool/icons/frase_new.png) `Ctrl-D` Will create a dialogue part in the text when a character says a line. It's constructed from 2 parts. The name of the character. And the line it self. It's optimized to work on the keyboard. So I do it like this. `Ctrl-D` then I type for example "Moria" press enter and type "This is not real driving" or what ever Moria should say. Then press Enter twice to return to normal text. I allow one Enter to be in the line. Since sometimes character speak entire speeches. 

![](../../settings/themes/OldSchool/icons/image_link.png) `Ctrl-I` Inserts an image. Sometimes you need a visual explanation for things. 

The name of the scene is editable only if the folder is not yet created for it. If it is created you will have the  ![](../../settings/themes/OldSchool/icons/folder.png) icon on the far right. Which will open that folder.

On the bottom you have the  ![](../../settings/themes/OldSchool/icons/left.png) and ![](../../settings/themes/OldSchool/icons/right.png) buttons. To go to connected scenes. 

**The Right**

On the right side it's the checklist. If a shot is selected then it's the checklist of the shot. If not it's the checklist of the scene. If there is no checklist file it will let you create one. **BUT**. Keep in mind that it will also create the folder. Which will block your ability to rename the scene or the shot.

**The Left**

On the very top of the left you can see 3 icons.

![](../../settings/themes/OldSchool/icons/shot.png) will present you with a list of shots. This is the main mode. We gonna talk about it in a bit.

![](../../settings/themes/OldSchool/icons/schedule.png) will present you with currently scheduled tasks for a given scene. Or if a shot selected, just the given shot. Keep in mind that you can still select shots from the text it self.

![](../../settings/themes/OldSchool/icons/history.png) will present you with a history. It's like a list of who done what at what time.

Now let's come back to the ![](../../settings/themes/OldSchool/icons/shot.png) shot list. You will see a vertical list of shots. Selecting one will open it up so you could see it in more details. At the very top you will see 4 round icons.

![](../../settings/themes/OldSchool/icons/storyboard.png) , ![](../../settings/themes/OldSchool/icons/opengl.png), ![](../../settings/themes/OldSchool/icons/test_rnd.png) and ![](../../settings/themes/OldSchool/icons/rendered.png) . You can think of them as a 4 levels of shot. Originally it was developed long time ago. And for sake of backward compatibility I will keep the names the same. They stand for `storyboard` , `opengl` , `test_rnd` and `rendered`. Those are folders for rendered frames for each category. *NOTE: The folders might not actually be present. They are created by the rendering algorithm in VCStudio.*

Slightly below it is the frame preview of the shot. It will show you a frame from a folder you select above. Under the preview frame there is a little time line. So you could scrub through the shot and see how the animation is looking.

Then there is a list of blend files used to make the shot. If you want to add a new one. You can use the search above. Type the name you want to appear. And it will let you add one.

Adding one will present you with 2 options.

![](../../settings/themes/OldSchool/icons/new_file.png) to add an empty blend file.

![](../../settings/themes/OldSchool/icons/copy_file.png) to copy one from a different place. It will show you other shots in the scene by default. But you can search for any blend file anywhere.

Under the blend files you have 2 additional icons not present in assets.

![](../../settings/themes/OldSchool/icons/obj_link.png) will let you link assets into the file. By default it will read the scene's text. And will give you the list of all assets marked in that text.

![](../../settings/themes/OldSchool/icons/render.png) will let you render the shot using the VCStudio rendering system.


Please take a look at the next section. Come on people. Source code is your friend. And reading it, editing it and sharing it is okay. 

# Source Code

The best documentation is to read the code of the software directly. For the script writer I recommend:

- [studio/story.py](../../studio/story.py) Reads, Writes and does various things with the story file.
- [studio_scriptLayer.py](../../studio/studio_scriptLayer.py) Draws the Script Writer and contains all of the writing logic. As well as the shots.

**How does it selects the colors for the shots?**

Simply. The 5 colors that you can see on the picture are positioned in a list called `rcolors`. Which are actually not the colors them selves but an index names of the colors.  Look at the [theme.data](../../settings/themes/Default/theme.data) file. You can find there entries for those 5 colors. `shot_1`,  `shot_2`,  `shot_3`,  `shot_4`,  `shot_5` and besides are the RGBA values for each color. These values are read and applied using [UI/UI_color.py](../../UI/UI_color.py).

Note that the link to the theme file is the link to the default theme. Various themes could have different colors.

Now just randomly selecting a color or selecting a color in sequence while could technically work. It would not allow the user to select the color manually. So after selecting the color in sequence. I'm saving the color into the story file. Yes into the `win.story` dictionary. And after that into the `/pln/story.vcss` file. But because I didn't plan to do that early on. It's separate from the scenes. Not in `scenes` in `win.story` but in `shot_colors` in `win.story`.

**How do you make the markings?**

This is not simple. If you look into the `/pln/story.vcss` which is secretly a JSON file. You can see that every scene is constructed of blocks. It's either a `text_block` or a `shot_block`. Text block has only 2 enties on the list. The string saying that it's a `text_block` and list of parts. Shot block has the string saying that it's a `shot_block` then string with the name of the shot and list of parts.

What is this list of parts? The last part is not a text. It's a list of parts of the text. Those pars could be either `text` which is a list of 2 elements. String saying that it's a `text` and a string of the text. `frase` which I use for dialogs. It's a 3 part list. String saying that it's a `frase` then the character name block and a string of the text the character is saying. `link` another 3 part list. The middle part is a url of an asset. Those are the purple ones. And `image` which is like `text` a 2 part list. But there is no text in the second part, there is a link to the image.

I lost you right? I lost myself. Good refernce would be to read [get_legacy()](../../studio/story.py) function.

**How do you make it type?**

The Gtk module has some handy functions to catch key presses and key releases. See [key_press()](../../studio/studio_gtk.py) function. On every key press. I'm not only writing the value of the key into the `keys` in `win.current` but also writing the string of the key into `key_letter` in `win.current`. Which is already combining the Shift / Caps Lock key and the various language keyboard layots. Giving you the actual UTF-8 character. All I need to do it to insert this character at a cursor location. Which sounds simple. But if you read the whole previous part and think about having 2 cursors. For the beginning of the selection and the end of the selection. And understand that selection could start in one block and end in another block. And that the user doesn't care. Then you have a problem. Basically about the middle of the [studio_scriptLayer.py](../../studio/studio_scriptLayer.py) script I have this very big and complex logic part that handles all of this craziness for me.

# Help The Documentation

The documentation files are not perfect. And need maintenance.

*If you are reading it from the VCStudio build in Documentation:*

 - Press ![](../../settings/themes/OldSchool/icons/edit.png) to edit locally.
 - Press ![](../../settings/themes/OldSchool/icons/notabug.png) to commit in our NotABug repository.

*(C) J.Y.Amihud 2021. Under GPL v3 or later.*