Yoko

All sides of Injection
It is currently 2025-11-06 23:54:01

All times are UTC+02:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: REPEAT
PostPosted: 2005-05-17 22:39:57 
Offline

Joined: 2005-02-22 20:03:13
Posts: 77
вопрос на засыпку?

sub test()
if uo.life > 0 then
uo.sayu("test")
end if
end sub

а теперь вопрос? как заставить крутится скрипт например 10 раз при помощи Repeat .
за ранее благодарен

_________________
говорила мне мама "учись неуч"


Top
   
 Post subject:
PostPosted: 2005-05-17 23:08:51 
Offline
Expert!

Joined: 2004-04-03 17:36:29
Posts: 2544
Location: Saint-Petersburg
а почему именно при помощи repeat? Для повторения конкретное количество раз есть специальные циклы. В частности, for.

Но если приспичило сделать через repeat - тоже особых проблем нету.

Code:
VAR i=1
repeat
   ...... Сюда ставь свой иф....
   else
   (не забудь добавить в иф else с небольшой паузой, иначе получишь пустой цикл)
   i = i + 1
until i == 10


Top
   
 Post subject:
PostPosted: 2005-05-18 06:56:41 
Offline
Expert!
User avatar

Joined: 2005-04-23 10:19:43
Posts: 388
Пишу все варианты. Может помогут на будущее:

For:
Code:
sub test() 
  for var i=1 to 10 //Создаем переменную i (за это отвечает var) и крутим его от 1 до 10
    if uo.life > 0 then
      uo.sayu("test")
    end if
  next
end sub


While:
Code:
sub test() 
  var i=0 //Создаем i так как с while такой трюк как с for не пройдет
  while i<10
    if uo.life > 0 then
      uo.sayu("test")
    end if
    i=i+1
  wend
end sub


Repeat (был но для коллекции):
Code:
sub test() 
  var i=0 //Создаем i
  repeat
    if uo.life > 0 then
      uo.sayu("test")
    end if
    i=i+1
  until i==10
end sub


Экзотичный вариант: рекурсия:
Code:
sub test(var countleft) 
  var i=0 //Создаем i
    if uo.life > 0 then
      uo.sayu("test")
    end if
  if (countleft>0) then
    test(countleft-1)
  end if
end sub


Top
   
 Post subject:
PostPosted: 2005-05-18 09:02:32 
Offline

Joined: 2005-02-22 20:03:13
Posts: 77
Beyonder ------ зачет! как раз то что надо)
СПАСИБО

_________________
говорила мне мама "учись неуч"


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited