Edited online
parent
820c5a2a32
commit
138e8e4e70
21
Guide.md
21
Guide.md
|
@ -6,7 +6,9 @@ This module lets you ditch `txtb` and `txtem` functions in the game main code. C
|
|||
**Usage:**
|
||||
|
||||
**bold** or __bold__
|
||||
*italic* или __italic__
|
||||
*italic*
|
||||
_underline_
|
||||
-strikeout-
|
||||
|
||||
Just write `require "emphasis"` and use these shortcuts. Module requires `format` module automatically.
|
||||
|
||||
|
@ -14,22 +16,23 @@ WARNING: shortcuts don't work in inventory.
|
|||
|
||||
## choice module
|
||||
|
||||
Наглядное использование этого модуля показано в игре ["Шестой город"](https://github.com/Oreolek/sixth_city). Он позволяет показывать фразы в диалогах на основе определённых критериев, которые различаются для каждой фразы. В результате получается сложный геймплей CYOA, основанный на множественных проверках условий.
|
||||
You can see this module in action in a prototype game ["Sixth city"](https://github.com/Oreolek/sixth_city). It lets you show dialogue phrases on pre-defined criteria. This results in a complex CYOA gameplay based on many condition checks.
|
||||
|
||||
Для начала покажу обычный диалог. Он ничем не отличается от стандартных диалогов INSTEAD, его можно сделать средствами обычного массива `phr`:
|
||||
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,'Съесть яблоко', nil, 'pl._ate = "apple"' ),
|
||||
option(nil,'Съесть перец'), nil, 'pl._ate = "pepper"' ),
|
||||
option(nil,'Запить водой'), nil, 'pl._drank = "water"' ),
|
||||
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"' ),
|
||||
}
|
||||
}
|
||||
|
||||
Чем отличается этот диалог? Во-первых, он описан как объект типа `choice`. Во-вторых, его фразы находятся в массиве `obj` и описаны функциями `option`. Синтаксис функции `option` соответствует функции `phr`, только добавляется новый параметр: условие, при котором появляется фраза. Если это условие пусто (что на языке Lua описывается словом `nil`), то фраза показывается всегда. Давайте посмотрим, что можно сделать при помощи условий:
|
||||
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',
|
||||
|
@ -41,6 +44,6 @@ WARNING: shortcuts don't work in inventory.
|
|||
}
|
||||
}
|
||||
|
||||
Теперь третья фраза изначально не видна. Если игрок выберет вторую, то вторая тут же скроется, и появится третья. Условия могут быть также функциями, которые возвращают булево значение (`true` или `false`). Условия могут быть сколь угодно сложными, они могут проверять всё состояние игры.
|
||||
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.
|
||||
|
||||
Здесь также важно то, что условия проверяются при каждой отрисовке комнаты: игрок может активировать предмет в инвентаре, и у него тут же поменяется набор вариантов. Объект choice может реагировать даже на изменение настроек самого INSTEAD — всё, что придёт вам в голову. Это часто удобнее, чем выставлять показ/скрытие каждой фразы явным образом.
|
||||
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.
|
Loading…
Reference in a new issue