Page 1 of 1
Циклы и массивы в Injection=)
Posted: 2008-08-04 07:32:32
by skazo4nik
Вопрос таков - к примеру, есть такая штука
Code: Select all
UO.WaitMenu ('Blacksmithing', 'Weapons', 'Weapons','Swords & Blades','Swords & Blades', 'cutlass (8 iron ingot)')
Можно ли каким-то образом забить массив и потом его перебрать, - или же прям туда запихнуть?
Что-то типа как в перле
uo.waitmenu("'".join("','",@x)."'");
?=)
Posted: 2008-08-04 08:27:19
by Scripts Writer
Code: Select all
sub inscription()
Var blanc='0x0E34' # тип бланка
Var food='0x097B' # тип еды
Var sunduk=0x4027308F # ИД где лежат реги и бланки
Var a, k, z, f
Var b='Cure' # Имя вашего скрола
Var msg='You put'
Var msg1='You fail'
Var MaxWeight= 600
Var scroll='0x1F37' # Тип нарисованного скрола
a = 2 # !!!Круг в котором находится ваш спел!!!
DIM reg[9]
reg[0]=0x0F88
reg[1]=0x0F85
reg[2]=0x0F84
reg[3]=0x0F8C
reg[4]=0x0F8D
reg[5]=0x0F7B
reg[6]=0x0F7A
reg[7]=0x0F86
reg[8]=0x0E34
UO.UseObject(sunduk)
wait(1000)
if a==1 then
k = 'First'
uo.Print(' First Circles ')
end if
if a==2 then
k = 'Second'
uo.Print(' Second Circles ')
end if
if a==3 then
k = 'Third'
uo.Print(' Third Circles ')
end if
if a==4 then
k = 'Fourth'
uo.Print(' Fourth Circles ')
end if
if a==5 then
k = 'Fifth
uo.Print(' Fives Circles ')
end if
if a==6 then
k = 'Sixth'
uo.Print(' Sixth Circles ')
end if
if a==7 then
k = 'Seventh'
uo.Print(' Seventh Circles ')
end if
if a==8 then
k = 'Eighth'
uo.Print(' Eighth Circles ')
end if
while not uo.Dead()
for f=0 to 8
if uo.Count(reg[f]) < 1 then
uo.FindType(reg[f],'-1',sunduk)
if UO.FindCount() > 0 then
uo.moveitem('finditem','100')
wait(1000)
else
UO.Print('There are no regs!!!')
uo.exec("terminate inscription")
end if
end if
next
uo.WaitMenu('Spell',k,a,b)
uo.UseType(blanc)
z = 0
uo.DeleteJournal()
repeat
wait(500)
z = z + 1
until uo.InJournal(msg) or uo.InJournal(msg1) or (z > 50)
if uo.InJournal('hungry') or uo.InJournal('starving') then
uo.FindType(food,'-1',sunduk)
uo.moveitem('finditem','20')
repeat
uo.UseType(food)
wait(750)
until uo.InJournal('simply')
end if
wend
end sub
Здесь сделано меню через переменные,-ты сделай через массив
Posted: 2008-08-04 10:07:35
by Destruction
Дык в чём проблема? - Джойна конечно нет, но есть руки, не так ли? -)
Code: Select all
sub main()
var count = 3
DIM promts[ val( str( count ) ) ]
DIM choice[ val( str( count ) ) ]
promts[0] = "Blacksmithing"
choice[0] = "Weapons"
promts[1] = "Weapons"
choice[1] = "Swords & Blades"
promts[2] = "Swords & Blades"
choice[2] = "cutlass (8 iron ingot)"
WaitMenu( promts, choice, count )
endsub
sub WaitMenu( promts, choice, len )
var i, menu = "waitmenu"
for i = 0 to len -1
menu = menu + " '" + promts[ i ] + "' '" + choice[ i ] + "'"
next
uo.exec( menu )
endsub
Теоретически должно работать, если кавычки не закосячит -)
PS: Вроде не сложная конструкция, странно почему раньше подобного не видел.
а, собственно, вопрос про массивы и несовсем...
Posted: 2008-09-13 13:44:15
by Millerbeer
Если я хочу, чтобы функция вернула мне несколько параметров, могу я в этой функции запихнуть эти параметры в массив и воткнуть в скрипте команду
, а в вызывающей функции проинициализировать массив и присвоить ему значение вызываемой функции? И если я не могу так сделать, то как мне вернуть членораздельно из функции несколько параметров, что б вызывающая функция знала где чего? Вот...