Ура. Движок для первой половины игры готов.

This commit is contained in:
Alexander Yakovlev 2011-11-28 18:37:27 +07:00
parent d0bd54c0bb
commit 9cf08dff23
3 changed files with 49 additions and 5 deletions

View file

@ -71,14 +71,13 @@ sentence = function(text)
text = string.gsub(text, '%^%^', ' newline ')
array = string.split(text, " ")
objects = {}
j = 1
local j = 1
for i,v in ipairs(array) do
if (table.contains({'colon', 'dot', 'newline', 'opening_bracket', 'closing_bracket', 'space', 'dash', 'exclamation', 'question', 'comma'},v) == false and string.match (v, "%S")) then
if(i > 1) then
table.insert(objects, j, 'space')
j = j + 1
end
print ()
table.insert(objects, j, word(v))
j = j + 1
else
@ -88,7 +87,7 @@ sentence = function(text)
end
end
end
value = obj{
local value = obj{
nam = '',
dsc = '',
obj = objects
@ -140,4 +139,20 @@ function news(v)
table.insert(v.obj, table.maxn(v.obj)+1, 'sign_newspaper_1')
v = obj(v);
return v;
end
function is_activated(previous, current, room)
for i,v in ipairs(room.obj) do
if v ~= nil then
for j,word in ipairs(v.obj) do
if (word ~= nil) then
if (word._word == previous) then
if (v.obj[j+2]._word == current) then --следующее слово _после пробела_
return v.obj[j+2]._enabled;
end
end
end
end
end
end
end

View file

@ -13,7 +13,34 @@ maximov_1 = room{
}
};
maximov_2 = room{
nam = 'г. Красноярск -- Почтовый ящик 107.',
dsc = "",
obj = {
sentence("Дорогой Максим!^^"),
vobj("", txtr('Друг.')),newline,
signed, 'sign_maximov_2'
}
};
sign_maximov_1 = obj{
nam = 'send',
dsc = txtc(txtu('{ОТПРАВИТЬ}')),
act = function()
local i = 2;
if (is_activated("Уважаемый", "господин", maximov_1) == false) then
table.insert(maximov_2.obj, i, sentence("Я не совсем понял, за кого ты меня принимаешь.^^"))
i = i+1
end
if (is_activated("господин", "Цветников", maximov_1) == false) then
table.insert(maximov_2.obj, i, sentence("По правде сказать, я не понял, к кому ты обращался. Мы решили, что ты имел в виду Цветникова -- ему и отдали письмо.^^"))
i = i+1
end
return goto('maximov_2');
end,
}
sign_maximov_2 = obj{
nam = 'send',
dsc = txtc(txtu('{ОТПРАВИТЬ}')),
act = function()

View file

@ -15,11 +15,14 @@ sign_newspaper_1 = obj{
nam = "УТВЕРДИТЬ СТАТЬИ",
dsc = txtc("{УТВЕРДИТЬ ВЫДЕЛЕННЫЕ СТАТЬИ, ОТЛОЖИТЬ ОСТАЛЬНЫЕ}"),
act = function()
Julia = 0
local Julia = 0
for i,headline in ipairs(newspaper_1.obj) do
if(headline._selected) then Julia = Julia + 1 end
end
if (Julia==0) then return true end
if (newspaper_1.obj[1]._selected) then
table.insert(newspaper_2.news, table.maxn(newspaper_2.news), 'Старая метла лучше новой метёт') -- здесь нужно что-то гибче
end
return goto(newspaper_1.goto)
end
}
@ -27,7 +30,6 @@ sign_newspaper_1 = obj{
newspaper_2 = news{
nam = 'Передовица газеты «Чеканный час», номер 57',
news = {
'Старая метла лучше новой метёт',
'Кукурузное посмешище',
'Хулиган вышел из клиники: куда денется истребитель врачей?',
'В НИИ Мягких Игрушек обнаружены серьёзные утечки радиации',