|
grandMA3 ユーザマニュアル » プラグイン » Lua 関数 - Object-Free API » Timer(string, integer, integer[, string[, handle]]) |
Version 2.2 |
Timer 関数は、タイマーを用いて別の関数を呼び出します。他の関数は、タイマー間隔を用いて複数回呼び出せます。
この関数は何も返しません。
メッセージを3回出力し、クリーンアップ関数を呼び出します。
Lua |
-- Function that will be called several times. function TimedFunction() -- Check the value of RunAmount and print something. if RunAmount < 1 then Printf("Hello") else Printf("Hello again") end -- Add 1 to the RunAmount variable. RunAmount = RunAmount + 1 end -- Cleanup function. function TimerCleanup() Printf("Goodbye") -- Delete the RunAmount variable. RunAmount = nil end -- Function with the Timer call. function Main() -- Set a wait variable. local waitSeconds = 1 -- Set a variable with the number of iterations. local iterations = 3 -- Create a counter variable and set it to 0. RunAmount = 0 -- Call the timer function. Timer(TimedFunction, waitSeconds, iterations, TimerCleanup); end -- call the main function. return Main |