more clever global

This commit is contained in:
p.kosyh 2010-07-08 08:06:27 +00:00
parent 3e747de495
commit f6cbb0a0b0
3 changed files with 13 additions and 6 deletions

View file

@ -471,9 +471,9 @@ game.use = 'Won\'t work...';
Attribute lists (such as “way” or “obj”) allow to work with themselves thus allowing to implement dynamically defined passages between scenes, live objects, etc.
List methods are: “add”, “del”, “look”, “srch”. The most used are “add” and “del”.
List methods are: “add”, “del”, “look”, “srch”, “purge”. The most used are “add” and “del”.
“add” adds to the list, “del” removes from the list, “srch” performs a search. Note that “del” and “srch” may use as a parameter not only the object itself or its identifier, but also the object name.
“add” adds to the list, “del” removes from the list, “purge” removes even disabled object, “srch” performs a search. Note that “del” and “srch” may use as a parameter not only the object itself or its identifier, but also the object name.
Starting from version 0.8 the object itself may be a parameter of “add”. Also from this version an optional second parameter is added — position in list. From 0.8 you also can modify the list by the index with the “set” method. For example:
<code>
@ -655,6 +655,10 @@ visited([where]) -- room visit counter (may be nil);
path(obj,[where]) -- lookup in way, even for disabled items;
nameof(obj) -- get object's name (nam attribute);
purge (obj, [where]) -- see remove, deletes even disabled object'
===== 14. Dialogs =====
Dialogs are scenes with phrase objects. The simplest dialog may look like this:

View file

@ -471,9 +471,9 @@ game.use = 'Не сработает...';
Атрибуты списки (такие как way или obj) позволяют работать с собой, таким образом позволяя реализовать динамически определяемые переходы между сценами, живые объекты и т.д.
Методы списков: add, del, look, srch. Из них наиболее часто используемые: add и del.
Методы списков: add, del, look, srch, purge. Из них наиболее часто используемые: add и del.
add - добавляет в список. del -- удаляет из него. srch -- выполняет поиск объекта. Следует отметить, что параметром del и srch может быть не только сам объект или идентификатор объекта, но и имя объекта.
add - добавляет в список. del -- удаляет из него. purge -- удаляет даже выключенный объект. srch -- выполняет поиск объекта. Следует отметить, что параметром del и srch может быть не только сам объект или идентификатор объекта, но и имя объекта.
Начиная с версии 0.8 параметром add может быть сам объект. Кроме того, с этой версии добавляется необязательный второй параметр -- позиция в списке. Начиная с версии 0.8 вы можете также выполнять модификацию списка по индексу с помощью метода set. Например:
<code>
@ -654,6 +654,9 @@ visited([комната]) -- счетчик посещений комнаты и
path(объект,[комната]) -- найти элемент в way, даже если он disabled;
nameof(объект) -- вернуть имя объекта (nam атрибут);
purge (объект, [откуда]) -- см. remove, удаляет даже выключенные объекты;
===== 14. Диалоги =====

View file

@ -24,7 +24,7 @@ function __vars_add(s, v, set)
elseif s.variables[k] then
error ("Variable overwrites variables object: "..tostring(k))
elseif k ~= 'variable_type' then
if set then
if set and type(o) == 'string' or type(o) == 'boolean' or type(o) == 'number' then
if s[k] then
error ("Global variable conflict: "..tostring(k));
end
@ -70,7 +70,7 @@ end
vars_object = obj {
nam = 'vars',
ini = function(s)
-- __vars_fill(_G)
__vars_fill(_G)
__vars_fill(pl)
__vars_fill(game)
end