How to enter the game industry (part 7: Ren'py Scripting, Dialogue) [tutorial]steemCreated with Sketch.

in #gaming7 years ago (edited)

part 1: your skills
part 2: Choosing an Engine
part 3: Ren'py Game Engine
part 4: Ren'py Scripting
part 5: Ren'py More Scripting
<< Part 6: Ren'py Scripting, Visuals

In a story based game, You might want as much control over the dialogues as possible. in that case you'll need a way to format your text style in dialogues, yes I exactly mean those "bold", "italic", "size" and "color" options.

0.jpg

Again we will start with an empty game script, if you've made a game by this point you can make a backup or create a new game in case you want to copy and paste the tests.

label start:

    return

Styling text in Ren'py is similar to HTML format, they come in tags on both side of the text and they are placed inside a pair of curly braces {}


Bold

For example a bold tag consist of {b}that starts bold and {/b} that ends it, anything between those tags would become bold.

label start:
    "this is normal text, {b}This is bold{/b} and this is normal again."
    return

Copy, paste and run to see the result.

Now let's go through all of the other tags real fast.

Italic

label start:
    "this is how you make {i}italic text{/i}"
    return

Strikethrough

label start:
    "this is how you make {s}strikethrough text{/s}"
    return

Underline

label start:
    "this is how you make {u}underlined text{/u}"
    return

font

label start:
    "this is how you make {font=tahoma.ttf}a different font{/font}"
    return

Note: to use fonts in Ren'py you need to copy the font file in the game folder.

color

label start:
    "this is how you make {color=#f00}your text red{/color}"
    return

Note: In the example above the code used for color #f00 is a type of color hex code, You might seen it's other format #ff0000around.
The two first values are for red the middle two are for green and the two values at the end are for blue, it's basically RGB in hex format, it's often simplified to one value per color when both values are the same.
Note: Ren'py actually use RGBA format and you can add a fourth value after #f00 for alpha, or two values at the end of #ff0000for alpha.
For example #f008 or #ff000088 are a half opacity red color, try it yourself:

label start:
    "{color=#f00}normal red{/color} {color=#f004}faint red{/color}"
    return

Alpha

Now we seen alpha in color let's see an example of alpha tag.

label start:
    "this is how you make {alpha=0.2}your text barely visible{/alpha}"
    return

Note: the value for alpha can be anything between zero and one, 0 is invisible, 0.5 is half visible and 1 is fully visible.

Size

The size tag controls the text size in two ways, absolute size and relative size, in the example below you give your text an absolute size to appear in.

label start:
    "this is how you make {size=40}text size 40{/size}"
    return

Relative size is calculated simply relative to the default text size, check the example below.

label start:
    "default text size {size=+10}default text size +10 {/size} {size=-10}default text size -10 {/size}"
    return

cps (characters per second)

In Ren'py there's a setting that gives the players the control over how fast the text appear on the screen:
1.jpg
However, the game developer can control the speed of text with the cps, like font size you can give it an absolute value or a relative value. when given an absolute value the text speed value is ignored:

label start:
    "The text will appear {cps=10}10 characters per second{/cps}"
    return

But when given a relative value the text will appear as a percentage of the text speed setting.

label start:
    "The text will appear {cps=*0.2}in a fifth of the normal speed {/cps} or {cps=*2}twice the normal speed {/cps}"
    return

Note: the default setting is set to instant and with instant relative cps is instant. Just keep that in mind when you make your game you might want to set the default cps speed to something you want. (I will explain how in a later part)

Link

The last remaining tag is clickable links, something useful when you want to open a web page from inside your game:

label start:
    "visit me: {a=https://steemit.com/@kiaazad}@kiaazad{/a}"
    return

Note: if address doesn't start with http the link will consider it a label to call and after you're done visiting that label it will bring you back where you've left.

label start:
    "visit me: {a=testlink}@kiaazad{/a}"
    return

label testlink:
    "it works"
    return


Now we gone through the tags that have a start and an end, let's take a look at the self closing tags. these tags have no end and they only have a start part.

w (wait)

Sometimes you want the dialogue pause in the middle for a while then start going again, you can use the {w} tag for that purpose. in fact {w} is the most used tag in the games.

label start:
    "you know what? {w=1.0} it's fine."
    return

Note: the value of wait is in seconds, a {w=0.5} will cause a half second pause. A {w} tag with no value will pause until the player clicks.

NW (no wait)

No wait tag will cause the next line of dialogue appear without the player clicking. it might look kind of useless but it becomes a very useful tool when combined with other tags and commands.

label start:
    "by the way{nw}"
    "I'm not going to wait."
    return

Note: instant cps can cause the first line pass so fast the player can't see it. use with caution.

Fast

A fast tag will cause any text before it to appear instantly while the text speed is not set to instant.

label start:
    "by the way {fast} are you staying for dinner?"
    return

let's combine {nw} and {fast} to show an image in the middle of the dialogue:

label start:
    "It's amazing when {nw}"
    show image "gui/window_icon.png"
    "It's amazing when {fast}the image appears out of nowhere."
    return

Space

If you've tried by now, you've noticed that you can't put a series of spaces in your text and make a gap in it. But don't worry, there is a tag for it:

label start:
    "here's a gap{space=70}isn't it nice."
    return

what else we can't use? (you might ask)
Obviously you can't have doublequote " in your dialogue unless:

label start:
    "her's a \"doublequote\" for you."
    return

A slash \ will cause the engine to skip the next character to it as code and show it as text.

What else I need to put a slash in front of? (you might ask)
Another slash of curse:

label start:
    "her's a \\ for you. or more \\\\\\"
    return

a next line n for going to the next line:

label start:
    "this text will \n appears in \n multiple lines."
    return

{} or []

label start:
    "a \{ or \["
    return

Note: an easier way to use those four is putting two of them instead of one {{

label start:
    "take the [[easy] way {{out}"
    return



I left out few things that looked unnecessary and might've cause confusion but don't worry I'll recheck and bring them up in the future tutorials if necessary.

In the next part I'll try to amass a set of tips and how to's that you might need,+ then you're a full flagged Ren'py scriptwriter, you might find some paying jobs by looking into lemmasoft forum.

Part 8: Ren'py Scripting, Conclusion
Part 9: Images
Part 10: Animation
Part 11: sound editing and voice acting

Sort:  

Wow this is a great detailed post, i'd never have the patience, great going :)

Thank you,
I've checked your channel and got a warm sense of nostalgia watching your Terraria boss fight ^_^

This is really interesting, although I have stumbled on it five parts in so I'm going to have to back track a bit. Reminds me of Javascript, not sure I will ever get time to create something myself but it's good to know.

Thanks, ^_^
If you've the free time, trying it can be very rewarding.

Congratulations @kiaazad, this post is the eighth most rewarded post (based on pending payouts) in the last 12 hours written by a User account holder (accounts that hold between 0.1 and 1.0 Mega Vests). The total number of posts by User account holders during this period was 1580 and the total pending payments to posts in this category was $3795.59. To see the full list of highest paid posts across all accounts categories, click here.

If you do not wish to receive these messages in future, please reply stop to this comment.

Coin Marketplace

STEEM 0.31
TRX 0.11
JST 0.033
BTC 64550.89
ETH 3156.32
USDT 1.00
SBD 4.30