isForSave extra parameters

This commit is contained in:
p.kosyh 2010-01-31 06:10:11 +00:00
parent 9e5b4bb4d2
commit 3a1292e75e
3 changed files with 71 additions and 3 deletions

View file

@ -777,6 +777,17 @@ main = room {
dsc = 'You are in the room: '..txtb('main')..'.',
}
</code>
Since the version 1.1.0 you can create unwrapped strings by using txtnb();
For example:
<code>
main = room {
nam = 'Intro',
dsc = 'You are in the room '..txtb('main')..'.',
}
</code>
==== Menus ====
You can do menus in the inventory area, using menu constructor. Menu handler will be called after single mouse click. If handler have no return string the state of game will no change. For example, here is pocket realisation:
<code>
@ -984,6 +995,63 @@ horse = obj {
};
lifeon('horse');
</code>
==== Timer ====
Since the version 1.1. 'instead' has a ''timer'' object. (Only for sdl version.)
Timer controls through the ''timer'' object.
* timer:set(ms) -- set timer interval (ms)
* timer:stop() -- stop timer
* timer.callback(s) -- callback for timer, calling in fixed time interval
Timer function can return a ''stead'' interface command that have to be invoked after the callback execution. For example:
<code>
timer.callback = function(s)
main._time = main._time + 1;
return "look";
end
timer:set(100);
main = room {
_time = 1,
force_dsc = true,
nam = 'Timer',
dsc = function(s)
return 'Example: '..tostring(s._time);
end
};
</code>
==== Keyboard ====
Since the version 1.1.0 ''instead'' supports the keyboard input. (Only for sdl version.) Use the ''input'' object for this.
input.key(s, pressed, key) -- keyboard handler; pressed -- press or release action; key -- symbolic name of the key;
Handler can return a ''stead'' interface command. In this case the interpreter doesn't handle a key.
For example:
<code>
input.key = function(s, pr, key)
if not pr or key == "escape"then
return
elseif key == 'space' then
key = ' '
elseif key == 'return' then
key = '^';
end
if key:len() > 1 then return end
main._txt = main._txt:gsub('_$','');
main._txt = main._txt..key..'_';
return "look";
end
main = room {
_txt = '_',
force_dsc = true,
nam = 'Keyboard',
dsc = function(s)
return 'Exmaple: '..tostring(s._txt);
end
};
</code>
==== Debugging ====
To see lua call stack during an error, launch sdl-instead with “-debug” parameter. In Windows version debugging console will be created.

View file

@ -983,7 +983,7 @@ lifeon('horse');
Таймер программируется с помощью объекта timer.
* timer:set(ms) -- задать интервал таймера в ms
* timer:del() -- удалить таймер
* timer:stop() -- остановить таймер
* timer.callback(s) -- функция-обработчик таймера, которая вызывается через заданный диапазон времени
Функция таймера может возвратить комнаду интерфейса stead, которую нужно выполнить после того, как движок выполнит обработчик. Например:

View file

@ -1374,7 +1374,7 @@ function savemembers(h, self, name, need)
local need2
if k ~= "__visited__" then
need2 = false
if isForSave(k) then
if isForSave(k, v, self) then
need2 = true;
end
@ -2196,7 +2196,7 @@ function disabled(o)
return isDisabled(ref(o))
end
function isForSave(k)
function isForSave(k, v, s) -- k - key, v - value, s -- parent table
return stead.string.find(k, '_') == 1 or stead.string.match(k,'^%u')
end
-- here the game begins