Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- The Aware Project
- by Creator
- for TheOS
- ]]--
- --[[
- First I am doing the mechanics of the program, afterwards I will do the GUI
- ]]--
- --GUI
- --if _G.Interact == nil then os.loadAPI("TheOS/API/Interact") end
- --local gui = Interact.Initialize()
- --Variables--
- local input = {}
- local Commands = {}
- local path = "TheOS/Programs/Aware.app/"
- --Functions--
- function split(str,sep)
- local buffer = {}
- for token in str:gmatch(sep) do
- buffer[#buffer+1] = token
- end
- return buffer
- end
- function getData()
- local var = http.get("https://raw.githubusercontent.com/TheOnlyCreator/Aware/master/Test/Test")
- print(var.readAll())
- os.pullEvent()
- error()
- end
- local function readFile(_path)
- local file = fs.open(_path,"r")
- local data = file.readAll()
- file.close()
- return data
- end
- function filter()
- end
- function redirect(word)
- print("Your word is "..word)
- oneWordCommand(word)
- end
- function respond(arg)
- print(_G[arg][math.random(1,#_G[arg])])
- end
- function oneWordCommand(word)
- if Commands[word] ~= nil then
- local func = loadstring(Commands[word])
- func()
- else
- local firstLetter = string.sub(word,1,1)
- print(firstLetter)
- local fromWeb = http.get("https://raw.githubusercontent.com/TheOnlyCreator/Aware/master/Actions/"..firstLetter)
- local buffer = fromWeb.readAll()
- local tableFromWeb = textutils.unserialize(buffer)
- print(tableFromWeb[word])
- local func = loadstring(tableFromWeb[word])
- func()
- end
- end
- function main()
- print("I am listening...")
- local buffer = read()
- input = split(buffer,"[^%s]+")
- for i,v in pairs(input) do
- input[i] = string.lower(v)
- end
- for i,v in pairs(input) do
- print(v)
- end
- if #input == 1 then
- oneWordCommand(input[1])
- else
- end
- end
- --Code--
- local buffer = readFile(path.."Commands")
- Commands = textutils.unserialize(buffer)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- while true do
- main()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement