All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

1 year ago
  1. import { MODULE_NAME } from "./consts.js";
  2. export function getSetting(key, localize = false) {
  3. return game.settings.get(MODULE_NAME, key);
  4. }
  5. export function setSetting(key, value) {
  6. return game.settings.set(MODULE_NAME, key, value);
  7. }
  8. export function log(message) {
  9. message = `${MODULE_NAME} | ${message}`;
  10. console.log(message.replace("<br>", "\n"));
  11. return message;
  12. }
  13. export function debug(message) {
  14. message = `${MODULE_NAME} | ${message}`;
  15. console.debug(message.replace("<br>", "\n"));
  16. return message;
  17. }
  18. export function info(message, notify = false) {
  19. message = `${MODULE_NAME} | ${message}`;
  20. if (notify) ui.notifications?.info(message);
  21. console.log(message.replace("<br>", "\n"));
  22. return message;
  23. }
  24. export function warn(warning, notify = false) {
  25. warning = `${MODULE_NAME} | ${warning}`;
  26. if (notify) ui.notifications?.warn(warning);
  27. console.warn(warning.replace("<br>", "\n"));
  28. return warning;
  29. }
  30. export function error(error, notify = true) {
  31. error = `${MODULE_NAME} | ${error}`;
  32. if (notify) ui.notifications?.error(error);
  33. return new Error(error.replace("<br>", "\n"));
  34. }
  35. export function i18n(key) {
  36. return game.i18n.localize(key)?.trim();
  37. }
  38. export function i18nFormat(key, data) {
  39. return game.i18n.format(key, data)?.trim();
  40. }
  41. export function titleCase(string) {
  42. return string[0].toUpperCase() + string.slice(1).toLowerCase();
  43. }