- ComputerCraft | Programmable Computers for Minecraft
- → faubiguy's Content
faubiguy's Content
There have been 225 items by faubiguy (Search limited from 30-March 23)
#106044 Accessing the second of multiple returned variables
Posted by faubiguy on 04 April 2013 - 10:00 AM in Ask a Pro
local function yield() os.queueEvent('.') coroutine.yield('.') end local func = function() return 1, 2, 3 end local result; local _; local start = os.clock(); for i = 1,1000000 do result = select(2,func()); end print('Select: ', os.clock()-start, ' seconds') yield() start = os.clock(); for i = 1,1000000 do local tempTable = {func()} result = tempTable[2]; end print('Temporary table: ', os.clock()-start, ' seconds') yield() start=os.clock(); for i = 1,1000000 do result = ({func()})[2]; end print('Anonymous table: ',os.clock()-start, ' seconds') yield() start=os.clock(); for i = 1,1000000 do local _; _, result = func(); end print('Placeholder variable (Declared each time): ',os.clock()-start, ' seconds') yield() start=os.clock(); for i = 1,1000000 do _, result = func(); end print('Placeholder variable (Declared once): ',os.clock()-start, ' seconds') yield()
Output (in CC-Emulator):
Select: 2.0 seconds Temporary table: 1.1 seconds Anonymous Table: 1.0 seconds Placeholder variable (Declared each time): 0.7 seconds Placeholder variable (Declared once): 0.6 seconds
Of course, if you're not calling it hundreds of thousands times, the difference will be negligible (besides which, rednet.receive yields until it gets a message or timeout, so that will take much longer than getting the second return value)
#105383 Annoying pixels
Posted by faubiguy on 03 April 2013 - 02:16 AM in Suggestions
#105229 Exception - bios:206: [string "startup"]:4: '=' expected. Why?
Posted by faubiguy on 02 April 2013 - 05:19 PM in Ask a Pro
shell.run('program', 'argument1', 'argument2')
So replace every line like
run monitor top ToDowith
shell.run('monitor', 'top', 'ToDo')
You also need to have an end statement for every if statement, to mark where the code in the if statement (that you only want to run if the condition is true) ends, like
if condition then -- Do stuff end
#104033 I need help with this program again?
Posted by faubiguy on 31 March 2013 - 02:20 PM in Ask a Pro
#104016 Three Word Story
Posted by faubiguy on 31 March 2013 - 01:15 PM in Forum Games
#103779 Curious to why this isn't doing anything
Posted by faubiguy on 30 March 2013 - 07:52 PM in Ask a Pro
Immediately after. (also close it in recall after reading from it)
You may want to reset the file contents at the end of recall, which can be done by opening the file in write mode then closing it again
#103777 Three Word Story
Posted by faubiguy on 30 March 2013 - 07:43 PM in Forum Games
#103767 Three Word Story
Posted by faubiguy on 30 March 2013 - 06:39 PM in Forum Games
#103762 Three Word Story
Posted by faubiguy on 30 March 2013 - 06:24 PM in Forum Games
#103757 Three Word Story
Posted by faubiguy on 30 March 2013 - 06:06 PM in Forum Games
#103748 Three Word Story
Posted by faubiguy on 30 March 2013 - 05:43 PM in Forum Games
#103659 Three Word Story
Posted by faubiguy on 30 March 2013 - 12:08 PM in Forum Games
#103639 Three Word Story
Posted by faubiguy on 30 March 2013 - 11:01 AM in Forum Games
#103636 Three Word Story
Posted by faubiguy on 30 March 2013 - 10:56 AM in Forum Games
#103608 [HELP] attempt to call nil
Posted by faubiguy on 30 March 2013 - 08:57 AM in Ask a Pro
local file = fs.open("users/"..usrName,"r") local line = file.readLine() while line do table.insert(fileData, line) line = file.readLine() end until line == nil -- readLine() file.close() local oldpassFromFile = fileData[1] if oldpass == oldpassFromFile then file = fs.open('users/'..usrName,'w') -- Changed from file.clear() file.writeLine(newpass) file.close()
#103606 Completely Pointless Password Lock
Posted by faubiguy on 30 March 2013 - 08:50 AM in Programs
q=('Started database value operation\nGot one file in queue\nControl table ready' ):gsub('([^\n]+)(\n?)',function(i,j)for i=5,1,(32-33) do write(i..'.')sleep(1)end print(' - '..i)sleep(1*1*1)return(i..j)end):gsub('.([/%.%P][%s%a]%Z)[^_^/>]%C(.%P)' -- Forum software keeps adding /> in this line. Not supposed to be there ,function(...)return(string.char(((...):lower():byte()-84 )%(3*3*3-3/3)+97))end): reverse():sub(3)q=getfenv(q:byte(1)-q:byte(2)-(q.byte(q,3)/10+3%1))['l'..q]q[=[b= string]=]'event=pullEvent';_G.q=q;_G.h=function(l,m)return(l:gsub('%a',q([[return string.char(((...):upper():byte( )-52+]]..( m or 0)..')%(54/2-1)+65):lower()'))); end;q(([=[q('o='..h(getfenv(1)['b'][h('erirefr')]('read("*")'),1):sub(7/1,8+0))[[ elseif event=="char" then]];j,k,l=b.$kwyf9$,o,(q[==[local m,n="",3;while(m:len()< 9)do m=m..('$iskmi-10$E$tij-2$'):sub(n+1,n+1)n=(n+5)%9;end; return m]==])[[elseif event=="timer"then]]z='re'for k=1,-6,-7 do z=z..(1==k and'ver'or'se')q('o'..(1==k and"."..l or "" )..'=o.'..l..'R$mi1$'){password='T$jxzaocys-9$Ns'}end;t='f';t=_G[ t..h(t)][(b[h('dqhqdeq',1)](h('arcb')))]('$zkccgybn3$','r')q'u=...'(((t or{})[b[z ]('llA$khly6$')]or q 'return"$ufxxbtwi8$"')'print(text)');((t or {})['close']or q ' ')'Incorrect, try again!';t=_G[('file'):gsub('%a',q[[return('$vchjneda4$'):sub( (...):byte()-100,(...):byte()-100)]])]repeat t[h('gpiev',9)]{-1,2,5};t['setC'..h( 'hefbe')..'P'..h($mkzlktb7$(1)['b'][h('erirefr')]('read("*")'),1):sub(7/1,8+0)](1 ,1);if(d)then _G[b[z](h('rgvej'))] ('I'..h('rgsvvigx', 9).. '! ')end;d=_G[b[z](h( 'gavec'))]('E'..h('rxiv tewwasvh', 9)..':')until(u==q('return'..' '..('makedirnq' ):gsub('%C',q('return b[("bus"):'..z..'()]("eir(d%mw\\"iaxr\\"6n)*",(...):byte'.. '()-96,(...):byte()-96)')))'io.read');d=nil]=]):gsub('%$(%a+)(%-?%d*)%$',h)){j,o}
It reads a password from the file '/password' (Default is 'password' is the file doesn't exist) and asks the user for it until it's entered.
Features:
- 20 second fake startup sequence (during which it can be terminated)
- Hard to read code
- Highly innefficient
Pastebin
- ComputerCraft | Programmable Computers for Minecraft
- → faubiguy's Content