Posted 07 September 2012 - 01:37 PM
Hey all, is there a way to get the current contents of the console? I'm sure it is stored in a table somewhere to be reprinted if the window is full. does anyone know where it is?
hiddenTab = {}
function myWrite(whatRite)
local hiddenStr = ""
x, y = term.getCursorPos()
for i = 1, y do
hiddenStr = hiddenStr .. "n"
end
for i = 1, x do
hiddenStr = hiddenStr .. " "
end
hiddenStr = hiddenStr .. whatRite
hiddenTab[#hiddenTab+1] = hiddenStr
term.write(whatRite)
end
funcs={}
record={}
for k,v in pairs(term.native) do
funcs[k]=v
end
record={}
funcs.write=function(...) table.insert(record,...) return turtle.native.write(...) end
term.redirect(funcs)
funcs={}
record={}
for k,v in pairs(term.native) do
funcs[k]=function(...) table.insert(record,{v,[2]={...}}) return v(...) end
funcs[k..'2']=v
end
term.redirect(funcs)
for k,v in pairs(record) do v[1](unpack(v[2])) sleep(0) end
term.clear() --you can store an alternate clear function in the func table so it won't call again if you like... up to you
for k,v in pairs(record) do v[1](unpack(v[2])) sleep(0.1) end