Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
- ]]--
- sessionId = tostring(math.random(10000, 99999))
- rednet.broadcast(sessionId, "WirelessOS")
- cd = ""
- function string:split(query)
- local result = {}
- local sections = {1}
- for i = 1, (#self - (#query - 1)) do
- if self:sub(i, i + #query - 1) == query then
- if (self:sub(sections[#sections], i - 1)) ~= query then
- result[#result + 1] = self:sub(sections[#sections], i - 1)
- end
- sections[#sections + 1] = sections[#sections] + #(self:sub(sections[#sections], i))
- end
- end
- if sections[#sections] > #self then else
- result[#result + 1] = self:sub(sections[#sections], #self)
- end
- if result == {} then
- result[1] = self
- end
- return result
- end
- function run(program)
- tArgs = program:split(" ")
- if tArgs[1] == "cd" then
- shell.setDir(tArgs[2])
- cd = tArgs[2]
- else
- shell.run(unpack(tArgs))
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("ArtificialOS 1.0")
- while true do
- write(cd.."> ")
- prog = read()
- rednet.broadcast(prog, sessionId)
- if prog ~= "" then
- if prog:split(" ")[1] == "exit" then
- break
- else
- run(prog)
- end
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement