Котовод 108 Опубликовано 8 Февраля 2022 Ребята, есть какой-то способ принудительного обновления диалогов такого типа? В НЛС они формируются при первой загрузке сейва, что мне не подходит... <dialog id="vergas_repair_dialog" priority="-1"> <precondition>dialogs.is_not_wounded</precondition> <init_func>sak_dialog.vergas_repair_dlg</init_func> </dialog> Скрытый текст local vergas_tbl = {} local vergas_bad_tbl = {} function generate_vergas_tbl() local items = get_shadow_inv():get_content( true ) for i, rec in items:ipairs() do local sect = sak_inventory.dyn_art_base( rec.sect ) if ( ( rec.obj:is_weapon() and rec.obj:condition() >= 0.65 and rec.obj:condition() < 1 and not ( str_in_tab( sect, { "wpn_binoc", "wpn_knife", "wpn_flame", "wpn_rpg7", "wpn_pkm", "wpn_gm94", "wpn_ak74_m1" } ) ) ) or ( rec.obj:is_outfit() and rec.obj:condition() >= 0.59 and rec.obj:condition() < 1 and not ( str_in_tab( sect, { "_q_", "bandit_veteran_", "bandit_master_", "exo" } ) ) ) ) then local cfg = this.repair_config[ r_vergas ] if not cfg then wprintf( "[~T].~C0C #ERROR(uniform_repair_cost):~C07 not specified configuration for repairer~C0A %s~C07", r_vergas ) misc.dump_table( this.repair_config ) return end local item_repair_cost = this.calc_repair_cost( rec.obj, this.get_margin( r_vergas ) ) local time_need_repair = this.uniform_time_repair( item_repair_cost, rec.obj:cost(), cfg.price_coefs, cfg.time_repair ) local time_rep = this.time_desc( time_need_repair ) local cost_phrase = "list_trader_repair_" .. lua_random( 1, 7 ) local text = translate( cost_phrase ) .. " %c[255,238,155,23]" .. item_repair_cost .. " %c[255,216,186,140]рублей. " .. time_rep .." ".. translate( "list_time_repair_2" ) table.insert( vergas_tbl, { obj = rec.obj:id(), sect = sect, cost = item_repair_cost, time_need = time_need_repair, text = text } ) -- misc.dump_table( vergas_tbl ) elseif ( ( rec.obj:is_weapon() and rec.obj:condition() < 0.65 ) or ( rec.obj:is_outfit() and rec.obj:condition() < 0.59 ) ) or str_in_tab( sect, { "wpn_flame", "wpn_rpg7", "wpn_pkm", "wpn_gm94", "wpn_ak74_m1", "_q_", "bandit_veteran_", "bandit_master_", "exo" } ) then table.insert( vergas_bad_tbl, sect ) misc.dump_table( vergas_bad_tbl ) end end end function show_not_available() if #vergas_bad_tbl < 1 then return end local text = "" local colour = "%c[ 255, 255, 255, 255 ]" for kk, vv in pairs( vergas_bad_tbl ) do if kotovod.have_selected_item( vv, 1 ) then text = text .. " • " .. colour .. get_inv_name( vv ) .. "\\n" .. "%c[default]" end end local last = "Так-с, ну... В общем, могу подлатать всё, кроме этих экземпляров: \\n" .. text .. "" db.actor:give_talk_message( last, "ui\\ui_iconsTotal", Frect():set( 0, 0, 0, 0), "simple_answer_item" ) vergas_bad_tbl = {} end function vergas_repair_items( dlg ) local phr = task_manager.Dlg_AddPhrase( dlg, "Здравствуй, не мог бы ты подсобить с ремонтом?", "0", "", -10000 ) local phrase_script = phr:GetPhraseScript() phrase_script:AddAction( "sak_dialog.generate_vergas_tbl" ) phr = task_manager.Dlg_AddPhrase( dlg, "Давай посмотрим, что там у тебя.", "1", "0", -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddDontHasInfo( "vergas_repair_starting" ) phrase_script:AddPrecondition( "sak_dialog.klava_done()" ) phrase_script:AddAction( "sak_dialog.show_not_available" ) for k, v in pairs( vergas_tbl ) do -- Наличие и название предмета phr = task_manager.Dlg_AddPhrase( dlg, "".. get_inv_name ( v.sect ) ..".", k + 1, "1", -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddPrecondition( "kotovod.have_selected_item( \"".. v.sect .."\", 1 )" ) -- Цена составит phr = task_manager.Dlg_AddPhrase( dlg, v.text, k + 100, k + 1, -10000 ) phrase_script = phr:GetPhraseScript() -- Согласен phr = task_manager.Dlg_AddPhrase( dlg, "Хорошо, я согласен. Вот деньги.", k + 1000, k + 100, -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddPrecondition( "sak_dialog.money_have( ".. v.cost .." )" ) phrase_script:AddAction( "sak_dialog.relocate_money( ".. v.cost ..", 'out' )" ) phrase_script:AddAction( "sak_dialog.vergas_repair_start( ".. v.time_need ..", \"".. v.sect .."\", ".. v.obj .." )" ) -- Отказ phr = task_manager.Dlg_AddPhrase( dlg, "Может в другой раз...", k + 2000, k + 100, -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddAction( "dialogs.break_dialog" ) end phr = task_manager.Dlg_AddPhrase( dlg, "Я немного занят. Ты лучше попозже загляни...", "200", "0", -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddHasInfo( "vergas_repair_starting" ) phrase_script:AddPrecondition( "sak_dialog.klava_done()" ) phr = task_manager.Dlg_AddPhrase( dlg, "Позже, так позже...", "201", "200", -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddAction( "dialogs.break_dialog" ) phr = task_manager.Dlg_AddPhrase( dlg, "А мне вроде кто-то обещал за блокнот починенный что-то? Слово держать нужно.", "300", "0", -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddPrecondition( "sak_dialog.not_klava_done()" ) phr = task_manager.Dlg_AddPhrase( dlg, "Ну ладно, будет тебе \"что-то\".", "301", "300", -10000 ) phrase_script = phr:GetPhraseScript() phrase_script:AddAction( "dialogs.break_dialog" ) end function vergas_repair_start( time_need, sect, obj ) -- log2( "time_need is %s, sect is %s, obj is %s", tostring( time_need ), tostring( sect ), tostring( obj ) ) local cfg = this.repair_config[ r_vergas ] if cfg.info_start then db.actor:give_info_portion( cfg.info_start ) end if t_repair[ r_vergas ] == nil then t_repair[ r_vergas ] = {} end sak.relocate_item( "out", sect, 1 ) t_repair[ r_vergas ].time_need = time_need t_repair[ r_vergas ].time_end = misc.game_time_minutes() + time_need t_repair[ r_vergas ].section = sect local obj = client_obj( obj ) if obj:is_outfit() then misc.release_obj( obj ) else kotovod.release_addons_new( obj, sect, obj ) misc.release_obj( obj ) end end function vergas_repair_dlg( dlg ) vergas_repair_items( dlg ) end Поделиться этим сообщением Ссылка на сообщение