Add optional support for 6d facedir in dir_to_facedir and add facedir_to_dir to the API to complement it

by way of Lua calling conventions, 6d support in dir_to_facedir is off by default; thus, these changes will not affect the behavior of any existing code

let me know if the code style is non-conformant for any reason (or if it should be implemented differently)