Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Library code used by the example programs
- -- Computercraft version
- --
- -- Utility for calling a function and printing the
- -- error message if it throws an exception
- function try(func, ...)
- ok, result = pcall(func, ...)
- if not ok then
- print("Error: " .. result)
- end
- end
- -- Terminal API compatibility functions
- screen_width, screen_height = term.getSize()
- function setCursor(col, row)
- term.setCursorPos(col, row)
- end
- -- Event API compatibility functions
- function pull_event()
- return os.pullEvent()
- end
- key_event_name = "char"
- function key_event_char(e)
- return e[2]
- end
- -- Error message compatibility functions
- function extractErrorMessage(mess)
- i = string.find(mess, "\n")
- if i then
- mess = string.sub(mess, i - 1)
- end
- i = string.find(mess, ":")
- while i do
- mess = string.sub(mess, i + 1)
- i = string.find(mess, ":")
- end
- return mess
- end
Add Comment
Please, Sign In to add comment