2011-11-15 09:42:48 +02:00
|
|
|
|
function room_scene(self) return true; end
|
|
|
|
|
|
2011-11-17 10:26:23 +02:00
|
|
|
|
function par(space,...)
|
|
|
|
|
local i, res
|
|
|
|
|
local a = {...};
|
|
|
|
|
for i = 1, stead.table.maxn(a) do
|
|
|
|
|
if type(a[i]) == 'string' then
|
|
|
|
|
if res == nil then res = "" end
|
|
|
|
|
res = res..a[i];
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return res;
|
|
|
|
|
end
|
|
|
|
|
stead.par = par
|
|
|
|
|
|
2011-11-20 18:39:23 +02:00
|
|
|
|
word = function(word)
|
2011-11-15 09:42:48 +02:00
|
|
|
|
return obj{
|
|
|
|
|
nam = '',
|
|
|
|
|
_word = word,
|
|
|
|
|
_enabled = true,
|
|
|
|
|
dsc = function(this)
|
|
|
|
|
value = ""
|
|
|
|
|
if (this._enabled == true) then
|
|
|
|
|
value = this._word
|
|
|
|
|
else
|
|
|
|
|
value = string.rep("█",string.len(this._word)/2)
|
|
|
|
|
end
|
|
|
|
|
return "{".. value .."}"
|
|
|
|
|
end,
|
|
|
|
|
act = function(this)
|
|
|
|
|
this._enabled = not this._enabled
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
}
|
2011-11-15 10:27:39 +02:00
|
|
|
|
end
|
2011-11-20 18:39:23 +02:00
|
|
|
|
function table.contains(table, element)
|
|
|
|
|
for _, value in pairs(table) do
|
|
|
|
|
if value == element then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
function string.split(str, pat)
|
|
|
|
|
local t = {}
|
|
|
|
|
local fpat = "(.-)" .. pat
|
|
|
|
|
local last_end = 1
|
|
|
|
|
local s, e, cap = str:find(fpat, 1)
|
|
|
|
|
while s do
|
|
|
|
|
if s ~= 1 or cap ~= "" then
|
|
|
|
|
table.insert(t,cap)
|
|
|
|
|
end
|
|
|
|
|
last_end = e+1
|
|
|
|
|
s, e, cap = str:find(fpat, last_end)
|
|
|
|
|
end
|
|
|
|
|
if last_end <= #str then
|
|
|
|
|
cap = str:sub(last_end)
|
|
|
|
|
table.insert(t, cap)
|
|
|
|
|
end
|
|
|
|
|
return t
|
|
|
|
|
end
|
|
|
|
|
sentence = function(text)
|
2011-11-21 13:59:27 +02:00
|
|
|
|
text = string.gsub(text, '%!', ' exclamation space ')
|
|
|
|
|
text = string.gsub(text, '%,', ' comma ')
|
|
|
|
|
text = string.gsub(text, '%:', ' colon ')
|
2011-11-20 18:39:23 +02:00
|
|
|
|
text = string.gsub(text, '%.', ' dot space')
|
2011-11-21 13:59:27 +02:00
|
|
|
|
text = string.gsub(text, '%(', ' space opening_bracket ')
|
|
|
|
|
text = string.gsub(text, '%)', ' closing_bracket space ')
|
|
|
|
|
text = string.gsub(text, '%?', ' question space ')
|
|
|
|
|
text = string.gsub(text, '%-%-', ' space dash ')
|
|
|
|
|
text = string.gsub(text, '%^%^', ' newline ')
|
2011-11-20 18:39:23 +02:00
|
|
|
|
array = string.split(text, " ")
|
|
|
|
|
objects = {}
|
2011-11-28 13:37:27 +02:00
|
|
|
|
local j = 1
|
2011-11-20 18:39:23 +02:00
|
|
|
|
for i,v in ipairs(array) do
|
2011-11-21 13:59:27 +02:00
|
|
|
|
if (table.contains({'colon', 'dot', 'newline', 'opening_bracket', 'closing_bracket', 'space', 'dash', 'exclamation', 'question', 'comma'},v) == false and string.match (v, "%S")) then
|
2011-11-20 18:39:23 +02:00
|
|
|
|
if(i > 1) then
|
|
|
|
|
table.insert(objects, j, 'space')
|
|
|
|
|
j = j + 1
|
|
|
|
|
end
|
|
|
|
|
table.insert(objects, j, word(v))
|
|
|
|
|
j = j + 1
|
|
|
|
|
else
|
2011-11-21 13:59:27 +02:00
|
|
|
|
if (string.match (v, "%S")) then
|
|
|
|
|
table.insert(objects, j, v)
|
|
|
|
|
j = j + 1
|
|
|
|
|
end
|
2011-11-20 18:39:23 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2011-11-28 13:37:27 +02:00
|
|
|
|
local value = obj{
|
2011-11-17 10:26:23 +02:00
|
|
|
|
nam = '',
|
|
|
|
|
dsc = '',
|
2011-11-20 18:39:23 +02:00
|
|
|
|
obj = objects
|
2011-11-17 10:26:23 +02:00
|
|
|
|
}
|
|
|
|
|
return value
|
|
|
|
|
end
|
2011-11-15 10:27:39 +02:00
|
|
|
|
newline = vobj("^^", "^^")
|
|
|
|
|
space = vobj(" ", " ")
|
2011-11-20 19:00:30 +02:00
|
|
|
|
opening_bracket = vobj(" ", "(")
|
|
|
|
|
closing_bracket = vobj(" ", ")")
|
2011-11-17 10:26:23 +02:00
|
|
|
|
dash = vobj("--", "--")
|
|
|
|
|
comma = vobj(",", ",")
|
|
|
|
|
dot = vobj(".", ".")
|
|
|
|
|
exclamation = vobj("!", "!")
|
2011-11-19 07:18:10 +02:00
|
|
|
|
question = vobj("?", "?")
|
|
|
|
|
colon = vobj(":", ":")
|
2011-11-21 17:14:50 +02:00
|
|
|
|
signed = vobj(" ", txtr("Проверено: цензор ███████████^^"))
|
|
|
|
|
|
|
|
|
|
function headline(text)
|
|
|
|
|
return obj{
|
|
|
|
|
nam="",
|
|
|
|
|
_selected = false,
|
|
|
|
|
dsc = function(this)
|
|
|
|
|
if (this._selected) then
|
|
|
|
|
return "• {" .. txtb(text) .. "}" .. "\t\t\t" .. [[^]]
|
|
|
|
|
end
|
|
|
|
|
return "• {" .. text .. "}" .. "\t\t\t" .. [[^]]
|
|
|
|
|
end,
|
|
|
|
|
act = function(this)
|
|
|
|
|
this._selected = not this._selected
|
|
|
|
|
return true
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function news(v)
|
|
|
|
|
if v.news == nil then v.news = {} end
|
|
|
|
|
if v.dsc == nil then v.dsc = "" end
|
|
|
|
|
if v.way == nil then v.way = {} end
|
|
|
|
|
if v.obj == nil then v.obj = {} end
|
|
|
|
|
if v.look == nil then v.look = room_look end
|
|
|
|
|
if v.save == nil then v.save = room_save end
|
|
|
|
|
if v.scene == nil then v.scene = room_scene end
|
|
|
|
|
v.way = list(v.way);
|
|
|
|
|
v.location_type = true
|
|
|
|
|
for i,text in ipairs(v.news) do
|
|
|
|
|
table.insert(v.obj, i, headline(text))
|
|
|
|
|
end
|
|
|
|
|
table.insert(v.obj, table.maxn(v.obj)+1, 'sign_newspaper_1')
|
|
|
|
|
v = obj(v);
|
|
|
|
|
return v;
|
2011-11-28 13:37:27 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function is_activated(previous, current, room)
|
|
|
|
|
for i,v in ipairs(room.obj) do
|
|
|
|
|
for j,word in ipairs(v.obj) do
|
2011-11-28 13:47:03 +02:00
|
|
|
|
if (word._word ~= nil) then
|
|
|
|
|
if (previous ~= nil) then
|
|
|
|
|
if (word._word == previous) then
|
|
|
|
|
if (v.obj[j+2]._word == current) then --следующее слово _после пробела_
|
|
|
|
|
return v.obj[j+2]._enabled
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if (word._word == current) then
|
|
|
|
|
return word._enabled
|
2011-11-28 13:37:27 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2011-11-21 17:14:50 +02:00
|
|
|
|
end
|