naknak Administrator


Posts: 865 Join date: 2010-07-30
 | Subject: Re: Anti-Ban script January 18th 2011, 6:07 pm | |
| This is an example of its basic use. | Code: | days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} revdays = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} for i,v in ipairs(days) do revdays[v] = i print(revdays[v]) end
|
This will print 1 through 7. Of course, there is probably better uses ;) |
|
blueymaddog Administrator


Posts: 1081 Join date: 2010-12-09 Age: 14
 | Subject: Re: Anti-Ban script January 20th 2011, 2:49 pm | |
| such as iriterating through every player and making them all do something. _________________ blueymaddog Administrator • Moderator • Expert Scripter PM: blueymaddog<+1 post. ujelly?> |
|
Supernapalm Expert Scripter


Posts: 393 Join date: 2011-01-17
 | Subject: Re: Anti-Ban script January 20th 2011, 5:15 pm | |
| actually its | Code: | days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
for i,v in ipairs(days) do revdays[v] = i print(revdays[v]) end |
copied this from the lua book? and that still doesnt point out what the difference between pairs and ipairs. i believe its that pairs is for tables and ipairs is for arrays. your confusing me thats why im asking. |
|
Supernapalm Expert Scripter


Posts: 393 Join date: 2011-01-17
 | Subject: Re: Anti-Ban script January 20th 2011, 5:16 pm | |
| and i already know what iterators are (forgot to add that) |
|
naknak Administrator


Posts: 865 Join date: 2010-07-30
 | Subject: Re: Anti-Ban script January 20th 2011, 6:32 pm | |
| Yes, I copied it. Since I have literally never used ipairs. I see no point in it. |
|
blueymaddog Administrator


Posts: 1081 Join date: 2010-12-09 Age: 14
 | Subject: Re: Anti-Ban script January 23rd 2011, 12:54 am | |
| if something is numerical then it means that it is a number _________________ blueymaddog Administrator • Moderator • Expert Scripter PM: blueymaddog<+1 post. ujelly?> |
|
slayer9365 Expert Scripter


Posts: 233 Join date: 2010-07-31 Age: 18
 | Subject: Re: Anti-Ban script January 23rd 2011, 11:01 am | |
| I find it easier to just use the for statement because it is much easier for me to think of how i works. |
|
blueymaddog Administrator


Posts: 1081 Join date: 2010-12-09 Age: 14
 | Subject: Re: Anti-Ban script January 24th 2011, 5:07 am | |
| it is the for statement.
FOR i,v in ipairs() do _________________ blueymaddog Administrator • Moderator • Expert Scripter PM: blueymaddog<+1 post. ujelly?> |
|