Как исправить неисчезающий текст на экране?
Вопрос
Как исправить неисчезающий текст на экране?
Ответ
Для исправления неисчезающего текста на экране выполните следующие шаги:
1. Обновите функцию `SetHudMsg` в _G, чтобы она корректно удаляла сообщение после заданного времени:
```lua
function SetHudMsg(msg,n)
msg = tostring(msg)
local hud = get_hud()
if (hud) then
hud:AddCustomStatic("not_enough_money_mine", true)
hud:GetCustomStatic("not_enough_money_mine"):wnd():TextControl():SetTextST(msg)
end
bind_stalker.ShowMessageTime = time_global() + n*1000
end
- Обновите функцию
reinitвbind_stalker, чтобы она корректно удаляла сообщение:
function actor_binder:reinit()
bind_stalker.ShowMessageTime = nil
function actor_binder:reinit() ...
local function check_hud_msg()
if (bind_stalker.ShowMessageTime) then
local hud = get_hud()
if (hud) then
local custom_static = hud:GetCustomStatic("not_enough_money_mine")
if custom_static ~= nil and time_global() > bind_stalker.ShowMessageTime then
hud:RemoveCustomStatic("not_enough_money_mine")
bind_stalker.ShowMessageTime = nil
end
end
end
return false
end
...
end```
3. Убедитесь, что вы корректно вызываете функцию `SetHudMsg`:
```lua
if math.random(1,100) <= (Probability*100) then
...
else
SetHudMsg(game.translate_string("st_cant_cut_monster_part"),5)
end```
4. Убедитесь, что вызовы функций через рестриктор корректны и сообщения удаляются по завершении времени.