Версия для печати темы

Нажмите сюда для просмотра этой темы в обычном формате

UoKit.com Форумы _ UO Pilot _ lua timer

Автор: TheQQmaster 16.2.2021, 1:28

i checked lua examples
https://uopilot.uokit.com/wiki/index.php?title=Timer_(Lua)

i dont want to wait on while loop, i want that it do like example on pilots language, it do on start and then after x time passed it do it again and go to next block
it need for if statement
any examples?

Код
--lua
repeat
// do something on script start and then after is x time passed
// do next block
until false


Код

:start
if  #timeStance < timer //stances
//do smth on start, then after 14 sec passed he do this block again
      set #timeStance timer + 1000 * 60 * 14
end_if
//more blocks with if timers
goto start

P.S mby that teme was but it's hard to search on russian forum if it isn't native language, if such topic exist, link please smile.gif

Автор: cirus 16.2.2021, 2:13

Код
--lua
log 'clear' log 'mode compact'
local t1 = 0
local t2 = 0
local t3 = 0

while true do
    if os.clock() > t1 then
        log ('action 1')
        t1 = os.clock() + 3
    end
    if os.clock() > t2 then
        log ('action  2')
        t2 = os.clock() + 10
    end
    if os.clock() > t3 then
        log ('action   3')
        t3 = os.clock() + 1
    end
    wait(10)
end

Автор: TheQQmaster 16.2.2021, 17:10

thank you again

what is diffrence in thoose loops and what is better to use and why u use exactly while
пиши на русском

p.s as far i get repeat it will run atleast 1 time, while it will not run on start if false, am i right?


Код

--lua
while true do
end

repeat
until false


Автор: DarkMaster 16.2.2021, 23:36

while check condition before start cycle, repeat - after. You are right, repeat will run minimum 1 time.
"Repeat" will work up to "true", "while" will work up to "false", then script will go to next block of code.

Русская версия Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)