Getting Started with OSL

From Spiral Framework
Jump to: navigation, search
Hmmm...
WARNING:
OSL is a heavy work in progress and lacks support for many functions. It's not possible to create a fully functional room with it as it lacks the necessary functions. You will still have to use the game's inbuilt opcodes to write most of your scripts. It is however possible to mix OSL with opcodes to get the best of both worlds at the moment.

The Open Spiral Language or OSL is a scripting language created to make creation of script files extremely easy. Rather than needing to manually write out a lot of scripting opcodes, OSL allows you to to write instructions in almost plain English and SPIRAL will take care of all of the hard work.

This guide aims to serve as a simple introduction to all of the essentials to get started writing basic scripts using OSL.

First Things First

OSL scripts may be created in any text editor. In order for SPIRAL to recognize the file as an OSL script, we must declare it as one at the top of the file. We do this by writing: OSL Script

Easy enough, right? SPIRAL now knows that it's looking at an OSL script. We need to add something else though.

Set Game To DR1

or

Set Game To DR2

This is important. You must write one of these lines after the "OSL Script" line in order to tell SPIRAL which game the script is for. This is important because the games have some differing functionality and DR2 scripts will not work in DR1 and vice versa.

Next we need to fade in the scene so we write:

Fade in from black for 1s


To finish off the start of the script we're going to write two more commands.

UI: Enable Speaker Name

UI: Enable Sprites

The first command enables the part of the HUD that shows the name of the character currently speaking. The second line enables the drawing of sprites onscreen so we can show our character.

Your script should now be looking something like this:

OSL Script
Set Game to DR1

Fade in from black for 1s

UI: Enable Speaker Name
UI: Enable Sprites

Showing Characters

The first logical step in learning how to actually write scripts after getting the header out of the way is make characters actually appear on-screen. With OSL, this is extremely easy. Simply write:

Display [character] pose [pose]

Replace [character] with the name of the character you wish to show. SPIRAL already accounts for most variations of character names so you don't usually need to worry about writing their name in a specific form. [pose] is the pose you want the character to switch to. In the future it may be possible to assign names to poses but right now you'll have to check the character's sprites for their poses. The pose ID is the second number of the sprite filename. Please note that SPIRAL only supports using the names of vanilla Danganronpa characters. In the future, support to add custom character names may be added.

Example:

Display Chihiro pose 0

Dialogue and Text

Now that we've got our character showing on the screen, it's time to put some words in their mouth. Once again, OSL makes this an extremely simple task.

[Character]: [Your text!]

Once again, simply replace [character] with the name of the character you want to show as speaking and replace [Your text!] with... well, your text.

Example:

Chihiro: This is some text!

Making Choices

Sometimes you may wish to give the player a choice. The choice system in the native LIN format is rather confusing and hard to keep track of but the OSL format makes it a piece of cake. The template for choice code looks like this:

Display Choices {
    "Choice 1" {
        [code]
    }
    "Choice 2" {
        [code]
    }
    "Choice 3" {
        [code]
    }
}

This code will make the game show 3 choices, "Choice 1", "Choice 2" and "Choice 3". You can customise the choices that appear by changing the text in quotes and you can replace [code] with any code you wish to run when this choice is made.

This can be modified to only give 2 choices (or go up to 4 choices in Danganronpa 2).

Example:

Chihiro: Do you like this example?
Display Choices {
    "Yes" {
        Chihiro: Really? Yay!
    }
    "No" {
        Chihiro: Oh...
    }
}