6 Guide
oreolek edited this page 2015-08-15 02:37:59 +00:00

[English guide] Usage

[TOC]

emphasis module

This module lets you ditch txtb and txtem functions in the game main code. Compare: pn "Hi"..txtem("Player") and pn "Hi *Player*".

Usage:

**bold** or __bold__
*italic*
_underline_
 -strikeout-

Just write require "emphasis" and use these shortcuts. Module requires format module automatically.

WARNING: shortcuts don't work in inventory.

choice module

You can see this module in action in a prototype game "Sixth city". It lets you show dialogue phrases on pre-defined criteria. This results in a complex CYOA gameplay based on many condition checks.

For example let's consider a usual dialog. It's almost as standard INSTEAD dlg, you can do it using regular phr array:

choose = choice {
  nam = 'Diner',
  dsc = [[I see some food.]],
  obj = {
    option(nil,'Eat an apple', nil, 'pl._ate = "apple"' ),
    option(nil,'Eat a pepper'), nil, 'pl._ate = "pepper"' ),
    option(nil,'Drint water'), nil, 'pl._drank = "water"' ),
  }
}

What's unique here? For starters, it's an object of choice type. In second place, the phrases are defined with option functions. option function syntax is the same as phr function but it has an additional parameter of condition.

If a condition is true at the moment, the phrase is shown. If a condition is nil, the phrase is always shown. See the second example:

choose = choice {
  nam = 'Diner',
  dsc = [[I see some food.]],
  obj = {
    option(function() return true end,'Eat an apple', nil, 'pl._ate = "apple"' ),
    option("pl._ate ~= 'pepper'",'Eat a pepper'), nil, 'pl._ate = "pepper"' ),
    option("pl._ate == 'pepper'",'Drink water'), nil, 'pl._drank = "water"' ),
  }
}

Now the third phrase is initially out. If the player chooses the second one, it hides away and the third shows up. The conditions can also be functions - they have to return a boolean (true or false). Conditions can be as complex as you want it, they have the complete game state to check.

What's also important here is that: conditions are checked on every look in the room. The player can activate an inventory object and have a different set of options immediately. The choice object can react even at INSTEAD preferences change — everything you can think of. It's often much easier than setting every phrase on and off with direct instructions.

rndstr module

A very short module that gives you a string randomization function. Example usage:

rndstr({
  'Ow!',
  'Oh!',
  'Holy pink horse in the sky!'
});

This results in a random string from the table.

translate module

This module lets you use gettext to translate your works - in contrast to copy-and-rewrite approach. It has only one option:

require 'translate'
translate.source = 'en'

The default value is 'ru', so you should definitely set it to your native language 2-letter code. The module declares a function __() that translates all text from the source language to the one currently selected in INSTEAD preferences.

That is all there is to that. You require the module, wrap all strings like this: __([[text]]) and start Poedit or whatever you prefer on the source code. To get help on gettext one should turn to a search engine.