Skip to content

Instantly share code, notes, and snippets.

@hobione2k
Created May 30, 2023 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hobione2k/89ced14c67718737bb31f43be552d8dc to your computer and use it in GitHub Desktop.
Save hobione2k/89ced14c67718737bb31f43be552d8dc to your computer and use it in GitHub Desktop.
ClusterScript-一定間隔で実行
const intervalTask = (name, interval, deltaTime) => {
const key = `intervalTask_${name}}`;
$.state[key] = ($.state[key] ?? interval) + deltaTime;
if ($.state[key] < interval) return false;
$.state[key] = 0;
return true;
};
@hobione2k
Copy link
Author

使い方

$.onUpdate((deltaTime) => {
  if (intervalTask("Task1", 5, deltaTime)) {
    // 5秒間隔で何か実行
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment