# HG changeset patch # User Silverwing # Date 2017-06-24 08:30:22 # Node ID e4ecbb8dc309038a003ec4f9ed2077b8301ae23e # Parent 61a5987f06f0020f79b72992ffeed2f7775e8ff7 Coder diff --git a/items.lua b/items.lua --- a/items.lua +++ b/items.lua @@ -578,6 +578,7 @@ item_talk_device = obj { item_suit = suit { dlg = "call_leviathan"; nam = "Скафандр"; + has_coder = true; }; item_deep_key = obj { diff --git a/utils.lua b/utils.lua --- a/utils.lua +++ b/utils.lua @@ -440,6 +440,126 @@ function input_number_nav(tab) return room(tab); end; +function input_alphabet_nav(tab) + if (not tab.maxlen) then + tab.maxlen = "16"; + end; + tab.forcedsc = true; + tab.noinv = true; + tab.input = ""; + tab.dsc = function(s) + pr(tab.label .. tab.input .. "_"); + return false; + end; + tab.entered = function(s) + s.input = ""; + hook_keys('0', '1', '2', '3', '4', '5', + 'a', 'd', 'e', 'f', 'h', 'i', 'j', 'k', 'l', 'n', 'p', 'r', 's', 't', 'v', 'y', 'z',"'",'space', + 'backspace', 'return', 'escape'); + end; + tab.left = function(s) + unhook_keys('0', '1', '2', '3', '4', '5', + 'a', 'd', 'e', 'f', 'h', 'i', 'j', 'k', 'l', 'n', 'p', 'r', 's', 't', 'v', 'y', 'z',"'",'space', + 'backspace', 'return', 'escape'); + end; + tab.kbd = function(s, down, key) + if (not down) then + if (key == "escape") then + back(); + elseif (key == "return") then + if (s.input) then + s:check(s.input); + end; + elseif (key == "backspace") then + if (s.input:len() > 0) then + s.input = s.input:sub(1, s.input:len() - 1); + end; + else + if (string.len(s.input) < s.maxlen) then + s.input = s.input .. key; + -- hide buttons :) + end; + end; + end; + pr(""); + end; + tab.obj = { + "_kh_input1", + "_kh_input2", + "_kh_input3", + "_kh_input4", + "_kh_input5", + "_kh_inputa", + "_kh_inputd", + "_kh_inpute", + "_kh_inputf", + "_kh_inputh", + "_kh_inputi", + "_kh_inputj", + "_kh_inputk", + "_kh_inputl", + "_kh_inputn", + "_kh_inputp", + "_kh_inputr", + "_kh_inputs", + "_kh_inputt", + "_kh_inputv", + "_kh_inputy", + "_kh_inputz", + "_kh_inputhp", + "_kh_inputsp", + "_kh_backspace", + "_kh_cancel", + "_kh_enter" + }; + return room(tab); +end; + +_kh_input_key = function(key, key_text) + if not key_text then + key_text = key; + end; + return obj { + nam = "_kh_input" .. key; + dsc = "{" .. key_text .. "}"; + act = function(s) + if (here().input:len() < here().maxlen) then + here().input = here().input .. key; + end; + return ""; + end; + }; +end; + +_kh_inputa = _kh_input_key("a"); +_kh_inputb = _kh_input_key("b"); +_kh_inputc = _kh_input_key("c"); +_kh_inputd = _kh_input_key("d"); +_kh_inpute = _kh_input_key("e"); +_kh_inputf = _kh_input_key("f"); +_kh_inputg = _kh_input_key("g"); +_kh_inputh = _kh_input_key("h"); +_kh_inputi = _kh_input_key("i"); +_kh_inputj = _kh_input_key("j"); +_kh_inputk = _kh_input_key("k"); +_kh_inputl = _kh_input_key("l"); +_kh_inputm = _kh_input_key("m"); +_kh_inputn = _kh_input_key("n"); +_kh_inputo = _kh_input_key("o"); +_kh_inputp = _kh_input_key("p"); +_kh_inputq = _kh_input_key("q"); +_kh_inputr = _kh_input_key("r"); +_kh_inputs = _kh_input_key("s"); +_kh_inputt = _kh_input_key("t"); +_kh_inputu = _kh_input_key("u"); +_kh_inputv = _kh_input_key("v"); +_kh_inputw = _kh_input_key("w"); +_kh_inputx = _kh_input_key("x"); +_kh_inputy = _kh_input_key("y"); +_kh_inputz = _kh_input_key("z"); +_kh_inputsp = _kh_input_key(" ", "Пробел"); +_kh_inputhp = _kh_input_key("'", "'"); + _kh_input1 = obj { nam = "_kh_input1"; dsc = "{1}"; @@ -616,12 +736,33 @@ function obscured_obj(nam, dsc_a, act_a, }; end; +_atlantis_coder = input_alphabet_nav { + nam = "Кодировщик"; + maxlen = 32; + label = "Сообщение:"; + check = function(s, input) + if type(_atlantis_suit_menu._here.checkCoder) == "function" then + pn(_atlantis_suit_menu._here:checkCoder()); + else + pn [[Лампочки кодировщика зажигаются в заданной последовательности, но ничего не происходит. ]]; + end; + back(); + end; +}; + _atlantis_suit_menu = dlg { nam = "Скафандр"; _item = nil; dsc = [[ Что вы хотите сделать? ]]; + entered = function(s) + if (s._item.has_coder) then + pon(2); + else + poff(2); + end; + end; phr = { {1, always = "true", "Использовать рацию", function(s) local val = EngineUtils.getValue(_atlantis.suit_menu._item.dlg, _atlantis.suit_menu._item); @@ -633,7 +774,8 @@ end; return "Никто не отвечает"; end; end}; - {2, always = "true", "Снять скафандр", function(s) + {2, always = "true", "Использовать кодировщик", code [[ walkin("_atlantis_coder"); ]]}; + {3, always = "true", "Снять скафандр", function(s) if (EngineUtils.getValue(_atlantis_suit_menu._item.cantakeoff, _atlantis_suit_menu._item)) then drop(_atlantis._uit_menu._item); back(); @@ -643,7 +785,7 @@ end; return "Вы не можете снять скафандр сейчас"; end; end}; - {3, always = "true", "Отмена", function(s) + {4, always = "true", "Отмена", function(s) back(); return ""; end}; @@ -653,6 +795,7 @@ end; _atlantis = { suit_inv = function(s) _atlantis_suit_menu._item = s; + _atlantis_suit_menu._here = here(); walkin(_atlantis_suit_menu); end; };