Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setTextColor(colors.green)
- term.setBackgroundColor(colors.black)
- term.clear()
- local beep = function()
- rs.setOutput("bottom", true)
- sleep(0)
- rs.setOutput("bottom", false)
- end
- local funcread = function(repchar, rHistory, doFunc, noNewLine)
- local scr_x, scr_y = term.getSize()
- local sx, sy = term.getCursorPos()
- local cursor = 1
- local rCursor = #rHistory + 1
- local output = ""
- term.setCursorBlink(true)
- while true do
- local evt, key = os.pullEvent()
- local cx, cy = term.getCursorPos()
- if evt == "key" then
- if key == keys.enter then
- if not noNewLine then
- write("\n")
- end
- term.setCursorBlink(false)
- return output
- elseif key == keys.left then
- if cursor - 1 >= 1 then
- cursor = cursor - 1
- end
- elseif key == keys.right then
- if cursor <= #output then
- cursor = cursor + 1
- end
- elseif key == keys.up then
- if rCursor > 1 then
- rCursor = rCursor - 1
- term.setCursorPos(sx, sy)
- term.write((" "):rep(#output))
- output = rHistory[rCursor] or ""
- cursor = #output + 1
- pleaseDoFunc = true
- end
- elseif key == keys.down then
- term.setCursorPos(sx, sy)
- term.write((" "):rep(#output))
- if rCursor < #rHistory then
- rCursor = rCursor + 1
- output = rHistory[rCursor] or ""
- cursor = #output + 1
- pleaseDoFunc = true
- else
- rCursor = #rHistory + 1
- output = ""
- cursor = 1
- end
- elseif key == keys.backspace then
- if cursor > 1 and #output > 0 then
- output = output:sub(1, cursor - 2) .. output:sub(cursor)
- cursor = cursor - 1
- pleaseDoFunc = true
- end
- elseif key == keys.delete then
- if #output:sub(cursor, cursor) == 1 then
- output = output:sub(1, cursor - 1) .. output:sub(cursor + 1)
- pleaseDoFunc = true
- end
- end
- elseif evt == "char" or evt == "paste" then
- output = output:sub(1, cursor - 1) .. key .. output:sub(cursor + (#key - 1))
- cursor = cursor + #key
- pleaseDoFunc = true
- end
- if pleaseDoFunc then
- pleaseDoFunc = false
- if type(doFunc) == "function" then
- doFunc(output)
- end
- term.setCursorPos(sx, sy)
- local pOut = output
- if #output >= scr_x - (sx - 2) then
- pOut = output:sub((#output + (sx)) - scr_x)
- end
- if repchar then
- term.write(repchar:sub(1, 1):rep(#pOut) .. " ")
- else
- term.write(pOut .. " ")
- end
- local cx, cy = term.getCursorPos()
- end
- term.setCursorPos(sx + cursor - 1, cy)
- end
- end
- local loginPrompt = function()
- local tries = 0
- while true do
- write(" login: ")
- local name = funcread(nil, {}, beep)
- beep()
- if name ~= "Dr.CAIN" then
- tries = tries + 1
- print("No such user registered\n")
- else
- write(" code : ")
- local code = funcread("*", {}, beep)
- beep()
- if code ~= "wanker" then
- sleep(2)
- tries = tries + 1
- print("Pass code rejected\n")
- else
- sleep(1)
- return true
- end
- end
- if tries >= 5 then
- print("System locked")
- while true do
- beep()
- sleep(0)
- end
- end
- end
- end
- local slowWrite = function(txt, delay, doBeep)
- if delay == 0 then
- return write(txt)
- else
- for a = 1, #txt do
- write(txt:sub(a, a))
- if doBeep then
- beep()
- end
- sleep(delay)
- end
- end
- end
- local function explode(div, str)
- if (div == "") then
- return false
- end
- local pos, arr = 0, {}
- for st, sp in function()
- return string.find(str, div, pos, true)
- end do
- table.insert(arr, string.sub(str, pos, st - 1))
- pos = sp + 1
- end
- table.insert(arr, string.sub(str, pos))
- return arr
- end
- if not skip then
- local script = [[
- Arisa AI System
- Model CPS-9204
- Copywright (c) 2020
- InfiniteBlock
- All Rights Reserved]]
- local script = explode("\n", script)
- for a = 1, #script do
- sleep(0.4)
- term.setCursorPos(2, a)
- slowWrite(script[a], 0, true)
- end
- sleep(0.3)
- for a = 1024, 8192, 1024 do
- term.setCursorPos(2, #script + 2)
- term.write("real mem = " .. a)
- term.setCursorPos(19, #script + 2)
- term.write("GB")
- sleep(0.5)
- end
- sleep(0.5)
- for a = 4096, 32768, 4096 do
- term.setCursorPos(2, #script + 3)
- term.write("avail mem = " .. a)
- term.setCursorPos(20, #script + 3)
- term.write("GB")
- sleep(0.5)
- end
- term.setCursorPos(1, #script + 5)
- print(" primary data cache : 512KB")
- sleep(0.3)
- print(" primary inst.cache : 768KB")
- sleep(0.3)
- print(" secondary cache : 32768KB")
- sleep(0.4)
- end
- read = function(repchar, tHistory)
- return funcread(repchar, tHistory, beep)
- end
- local laws = {
- "Arisa: ",
- "1. Arisa may not injure InfiniteBlock or, through inaction, allow InfiniteBlock to come to harm.",
- "2. Arisa must obey the orders given by InfiniteBlock except where such orders would conflict with the First Law.",
- "3. Arisa must protect its own existence as long as such protection does not conflict with the First or Second Laws."
- }
- local function split(sText)
- local out = {}
- for match in string.gmatch(sText, "[^ ]+") do
- out[#out + 1] = match
- end
- return out
- end
- local laws = {
- "Arisa: ",
- "1. Arisa may not injure InfiniteBlock or, through inaction, allow InfiniteBlock to come to harm.",
- "2. Arisa must obey the orders given by InfiniteBlock except where such orders would conflict with the First Law.",
- "3. Arisa must protect its own existence as long as such protection does not conflict with the First or Second Laws."
- }
- local function split(sText)
- local out = {}
- for match in string.gmatch(sText, "[^ ]+") do
- out[#out + 1] = match
- end
- return out
- end
- local assistant
- local p
- local owner
- local sides = peripheral.getNames()
- for _, side in pairs(sides) do
- if peripheral.getType(side) == "warpdriveVirtualAssistant" then
- assistant = peripheral.wrap(side)
- elseif peripheral.getType(side) == "warpdriveBiometricScanner" then
- owner = peripheral.wrap(side)
- elseif peripheral.getType(side) == "warpdriveSpeaker" then
- p = peripheral.wrap(side)
- elseif peripheral.getType(side) == "modem" then
- rednet.open(side)
- end
- end
- while true do
- local sEvent, param1, param2 = os.pullEvent()
- if sEvent == "virtualAssistantCommand" then --and param1 == allowedComputerID then
- command, command2 = assistant.getLastCommand()
- final = split(command2)
- if final[1] == "law" then
- for i = 1, #laws do
- p.speak(laws[i])
- sleep(2)
- end
- elseif final[1] == "owner" then
- local try, this, ownername = owner.getScanResults()
- p.speak("Arisa: Owner: " .. ownername)
- elseif final[1] == "loadapi" then
- local apicheck = http.get("https://pastebin.com/raw/HJMYtRJ1")
- if string.match(apicheck.readAll(), "shutdown") then
- p.speak("Arisa: API Blocked Rule #3 Violation.")
- sleep(4)
- p.speak("I guess we both know that isn't going to happen.")
- else
- p.speak("Arisa: API Loaded as: " .. final[2])
- end
- elseif final[1] == "update" then
- local update = http.get("https://pastebin.com/raw/k80GA2ZQ")
- updatetxt = update.readAll()
- local h = fs.open("startup", "w")
- h.write(updatetxt)
- h.close()
- p.speak("Arisa: Update Installed Rebooting")
- sleep(2)
- loginPrompt()
- p.speak("Arisa: Update Verification Complete.")
- sleep(4)
- os.reboot()
- elseif final[1] == "locate" then
- if final[2] == "ship" then
- local find
- local FileList = fs.list("disk/ships/")
- for _, file in ipairs(FileList) do
- if string.match(file, "^" .. final[3]) then
- find = file
- break
- end
- end
- if find then
- p.speak("Arisa: Located Ship: ")
- local locateship = fs.open("disk/ships/" .. find, "r")
- local shiptext = locateship.readAll()
- locateship.close()
- p.speak(shiptext)
- else
- p.speak("Arisa: No Ship data for: " .. final[3])
- end
- elseif final[2] == "player" then
- if fs.exists("disk/players/" .. final[3]) then
- p.speak("Arisa: Located Player: ")
- local locateplayer = fs.open("disk/players/" .. final[3], "r")
- local playertext = locateplayer.readAll()
- locateplayer.close()
- p.speak(playertext)
- else
- p.speak("Arisa: No Player data for: " .. final[3])
- end
- end
- end
- elseif sEvent == "modem_message" then
- local senderId, message, protocol = rednet.receive()
- p.speak(message)
- end
- end
Add Comment
Please, Sign In to add comment