Spoiler
-- Draw a line at <sheight> function line(sheight) s = "" swidth = term.getSize() term.setCursorPos(1,sheight) for i = 1, swidth do s = s.."-" end print(s) end -- Print text centered at line <sheight> function printC(text, sheight) swidth = term.getSize() swidth = math.ceil((swidth/2) - (string.len(text)/2)) term.setCursorPos(swidth, sheight) print(text) end -- Clear screen and set cursor pos function cScreen(swidth, sheight) term.clear() term.setCursorPos(swidth, sheight) end -- Wait for key pressing function waitForKey() while true do local sEvent,param = os.pullEvent("key") if sEvent == "key" then if param == 200 then term.scroll(-1) elseif param == 208 then term.scroll(1) elseif param ~= 200 or 208 then startup() end end end end -- Print a microphone function mic() print(" .::. ") print(" ///\\\\\\") print(" ||||||") print(" HH |||||| HH") print(" HH==========HH") print(" HH==========HH") print(" HH ###### HH") print(" HH #### HH") print(" HH ## HH") print(" HH HH") print(" \\\\ // ") print(" \\\\ // ") print(" ___\\/___ ") end -- Print a progress bar function progressBar() swidth, sheight = 22,15 local function doWrite(char) term.setCursorPos(22, 15) term.setCursorBlink(false) write("Loading "..char) sleep(0.1) end for i = 1,10 do doWrite("|") doWrite("/") doWrite("-") doWrite("\\") end getMessage() end function getMessage() input = answer answer = textutils.urlEncode(answer) http.request("http://api.wolframalpha.com/v2/query?appid=5KGYY5-YE2JLLG74H&input="..answer.."&format=plaintext") local sEvent, url, sourceText = os.pullEvent() if sEvent == "http_success" then local respondedText = sourceText.readAll() text = {} index = 1 for content in respondedText:gmatch "<plaintext>(.-)</plaintext>" do table.insert(text, content) text[index] = string.gsub(text[index],"'","'") text[index] = string.gsub(text[index],""","\"") index = index + 1 end while true do cScreen(1,1) line(1) printC("CCiri V "..version, 2) line(3) if text[1] ~= nil then write("Input: "..input, 5) print("\n") index = 2 for i = 1,#text - 1 do print(text[index].."\n") index = index + 1 end parallel.waitForAny(waitForKey) else printC("Output: No answer found",7) end waitForKey() end elseif sEvent == "http_failure" then progress = false cScreen(1,1) line(1) printC("CCiri V "..version, 2) line(3) write("Couldn't contact server") waitForKey() end end function cciri() cScreen(1,1) line(1) printC("CCiri V "..version, 2) line(3) mic() line(17) line(19) term.setCursorPos(1,17) write("> ") answer = read() end function startup() cciri() -- parallel.waitForAny(wait,progressBar) getMessage() end version = "1.0" startup()