0 Members and 1 Guest are viewing this topic.
tn, msg = 0, "";t, n, aa, a10, b = 0, 0, 0, 0, 0save = falsetimes = {};function a()local min, avg10, avga = 2^32, 0, 0for i = 1, tn dolocal v = times[i]if v < min thenmin = vendif i <= 10 thenavg10 = avg10 + vendavga = avga + vendb = minaa = math.floor(avga/tn)a10 = math.floor(avg10 / math.min(tn, 10))endfunction f(t)return ("%02d:%02d.%02d"):format(t/60000, t/1000%60, t/10%100)endfunction on.paint(g)if c thent = (timer.getMilliSecCounter() - n)endg:drawString("time: " .. f(t), 0, 0, "top");g:drawString(msg, 0, 20, "top");g:drawString("best: " .. f(b), 150, 0, "top");g:drawString("average (10): " .. f(a10), 150, 20, "top");g:drawString("average (all): " .. f(aa), 150, 40, "top");for i = 1, 8 dolocal v = times[i];if not v then break endg:drawString(i .. ") " .. f(v), 0, 20+i*20, "top")endtimer.start(0.01);endfunction on.timer()timer.stop()platform.window:invalidate()endfunction on.charIn(c)if save thensave = falsemsg = ""if c == "y" thentable.insert(times, 1, t)tn = tn + 1a()on.charIn("s")endendif c == "d" thent = 0times = {};tn = 0;msg = "";a();elseif c == "s" thenlocal s = "" .. tnmsg = "saved"for i = 1, tn dos = s .. " " .. times[i]endvar.store("cube_times", s .. " ");elseif c == "r" thenlocal s, b , n = var.recall("cube_times") or "0 ", {}, 0;msg = "loaded";for w in s:gmatch("%d+%s") don = n + 1;b[n] = tonumber(w);endtn = table.remove(b, 1);times = b;a();endendfunction on.enterKey() if save then save = falsemsg = ""returnendif c thensave = true;msg = "save? (y/n)";c = nil;elsec = true;msg = "";n = timer.getMilliSecCounter();endendon.charIn("r")
nice, but i had to put this in the code:[code],2^32,2^32
function a()local min, avg10, avga = 2^32[b],2^32,2^32[/b]
nice, but i had to put this in the code:Code: [Select],2^32,2^32in Code: [Select]function a()local min, avg10, avga = 2^32,2^32,2^32and the averages are in milliseconds again?but except for those things, it works perfect, and is fast (i mean it stops when you enter, and not a second later)
,2^32,2^32
function a()local min, avg10, avga = 2^32,2^32,2^32
one thing you could add is a random scrambler to (well yeah, you could guess this) scramble the cube before you start (like RU (right up) LD (left down) etc etc) so you can totally use it as a rubik's gameoh and do you use the modulus to calculate, or another way?is scramble te right word for this? xp