|
| 26 Aug 2013 08:31 PM |
| I forgot which one gets all of the table. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2013 08:33 PM |
pairs.
ipairs only gets the indices that are numbers |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Aug 2013 09:27 PM |
function test(qq) for i, v in pairs(Game.Workspace:GetChildren()) do print(qq) end end function test2(qq) for i, v in ipairs(Game.Workspace:GetChildren()) do print(qq) end end
Delay(0, test) Delay(0, test2) |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2013 09:29 PM |
| Man you are such a guud scripter. HOw did you learn this stuff cnt? And do you wrte on the wiki? Oh and thanks. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Aug 2013 09:30 PM |
| I think all the wiki topics are taken lol |
|
|
| Report Abuse |
|
|
shonclub
|
  |
| Joined: 05 Sep 2009 |
| Total Posts: 1331 |
|
| |
|
|
| 26 Aug 2013 09:30 PM |
| Kohl? I keep hearing about his admin scripts who is he!? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Aug 2013 09:31 PM |
| He made a bad, popular admin skirpt |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2013 09:33 PM |
| :o Okay, uncle cntkillme what is his username? And why is his admin scrpt bad? My friend told me tat people think person229 is sloppy admin scrpt |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Aug 2013 09:34 PM |
person's is also bad. His name is like kohlstophe or something, he's bannered cuz he mad bad script c: (idk why he's banned) |
|
|
| Report Abuse |
|
|
shonclub
|
  |
| Joined: 05 Sep 2009 |
| Total Posts: 1331 |
|
|
| 26 Aug 2013 09:35 PM |
| He got banned for try to get ookers on roblox. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Aug 2013 09:38 PM |
cntkillme: The delay time is a matter of how long the delay was in starting the function call, not execution, and since you call one first, it's not surprising that it finished first since there's nothing going on in either function. TL;DR: That's a really terrible way to show one is faster.
local t = {}; for i = 1, 10000 do table.insert(t,math.random()); end
function one() local s = 0; for i,v in pairs(t) do s = s + v; end return s; end
function two() local s = 0; for i,v in ipairs(t) do s = s + v; end return s; end
print(".");
local time; time = tick(); for j=1,1000 do one(); end print(tick() - time,1);
local time; time = tick(); for j=1,1000 do two(); end print(tick() - time,2);
two takes 4% longer than one one 10,000 elements, and similar results are seen on 5,000 elements (~4%) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Aug 2013 09:41 PM |
@Blue Delays run on separate "threads", it's not going to wait for the first one to finish. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2013 09:42 PM |
| I know, that's not relevant, is it? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Aug 2013 09:43 PM |
| I read your thing wrong, oops c; |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2013 09:49 PM |
Oh, but relevant advice: ipairs and pairs are both dreadfully slow.
function three() local s = 0; for i=1,#t do local v = t[i]; s = s + v; end return s; end
This is about three times faster than pairs/ipairs (although it only replaces the functionality of ipairs). When ipairs is possible and you're worrying about efficient, use this. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|