Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Programming Environment")
- print("Commands: 'run <file>', 'save <file>', 'load <file>', 'exit'")
- while true do
- write("> ")
- local input = read()
- local command, arg = string.match(input, "^(%S+)%s*(.*)$")
- if command == "run" and arg then
- if fs.exists(arg) then
- local success, err = pcall(function() shell.run(arg) end)
- if not success then
- print("Error: " .. err)
- end
- else
- print("File not found.")
- end
- elseif command == "save" and arg then
- write("Enter your code. Type 'end' to finish.")
- local code = ""
- while true do
- local line = read()
- if line == "end" then break end
- code = code .. line .. "\n"
- end
- local file = fs.open(arg, "w")
- file.write(code)
- file.close()
- print("File saved as " .. arg)
- elseif command == "load" and arg then
- if
Advertisement
Add Comment
Please, Sign In to add comment