220 lines
7.7 KiB
Lua
220 lines
7.7 KiB
Lua
-- Здесь мы настраиваем парсер.
|
||
local mrd = require "morph/mrd"
|
||
local msg = dprint or print
|
||
|
||
mp.msg.SCENE = "{#You} {#plural/находишься,находитесь} {#if_has/#here,supporter,на,в} {#here/пр,2}.";
|
||
mp.msg.Exam.DEFAULT = "{#You} не {#g/видишь,видите} {#vo/{#first/пр}} ничего необычного.";
|
||
mp.msg.LookUnder.NOTHING = "{#You} не {#g/находишь,находите} под {#first/тв} ничего интересного."
|
||
mp.msg.Enter.INV = "Нельзя зайти в то, что {#me} {#g/держишь,держите} в руках."
|
||
mp.msg.Open.OPEN = "{#You} {#g/открываешь,открываете} {#first/вн}."
|
||
mp.msg.Open.CLOSE = "{#You} {#g/закрываешь,закрываете} {#first/вн}."
|
||
mp.msg.Take.HAVE = "У {#you/вн} и так {#firstit} уже есть."
|
||
mp.msg.Take.SELF = "{#You} есть у {#you/рд}."
|
||
mp.msg.Take.TAKE = '{#You} {#g/берёшь,берёте} {#first/вн}.';
|
||
mp.msg.Drop.SELF = "У {#you/рд} не хватит ловкости."
|
||
mp.msg.Insert.INSERT = "{#You} {#g/кладёшь,кладёте} {#first/вн} в {#second/вн}."
|
||
mp.msg.PutOn.PUTON = "{#You} {#g/кладёшь,кладёте} {#first/вн} на {#second/вн}."
|
||
mp.msg.SwitchOn.SWITCHON = "{#You} {#g/включаешь,включаете} {#first/вн}."
|
||
mp.msg.SwitchOff.SWITCHOFF = "{#You} {#g/выключаешь,выключаете} {#first/вн}."
|
||
mp.msg.Sing.SING = "Это лучше оставить оперным певцам."
|
||
mp.msg.SwitchOn.SWITCHON = "{#You} {#g/включаешь,включаете} {#first/вн}."
|
||
mp.msg.Smell.SMELL = "Запах очень забытых вещей."
|
||
mp.msg.Smell.SMELL2 = "Не {#g/волнуйся,волнуйтесь}, у {#you/рд} не пропало чувство запаха. Просто это ничем особенным не пахнет."
|
||
mp.msg.Taste.TASTE = "Не {#g/волнуйся,волнуйтесь}, у {#you/рд} не пропало чувство вкуса. Просто это не съедобно.";
|
||
mp.msg.Sleep.SLEEP = "Не спится."
|
||
mp.msg.Jump.JUMP = "Прыг-скок. Не помогает."
|
||
mp.msg.Consult.CONSULT = "{#You} не {#g/находишь,находите} ничего подходящего."
|
||
mp.msg.Cut.CUT = "В этой игре есть только команда ВЫРЕЗАТЬ (что-то) ИЗ (чего-то)."
|
||
mp.msg.Cut.CUT2 = "В этой игре есть только команда ВЫРЕЗАТЬ (что-то) ИЗ (чего-то)."
|
||
mp.msg.Eat.EAT = "{#You} {#g/съедаешь,съедаете} {#first/вн}."
|
||
mp.msg.WaveHands.WAVE = "{#You} глупо {#g/машешь,машете} руками."
|
||
mp.msg.Wave.WAVE = "{#You} глупо {#word/машешь,машете} {#first/тв}."
|
||
|
||
local 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
|
||
|
||
local function HasChar(str, skipc)
|
||
if type(str) ~= 'string' then
|
||
return false
|
||
end
|
||
return (string.find(str, skipc) ~= nil)
|
||
end
|
||
|
||
local function StrCut(str, skipc)
|
||
if type(str) ~= 'string' then
|
||
return str
|
||
end
|
||
return str:gsub(skipc, '')
|
||
end
|
||
|
||
Verb {
|
||
"#Shoot",
|
||
'вырез/ать',
|
||
'~ * из {noun}/рд,scene : SetShoot',
|
||
}
|
||
|
||
function mp:SetShoot(what, letter)
|
||
if not pl:have('letterremover') then
|
||
return 'Нечем.';
|
||
end
|
||
if (what:has 'animate') then
|
||
return 'Вырезатель не работает на живых.';
|
||
end
|
||
if (what:has 'essential') then
|
||
return 'Это слишком полезная вещь, чтобы её вырезать.';
|
||
end
|
||
if type(letter) ~= 'string' then
|
||
return 'Вырезатель можно установить только на букву.';
|
||
end
|
||
-- string.len считает байты, а надо символы; utf8.len в инстеде не работает
|
||
if #(letter):gsub('[\128-\191]', '') == 0 then
|
||
return 'Вырезатель можно установить только на букву русского алфавита.';
|
||
end
|
||
if #(letter):gsub('[\128-\191]', '') > 1 then
|
||
return 'Вырезатель можно установить только на одну букву.';
|
||
end
|
||
local lcaseletter = mrd.lang.lower(letter);
|
||
if what.canonical == nil or what.canonical == '' then
|
||
what.canonical = what.word
|
||
end
|
||
if not HasChar(what.canonical, lcaseletter) then
|
||
return 'Вырезатель настроен на букву '..letter..', которой нет в слове «'..what.canonical..'».';
|
||
end
|
||
local newCanonical = StrCut(what.canonical, lcaseletter);
|
||
local newTarget = lookup(newCanonical);
|
||
if not newTarget then
|
||
-- продолжаем поиск полным перебором
|
||
std.for_each_obj(function(v)
|
||
if v.canonical == newCanonical then
|
||
newTarget = v
|
||
return;
|
||
end
|
||
end)
|
||
end
|
||
if newTarget then
|
||
if (newTarget:has 'animate') then
|
||
return 'Вырезатель не может создать живое существо ('.. newTarget:noun('вн').. ') из неживого предмета ('.. what:noun('рд')..').';
|
||
end
|
||
what:remove();
|
||
put(newTarget, here());
|
||
p('Вы стреляете в '.. what:noun'вн' ..', и '..what:it('им')..' ');
|
||
if what:hint'plural' then
|
||
p 'вырезаются'
|
||
else
|
||
p 'вырезается'
|
||
end
|
||
pn (' в '..newTarget:noun'вн'..'.');
|
||
if newTarget.oncreate ~= nil then
|
||
newTarget.oncreate()
|
||
end
|
||
return;
|
||
end
|
||
local retval = ('{#You} {#g/стреляешь,стреляете} в '.. what:noun'вн' .. ' и '..what:it('им')..' ');
|
||
|
||
if what:hint'plural' then
|
||
retval = retval .. 'мигают'
|
||
else
|
||
retval = retval .. 'мигает'
|
||
end
|
||
retval = retval .. ' в слабом тумане букв «'..newCanonical..'», но затем ';
|
||
|
||
if what:hint'plural' then
|
||
retval = retval .. 'возвращаются'
|
||
else
|
||
retval = retval .. 'возвращается'
|
||
end
|
||
|
||
retval = retval .. ' в прежнее состояние.';
|
||
return retval;
|
||
|
||
end
|