Post by tyreafus on Nov 14, 2005 23:42:58 GMT -5
I'm working on a timer script for Lunar that will allow Windower scripted macros to display up to 6 onscreen countdown timers to be used for monitoring time-til-use on abilities(imagine being a war/mnk and being able to see timers for voke, berserk, defender, boost, and dodge all at once). However I'm looking for a Lua command that I'm sure exists, but I can't seem to find(I'm a beginner ; .
I need a command that will make a while loop pause for 1 second, while leaving the script open to accept function commands from the Windower console. I don't think I can use Windower.script_Sleep(1000) because this will lock the entire script for 1 second, disallowing it to accept commands from the console. Is this true? If so, is there another command I can use?
Here is what I have so far:
What command should I use? Any other suggestions are also welcome.
I need a command that will make a while loop pause for 1 second, while leaving the script open to accept function commands from the Windower console. I don't think I can use Windower.script_Sleep(1000) because this will lock the entire script for 1 second, disallowing it to accept commands from the console. Is this true? If so, is there another command I can use?
Here is what I have so far:
--Global variable initialization, creation of text objects--
global going = true
global on1 = false
global on2 = false
global on3 = false
global on4 = false
global on5 = false
global on6 = false
global label1 = ""
global label2 = ""
global label3 = ""
global label4 = ""
global label5 = ""
global label6 = ""
global time1 = 0
global time2 = 0
global time3 = 0
global time4 = 0
global time5 = 0
global time6 = 0
global t1 = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 0, 100, 100, t1)
Graphics.text_SetPosition(50, 20, t1)
Graphics.text_SetVisibility(false, t1)
global t2 = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 0, 100, 100, t2)
Graphics.text_SetPosition(50, 100, t2)
Graphics.text_SetVisibility(false, t2)
global t3 = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 0, 100, 100, t3)
Graphics.text_SetPosition(50, 180, t3)
Graphics.text_SetVisibility(false, t3)
global t4 = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 0, 100, 100, t4)
Graphics.text_SetPosition(50, 260, t4)
Graphics.text_SetVisibility(false, t4)
global t5 = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 0, 100, 100, t5)
Graphics.text_SetPosition(50, 340, t5)
Graphics.text_SetVisibility(false, t5)
global t6 = Graphics.text_CreateObject()
Graphics.text_SetColor(255, 0, 100, 100, t6)
Graphics.text_SetPosition(50, 20, t6)
Graphics.text_SetVisibility(false, t6)
--functions, to be initialized from the Windower console.-------
function start(timernum, t, label)
if timernum = 1 then
on1 = true
label1 = label
time1 = t
elseif timernum == 2 then
on2 = true
label2 = label
time2 = t
elseif timernum == 3 then
on3 = true
label3 = label
time3 = t
elseif timernum == 4 then
on4 = true
label4 = label
time4 = t
elseif timernum == 5 then
on5 = true
label5 = label
time5 = t
elseif timernum == 6 then
on6 = true
label6 = label
time6 = t
else
Control.control_SendString("/echo Timer.start: invalid timer#.")
end
end
funtion off(tnum)
if tnum == 1 then
on1 = false
Graphics.text_SetVisiblity(false, t1)
elseif tnum == 2 then
on2 = false
Graphics.text_SetVisiblity(false, t2)
elseif tnum == 3 then
on3 = false
Graphics.text_SetVisiblity(false, t3)
elseif tnum == 4 then
on4 = false
Graphics.text_SetVisiblity(false, t4)
elseif tnum == 5 then
on5 = false
Graphics.text_SetVisiblity(false, t5)
elseif tnum == 6 then
on6 = false
Graphics.text_SetVisiblity(false, t6)
else
Control.control_SendString("/echo Timer.off: invalid timer#.")
end
end
--While loop for countdown/update------------------------
while going == true do
if on1 == true then
Graphics.text_SetVisiblity(true, t1)
Graphics.text_SetText(label1 .. ": " .. time1)
end
if on2 == true then
Graphics.text_SetVisibility(true, t2)
Graphics.text_SetText(label1 .. ": " .. time1)
end
if on3 ==true then
Graphics.text_SetVisibility(true, t3)
Graphics.text_SetText(label3 .. ": " .. time3)
end
if on4 == true then
Graphics.text_SetVisibility(true, t4)
Graphics.text_SetText(label4 .. ": " .. time4)
end
if on5 == true then
Graphics.text_SetVisibility(true, t5)
Graphics.text_SetText(label5 .. ": " .. time5)
end
if on6 == true then
Graphics.text_SetVisibility(true, t6)
Graphics.text_SetText(label1 .. ": " .. time6)
end
if time1 > 0 then
time1 = time1 - 1
end
if time2 > 0 then
time2 = time2 - 1
end
if time3 > 0 then
time3 = time3 -1
end
if time4 > 0 then
time4 = time4 - 1
end
if time5 > 0 then
time5 = time5 -1
end
if time6 > 0 then
time6 = time6 - 1
end
Windower.script_Sleep(1000)
--^time command in question--
end
What command should I use? Any other suggestions are also welcome.