96 lines
2 KiB
Lua
96 lines
2 KiB
Lua
-- Здесь мы настраиваем парсер.
|
|
|
|
mp.msg.SCENE = "{#Me} {#plural/находишься,находитесь} {#if_has/#here,supporter,на,в} {#here/пр,2}.";
|
|
|
|
function split(s, sep)
|
|
if sep == nil then
|
|
sep = ","
|
|
end
|
|
local t={}
|
|
for str in string.gmatch(s, "([^"..sep.."]+)") do
|
|
table.insert(t, str)
|
|
end
|
|
return t
|
|
end
|
|
|
|
local function istable(t) return type(t) == 'table' end
|
|
|
|
-- "Ты/вы" в разных падежах: им, род, дат, вин, твор, пред.
|
|
function mp.shortcut.you(case)
|
|
if case == nil or case == '' then
|
|
case = 'им'
|
|
end
|
|
if case == 'им' then
|
|
if pl.plural then
|
|
return 'вы'
|
|
end
|
|
return 'ты'
|
|
end
|
|
if case == 'род' or case == 'рд' then
|
|
if pl.plural then
|
|
return 'вас'
|
|
end
|
|
return 'тебя'
|
|
end
|
|
if case == 'дат' or case == 'дт' then
|
|
if pl.plural then
|
|
return 'вам'
|
|
end
|
|
return 'тебе'
|
|
end
|
|
if case == 'вин' or case == 'вн' then
|
|
if pl.plural then
|
|
return 'вас'
|
|
end
|
|
return 'тебя'
|
|
end
|
|
if case == 'твор' or case == 'тв' then
|
|
if pl.plural then
|
|
return 'вами'
|
|
end
|
|
return 'тобой'
|
|
end
|
|
if case == 'пред' or case == 'пр' then
|
|
if pl.plural then
|
|
return 'вас'
|
|
end
|
|
return 'тебе'
|
|
end
|
|
return 'ты'
|
|
end
|
|
|
|
function mp.shortcut.plural(options)
|
|
if not istable(options) then
|
|
options = split(options)
|
|
end
|
|
|
|
if pl.plural then
|
|
return options[2]
|
|
end
|
|
return options[1]
|
|
end
|
|
|
|
-- {#g/singlefem,singlemasc,singleother,plural}
|
|
function mp.shortcut.g(options)
|
|
if not istable(options) then
|
|
options = split(options)
|
|
end
|
|
if #options == 2 then
|
|
return mp.shortcut.plural(options)
|
|
end
|
|
|
|
if pl.plural then
|
|
return options[4]
|
|
end
|
|
if pl.pronouns == 'fem' then
|
|
return options[1]
|
|
end
|
|
if pl.pronouns == 'masc' then
|
|
return options[2]
|
|
end
|
|
if pl.pronouns == 'other' then
|
|
return options[3]
|
|
end
|
|
return options[1]
|
|
end
|