This commit is contained in:
p.kosyh 2010-05-19 17:38:09 +00:00
parent 658c28538a
commit 53701da01c
2 changed files with 519 additions and 511 deletions

View file

@ -325,7 +325,7 @@ knife = obj {
inv = 'Sharp!', inv = 'Sharp!',
tak = 'I took the knife!', tak = 'I took the knife!',
use = function(s, w) use = function(s, w)
if w ~= 'tabl' if w ~= 'tabl' then
return 'I don\'t want to cut this.', false return 'I don\'t want to cut this.', false
else else
return 'You incise your initials on the table.'; return 'You incise your initials on the table.';
@ -362,7 +362,7 @@ Commands:^
}; };
</code> </code>
As we can see, the object keeps the reference to the current player ('pl') and some parameters. For example at the start of your game you can set the encoding the following way: As we can see, the object keeps the reference to the current player ('pl') and some parameters. For example at the start of your game you can set the encoding the following way:
<code> game.codepage="UTF-8"; </code> <code>game.codepage="UTF-8"; </code>
The support of arbitrary encodings is present in every UNIX version of the interpreter and in windows versions from 0.7.7. The support of arbitrary encodings is present in every UNIX version of the interpreter and in windows versions from 0.7.7.
@ -469,11 +469,11 @@ end
move(o, w) — moves an object from the current scene to another: move(o, w) — moves an object from the current scene to another:
<code> move('mycat','inmycar');</code> <code>move('mycat','inmycar');</code>
If you want to move an object from an arbitrary scene, you'll have to delete it from the original scene with the “del” method. To create objects, that move in complex ways, you'll have to write a method that would save the object's position in the object itself and delete it from the original scene. You can set the initial position (room) as the third parameter of “move”. If you want to move an object from an arbitrary scene, you'll have to delete it from the original scene with the “del” method. To create objects, that move in complex ways, you'll have to write a method that would save the object's position in the object itself and delete it from the original scene. You can set the initial position (room) as the third parameter of “move”.
<code> move('mycat','inmycar', 'forest'); </code> <code>move('mycat','inmycar', 'forest'); </code>
From version 0.8 there is a “movef” function similar to “move”, but adding the object to the start of the list. From version 0.8 there is a “movef” function similar to “move”, but adding the object to the start of the list.
@ -591,7 +591,7 @@ You can pass from one dialog to another, organizing hierarchic dialogs.
You can also hide some phrases when initializing the dialog and show them under certain conditions. You can also hide some phrases when initializing the dialog and show them under certain conditions.
<code> <code>
facectrl = dlg { facectrl = dlg {
nam = 'фэйсконтроль', nam = 'facecontrol',
dsc = 'I see an unpleasant face of a fat guard.', dsc = 'I see an unpleasant face of a fat guard.',
obj = { obj = {
[1] = phr('“I came to the Belin's lecture...”', [1] = phr('“I came to the Belin's lecture...”',
@ -649,7 +649,7 @@ There is a modification of “vobj” object — “vway”. It creates a refere
You can dynamically fill the scene with “vobj” and “vway” objects. Use methods “add” and “del”. For example: You can dynamically fill the scene with “vobj” and “vway” objects. Use methods “add” and “del”. For example:
<code> <code>
home.objs:add(vway("next", "{Next}.", 'next_room'); home.objs:add(vway("next", "{Next}.", 'next_room'));
-- some code here -- some code here
home.objs:del("next"); home.objs:del("next");
</code> </code>
@ -877,6 +877,7 @@ If you use “goto” from the “exit” handler, you get stack overflow, becau
exit = function(s, t) exit = function(s, t)
if t == 'dialog' then return; end if t == 'dialog' then return; end
return goto('dialog'); return goto('dialog');
end
</code> </code>
From version 0.9.1 this is done by stead engine. From version 0.9.1 this is done by stead engine.
@ -937,11 +938,11 @@ You can create a game with several characters and switch between them from time
==== Using the first parameter of a handler ==== ==== Using the first parameter of a handler ====
Code example. Code example.
<code> <code>
knife = obj { stone = obj {
nam = 'stone', nam = 'stone',
dsc = 'There is a {stone} at the edge.', dsc = 'There is a {stone} at the edge.',
act = function() act = function()
objs():del('knife'); objs():del('stone');
return 'I pushed the stone, it fell and flew down...'; return 'I pushed the stone, it fell and flew down...';
end end
</code> </code>
@ -962,7 +963,7 @@ You can write your own music player, creating it from a live object, e.g:
-- plays tracks in random order, starting from 2-nd -- plays tracks in random order, starting from 2-nd
tracks = {"mus/astro2.mod", "mus/aws_chas.xm", "mus/dmageofd.xm", "mus/doomsday.s3m"} tracks = {"mus/astro2.mod", "mus/aws_chas.xm", "mus/dmageofd.xm", "mus/doomsday.s3m"}
mplayer = obj { mplayer = obj {
nam = 'плеер', nam = 'media player',
life = function(s) life = function(s)
local n = get_music(); local n = get_music();
local v = get_music_loop(); local v = get_music_loop();
@ -1175,6 +1176,8 @@ end
</code> </code>
''pn()'' function adds line feed to the text and outputs the result to the buffer. ''p()'' does almost the same thing but adds a space instead of line feed. ''pn()'' function adds line feed to the text and outputs the result to the buffer. ''p()'' does almost the same thing but adds a space instead of line feed.
There is a function ''pr()'' in versions 1.1.6 and later, that does not add anything at end of output.
To clear the buffer you can use ''pclr()''. To return the status of the action along with the text, use ''pget()''. To clear the buffer you can use ''pclr()''. To return the status of the action along with the text, use ''pget()''.
<code> <code>
use = function(s, w) use = function(s, w)

View file

@ -323,7 +323,7 @@ knife = obj {
inv = 'Острый!', inv = 'Острый!',
tak = 'Я взял нож!', tak = 'Я взял нож!',
use = function(s, w) use = function(s, w)
if w ~= 'tabl' if w ~= 'tabl' then
return 'Не хочу это резать.', false return 'Не хочу это резать.', false
else else
return 'Вы вырезаете на столе свои инициалы.'; return 'Вы вырезаете на столе свои инициалы.';
@ -465,19 +465,19 @@ end
</code> </code>
move(o, w) -- переносит объект из текущей сцены в другую: move(o, w) -- переносит объект из текущей сцены в другую:
<code> move('mycat','inmycar');</code> <code>move('mycat','inmycar');</code>
Если вы хотите перенести объект из произвольной сцены, вам придется удалить его из старой сцены с помощью метода del. Для создания сложно перемещающихся объектов, вам придется написать свой метод, который будет сохранять текущую позицию объекта в самом объекте и делать удаление объекта из старой сцены. Вы можете указать исходную позицию (комнату) объекта в качестве третьего параметра move. Если вы хотите перенести объект из произвольной сцены, вам придется удалить его из старой сцены с помощью метода del. Для создания сложно перемещающихся объектов, вам придется написать свой метод, который будет сохранять текущую позицию объекта в самом объекте и делать удаление объекта из старой сцены. Вы можете указать исходную позицию (комнату) объекта в качестве третьего параметра move.
<code> move('mycat','inmycar', 'forest'); </code> <code>move('mycat','inmycar', 'forest'); </code>
Начиная с версии 0.8 присутствует также функция movef, аналогичная move, но добавляющая объект в начало списка. Начиная с версии 0.8 присутствует также функция movef, аналогичная move, но добавляющая объект в начало списка.
seen(o) -- если объект присутствует в текущей сцене: seen(o) -- если объект присутствует в текущей сцене:
<code> <code>
if seen('mycat') then if seen('mycat') then
move('mycat','inmycar'); move('mycat','inmycar');
end end
</code> </code>
Начиная с 0.8.6 -- необязательный второй параметр -- сцена. Начиная с 0.8.6 -- необязательный второй параметр -- сцена.
@ -644,8 +644,8 @@ sside = room {
Вы можете динамически заполнять сцену объектами vobj или vway с помощью методов add и del. Например: Вы можете динамически заполнять сцену объектами vobj или vway с помощью методов add и del. Например:
<code> <code>
home.objs:add(vway("next", "{Дальше}.", 'next_room'); home.objs:add(vway("next", "{Дальше}.", 'next_room'));
-- some code here -- здесь какой-нибудь код
home.objs:del("next"); home.objs:del("next");
</code> </code>
@ -664,11 +664,11 @@ mycat = obj {
nam = 'Барсик', nam = 'Барсик',
lf = { lf = {
[1] = 'Барсик шевелится у меня за пазухой.', [1] = 'Барсик шевелится у меня за пазухой.',
[2] = 'Барсик выглядывает из за пазухи.', [2] = 'Барсик выглядывает из-за пазухи.',
[3] = 'Барсик мурлычит у меня за пазухой.', [3] = 'Барсик мурлычит у меня за пазухой.',
[4] = 'Барсик дрожит у меня за пазухой.', [4] = 'Барсик дрожит у меня за пазухой.',
[5] = 'Я чувствую тепло Барсика у себя за пазухой.', [5] = 'Я чувствую тепло Барсика у себя за пазухой.',
[6] = 'Барсик высовывает голову из за пазухи и осматривает местность.', [6] = 'Барсик высовывает голову из-за пазухи и осматривает местность.',
}, },
life = function(s) life = function(s)
local r = rnd(6); local r = rnd(6);
@ -863,6 +863,7 @@ inv():add('status');
exit = function(s, t) exit = function(s, t)
if t == 'dialog' then return; end if t == 'dialog' then return; end
return goto('dialog'); return goto('dialog');
end
</code> </code>
Начиная с версии 0.9.1 движок сам разрывает рекурсию. Начиная с версии 0.9.1 движок сам разрывает рекурсию.
@ -922,11 +923,11 @@ doencfile("game");
==== Использование первого параметра обработчика ==== ==== Использование первого параметра обработчика ====
Пример кода. Пример кода.
<code> <code>
knife = obj { stone = obj {
nam = 'камень', nam = 'камень',
dsc = 'На краю лежит {камень}.', dsc = 'На краю лежит {камень}.',
act = function() act = function()
objs():del('knife'); objs():del('stone');
return 'Я толкнул камень, он сорвался и улетел вниз...'; return 'Я толкнул камень, он сорвался и улетел вниз...';
end end
</code> </code>
@ -938,6 +939,7 @@ knife = obj {
return 'Я толкнул камень, он сорвался и улетел вниз...'; return 'Я толкнул камень, он сорвался и улетел вниз...';
end end
</code> </code>
==== Использование set_music ==== ==== Использование set_music ====
Вы можете использовать set_music для проигрывания звуков, задавая второй параметр -- счетчик циклов проигрывания звукового файла. Вы можете использовать set_music для проигрывания звуков, задавая второй параметр -- счетчик циклов проигрывания звукового файла.
@ -1004,6 +1006,7 @@ horse = obj {
}; };
lifeon('horse'); lifeon('horse');
</code> </code>
==== Таймер ==== ==== Таймер ====
Начиная с версии 1.1.0 в instead появлилась возможность использовать таймер. (Только в графической версии интерпретатора.) Начиная с версии 1.1.0 в instead появлилась возможность использовать таймер. (Только в графической версии интерпретатора.)
@ -1067,7 +1070,7 @@ main = room {
input.click(s, pressed, mb, x, y, px, py) -- обработчик клика мыши; pressed -- нажатие или отжатие. mb -- номер кнопки (1 - левая), x и y -- координаты клика относительно левого верхнего угла. px и py присутствуют, если клик произошел в области картинки сцены и содержит координаты клика относительно левого верхнего угла картинки. input.click(s, pressed, mb, x, y, px, py) -- обработчик клика мыши; pressed -- нажатие или отжатие. mb -- номер кнопки (1 - левая), x и y -- координаты клика относительно левого верхнего угла. px и py присутствуют, если клик произошел в области картинки сцены и содержит координаты клика относительно левого верхнего угла картинки.
Обработчик может вернуть команду интерфейса stead, в этом случае клик не будет обработана интерпретатором. Обработчик может вернуть команду интерфейса stead, в этом случае клик не будет обработан интерпретатором.
Например: Например:
<code> <code>
@ -1158,6 +1161,8 @@ end
</code> </code>
Функция pn() выполняет вывод текста в буфер, дополняя его переводом строки. Функция p() дополняет вывод пробелом. Функция pn() выполняет вывод текста в буфер, дополняя его переводом строки. Функция p() дополняет вывод пробелом.
Начиная с версии 1.1.6 существует функция pr(), которая не выполняет дополнение вывода.
Для очистки буфера, используйте pclr(). Если вам нужно вернуть статус действия, используйте pget(). Для очистки буфера, используйте pclr(). Если вам нужно вернуть статус действия, используйте pget().
<code> <code>
use = function(s, w) use = function(s, w)