From 3a1292e75e25b4ec956a752f2eef25ee2222241a Mon Sep 17 00:00:00 2001 From: "p.kosyh" Date: Sun, 31 Jan 2010 06:10:11 +0000 Subject: [PATCH] isForSave extra parameters --- doc/writing_games-en.txt | 68 ++++++++++++++++++++++++++++++++++++++++ doc/writing_games.txt | 2 +- stead/stead.lua | 4 +-- 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/doc/writing_games-en.txt b/doc/writing_games-en.txt index 77f34ce..25acb05 100644 --- a/doc/writing_games-en.txt +++ b/doc/writing_games-en.txt @@ -777,6 +777,17 @@ main = room { dsc = 'You are in the room: '..txtb('main')..'.', } + +Since the version 1.1.0 you can create unwrapped strings by using txtnb(); + +For example: + +main = room { + nam = 'Intro', + dsc = 'You are in the room '..txtb('main')..'.', +} + + ==== 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: @@ -984,6 +995,63 @@ horse = obj { }; lifeon('horse'); +==== 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: + +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 +}; + + +==== 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: + +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 +}; + ==== Debugging ==== To see lua call stack during an error, launch sdl-instead with “-debug” parameter. In Windows version debugging console will be created. diff --git a/doc/writing_games.txt b/doc/writing_games.txt index 4561c48..8f9a015 100644 --- a/doc/writing_games.txt +++ b/doc/writing_games.txt @@ -983,7 +983,7 @@ lifeon('horse'); Таймер программируется с помощью объекта timer. * timer:set(ms) -- задать интервал таймера в ms - * timer:del() -- удалить таймер + * timer:stop() -- остановить таймер * timer.callback(s) -- функция-обработчик таймера, которая вызывается через заданный диапазон времени Функция таймера может возвратить комнаду интерфейса stead, которую нужно выполнить после того, как движок выполнит обработчик. Например: diff --git a/stead/stead.lua b/stead/stead.lua index 2bc1a81..5101796 100644 --- a/stead/stead.lua +++ b/stead/stead.lua @@ -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