autosave.js 461 B

123456789101112131415161718192021222324
  1. let plugin = plugin_create();
  2. let h1 = ui_handle_create();
  3. let h2 = ui_handle_create();
  4. ui_handle_set_value(h2, 5.0);
  5. let timer = 0.0;
  6. plugin_notify_on_ui(plugin, function() {
  7. if (ui_panel(h1, "Auto Save")) {
  8. ui_slider(h2, "min", 1, 15, false, 1);
  9. }
  10. });
  11. plugin_notify_on_update(plugin, function() {
  12. if (project_filepath_get() == "") {
  13. return;
  14. }
  15. timer += 1 / 60;
  16. if (timer >= ui_handle_get_value(h2) * 60) {
  17. timer = 0.0;
  18. project_save();
  19. }
  20. });