раскрыть
toastyTable = {
[1] = { "toasty", "toasty" },
[2] = { "hatehorse", "hatehorse" },
[3] = { "spypeon", "Units\\Orc\\Peon\\PeonWarcry1" },
[4] = { "mush", "nya" }
}
function CreateToasty()
local r = GetRandomInt(1, #toastyTable)
local texture, sound = GetDataFromTable(toastyTable, r)
CreateAndMoveToastyFrame(texture, sound)
end
function CreateAndMoveToastyFrame(texture, sound)
local x, y = 1, 0.1
local toasty = BlzCreateFrameByType('BACKDROP', 'FaceButtonIcon', BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), '', 0)
BlzFrameSetParent(toasty, BlzGetFrameByName("ConsoleUIBackdrop", 0))
BlzFrameSetTexture(toasty, texture, 0, true)
BlzFrameSetSize(toasty, 0.1, 0.1)
BlzFrameSetAbsPoint(toasty, FRAMEPOINT_TOP, x, y)
PlaySound(sound)
--print("запушен референс")
TimerStart(CreateTimer(), 1 / 32, true, function()
x = x - 0.02
if x <= 0.88 then
--print("остановка")
DestroyTimer(GetExpiredTimer())
local showDuration = 0.5
TimerStart(CreateTimer(), showDuration, false, function()
Left2Right(toasty, x, y)
--print("реверс")
end)
else
BlzFrameSetAbsPoint(toasty, FRAMEPOINT_TOP, x, y)
end
end)
end
function Left2Right(frame, x, y)
TimerStart(CreateTimer(), 1 / 32, true, function()
x = x + 0.02
if x >= 1 then
--print("остановка")
DestroyTimer(GetExpiredTimer())
--print("Уничтожить фрейм")
else
BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, x, y)
end
end)
end
function GetDataFromTable(table, index)
if not table[index] then
print("элемент в таблице не существует")
else
return table[index][1],table[index][2]
--table.unpack(table[index])
end
end
Вызывать по Esc, открывается случайный