Script Problem

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
dizzy

Script Problem

Post by dizzy » July 14th, 2007, 5:43 am

I know for sure this is not the right script...

But do you think you could clairify for me how to do arrays?

Code: Select all

main()
{
thread run();
}
run()
{
trig = getent ("trig","targetname");
step = getentarray ("step","targetname");
{
trig waittill ("trigger", user);
user iprintln ("HI");
step[0] moveto (200,32,248,1);
step[1] moveto (200,32,248,.9375);
step[2] moveto (200,32,248,.875);
step[3] moveto (200,32,248,.8125);
step[4] moveto (200,32,248,.75);
step[5] moveto (200,32,248,.6875);
step[6] moveto (200,32,248,.625);
step[7] moveto (200,32,248,.5625);
step[8] moveto (200,32,248,.5);
step[9] moveto (200,32,248,.4375);
step[10] moveto (200,32,248,.375);
step[11] moveto (200,32,248,.3125);
step[12] moveto (200,32,248,.25);
step[13] moveto (200,32,248,.1825);
step[14] moveto (200,32,248,.125);
step[15] moveto (200,32,248,.0625);
user iprintln ("HI");   
}
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » July 14th, 2007, 1:48 pm

the main way of using arrays is combining them with for loops which basically tell the entire array to repeat the same action for every part of the array...

you script has a changing deceleration so it makes it slightly harder, your pattern is currently irregular making this slightly harder but can still be done.

Through the use of some maths and code, hopefully this should work.

Code: Select all

pattern = ((1 - 0.625) / array.size;
j=undefined;
for(i=0;i<array.size;i++)
{
j = 1 - (pattern * i);
iprintln(j); //Debug
array[i] moveto (200, 32, 248, j);
}
So your full code is...

Code: Select all

main()
{
thread run();
}
run()
{
trig = getent ("trig","targetname");
step = getentarray ("step","targetname");
pattern = ((1 - 0.625) / step.size);
j=undefined;
while(1)
{
trig waittill ("trigger", user);
user iprintln ("Start"); // Debug

for(i=0;i<step.size;i++)
{
j = 1 - (pattern * i);
iprintln(j); // Debug
step[i] moveto (200, 32, 248, j);
}
user iprintln ("End");   // Debug
}
}
I corrected a mistake where you did not put the 'while' function. You cannot open { brackets for no reason, they must be along side a function that allows them, such as 'while', 'for', 'if' and when you open a function (main() {})
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests